Skip to content

Commit

Permalink
removed extra mining in impersonating and added IncreaseTime
Browse files Browse the repository at this point in the history
Signed-off-by: Krasi Georgiev <[email protected]>
  • Loading branch information
krasi-georgiev committed Oct 30, 2022
1 parent 4d0e909 commit 174807a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions big/big_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ func TestFromFloatMul(t *testing.T) {
1e28,
1234,
},
{ // Some realistic eth price.
1296.890000,
1e18,
1296890000000000196608, // For some reason there is some precision loss?
},
}

for i, tc := range cases {
Expand Down
14 changes: 9 additions & 5 deletions localnode/localnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,15 @@ func (self *LocalNode) SetNextBlockTimestamp(ctx context.Context, ts int64) erro
return nil
}

func (self *LocalNode) IncreaseTime(ctx context.Context, seconds int64) error {
err := self.rpcClient.CallContext(ctx, nil, "evm_increaseTime", big.NewInt(seconds))
if err != nil {
return errors.Wrap(err, "calling evm_increaseTime")
}

return nil
}

func (self *LocalNode) DebugTraceTransaction(ctx context.Context, hash common.Hash) (*ethlogger.ExecutionResult, error) {
opts := struct {
DisableMemory bool `json:"disableMemory"`
Expand Down Expand Up @@ -353,11 +362,6 @@ func (self *LocalNode) TxWithImpersonateAccountWithData(ctx context.Context, fro
return nil, errors.Wrapf(err, "calling %s", callStopImpersonatingAccount)
}

if err := self.Mine(ctx); err != nil { // For some reason Anvil doesn't automine a block here.
return nil, errors.Wrapf(err, "calling Mine")

}

ethClient := ethclient.NewClient(self.rpcClient)
rcpt, err := ethClient.TransactionReceipt(ctx, common.HexToHash(txHash))
if err != nil {
Expand Down

0 comments on commit 174807a

Please sign in to comment.