accounts/abi/bind/backends: fix EstimateGas

This commit is contained in:
rjl493456442 2020-06-04 19:10:24 +08:00 committed by Péter Szilágyi
parent 7cdf4eea7e
commit 53508c5d46
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
2 changed files with 2 additions and 8 deletions

View File

@ -509,13 +509,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
if failed { if failed {
if result != nil && result.Err != vm.ErrOutOfGas { if result != nil && result.Err != vm.ErrOutOfGas {
if len(result.Revert()) > 0 { if len(result.Revert()) > 0 {
reason, err := abi.UnpackRevert(result.Revert()) return 0, newRevertError(result)
if err == nil {
return 0, &revertError{
error: errors.New("execution reverted"),
errData: reason,
}
}
} }
return 0, result.Err return 0, result.Err
} }

View File

@ -415,7 +415,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) {
GasPrice: big.NewInt(0), GasPrice: big.NewInt(0),
Value: nil, Value: nil,
Data: common.Hex2Bytes("d8b98391"), Data: common.Hex2Bytes("d8b98391"),
}, 0, errors.New("execution reverted"), "revert reason"}, }, 0, errors.New("execution reverted: revert reason"), "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d72657665727420726561736f6e00000000000000000000000000000000000000"},
{"PureRevert", ethereum.CallMsg{ {"PureRevert", ethereum.CallMsg{
From: addr, From: addr,