Skip to content

Commit

Permalink
add test for 1559 gas estimates for the simulated backend
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Aug 2, 2021
1 parent c4cf522 commit 3b26cd1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions accounts/abi/bind/backends/simulated_test.go
Expand Up @@ -580,6 +580,16 @@ func TestEstimateGasWithPrice(t *testing.T) {
Value: big.NewInt(100000000000),
Data: nil,
}, 21000, errors.New("gas required exceeds allowance (10999)")}, // 10999=(2.2ether-1000wei)/(2e14)

{"EstimateEIP1559WithHighFees", ethereum.CallMsg{
From: addr,
To: &addr,
Gas: 0,
GasFeeCap: big.NewInt(1e14), // maxgascost = 2.1ether
GasTipCap: big.NewInt(1),
Value: big.NewInt(1e17), // the remaining balance for fee is 2.1ether
Data: nil,
}, params.TxGas, nil},
}
for i, c := range cases {
got, err := sim.EstimateGas(context.Background(), c.message)
Expand All @@ -592,6 +602,9 @@ func TestEstimateGasWithPrice(t *testing.T) {
}
continue
}
if c.expectError == nil && err != nil {
t.Fatalf("test %d: didn't expect error, got %v", i, err)
}
if got != c.expect {
t.Fatalf("test %d: gas estimation mismatch, want %d, got %d", i, c.expect, got)
}
Expand Down

0 comments on commit 3b26cd1

Please sign in to comment.