mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
accounts/abi: test insufficientfund
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
7c6d721564
commit
bc6ae2875b
1 changed files with 17 additions and 8 deletions
|
|
@ -510,26 +510,26 @@ func TestEstimateGas(t *testing.T) {
|
||||||
Data: common.Hex2Bytes("e09fface"),
|
Data: common.Hex2Bytes("e09fface"),
|
||||||
}, 21275, nil, nil},
|
}, 21275, nil, nil},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for i, c := range cases {
|
||||||
got, err := sim.EstimateGas(context.Background(), c.message)
|
got, err := sim.EstimateGas(context.Background(), c.message)
|
||||||
if c.expectError != nil {
|
if c.expectError != nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expect error, got nil")
|
t.Fatalf("test: %d expect error, got nil", i)
|
||||||
}
|
}
|
||||||
if c.expectError.Error() != err.Error() {
|
if c.expectError.Error() != err.Error() && !errors.Is(err, c.expectError) {
|
||||||
t.Fatalf("Expect error, want %v, got %v", c.expectError, err)
|
t.Fatalf("test: %d expect error, want %v, got %v", i, c.expectError, err)
|
||||||
}
|
}
|
||||||
if c.expectData != nil {
|
if c.expectData != nil {
|
||||||
if err, ok := err.(*revertError); !ok {
|
if err, ok := err.(*revertError); !ok {
|
||||||
t.Fatalf("Expect revert error, got %T", err)
|
t.Fatalf("test: %d expect revert error, got %T", i, err)
|
||||||
} else if !reflect.DeepEqual(err.ErrorData(), c.expectData) {
|
} else if !reflect.DeepEqual(err.ErrorData(), c.expectData) {
|
||||||
t.Fatalf("Error data mismatch, want %v, got %v", c.expectData, err.ErrorData())
|
t.Fatalf("test: %d error data mismatch, want %v, got %v", i, c.expectData, err.ErrorData())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if got != c.expect {
|
if got != c.expect {
|
||||||
t.Fatalf("Gas estimation mismatch, want %d, got %d", c.expect, got)
|
t.Fatalf("test: %d gas estimation mismatch, want %d, got %d", i, c.expect, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -584,6 +584,15 @@ func TestEstimateGasWithPrice(t *testing.T) {
|
||||||
Data: nil,
|
Data: nil,
|
||||||
}, 21000, errors.New("gas required exceeds allowance (10999)")}, // 10999=(2.2ether-1000wei)/(2e14)
|
}, 21000, errors.New("gas required exceeds allowance (10999)")}, // 10999=(2.2ether-1000wei)/(2e14)
|
||||||
|
|
||||||
|
{"EstimateWithInsufficientFund", ethereum.CallMsg{
|
||||||
|
From: addr,
|
||||||
|
To: &recipient,
|
||||||
|
Gas: 0,
|
||||||
|
GasPrice: big.NewInt(1),
|
||||||
|
Value: big.NewInt(3 * params.Ether),
|
||||||
|
Data: nil,
|
||||||
|
}, 0, core.ErrInsufficientFundsForTransfer},
|
||||||
|
|
||||||
{"EstimateEIP1559WithHighFees", ethereum.CallMsg{
|
{"EstimateEIP1559WithHighFees", ethereum.CallMsg{
|
||||||
From: addr,
|
From: addr,
|
||||||
To: &addr,
|
To: &addr,
|
||||||
|
|
@ -610,7 +619,7 @@ func TestEstimateGasWithPrice(t *testing.T) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("test %d: expect error, got nil", i)
|
t.Fatalf("test %d: expect error, got nil", i)
|
||||||
}
|
}
|
||||||
if c.expectError.Error() != err.Error() {
|
if c.expectError.Error() != err.Error() && !errors.Is(err, c.expectError) {
|
||||||
t.Fatalf("test %d: expect error, want %v, got %v", i, c.expectError, err)
|
t.Fatalf("test %d: expect error, want %v, got %v", i, c.expectError, err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue