From 53508c5d462792d43339b2976d1086cf26a0b93d Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Thu, 4 Jun 2020 19:10:24 +0800 Subject: [PATCH] accounts/abi/bind/backends: fix EstimateGas --- accounts/abi/bind/backends/simulated.go | 8 +------- accounts/abi/bind/backends/simulated_test.go | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 5d621a24f371..2cf7a3810f64 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -509,13 +509,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs if failed { if result != nil && result.Err != vm.ErrOutOfGas { if len(result.Revert()) > 0 { - reason, err := abi.UnpackRevert(result.Revert()) - if err == nil { - return 0, &revertError{ - error: errors.New("execution reverted"), - errData: reason, - } - } + return 0, newRevertError(result) } return 0, result.Err } diff --git a/accounts/abi/bind/backends/simulated_test.go b/accounts/abi/bind/backends/simulated_test.go index 61ee6b8bae03..6dfd071b86d8 100644 --- a/accounts/abi/bind/backends/simulated_test.go +++ b/accounts/abi/bind/backends/simulated_test.go @@ -415,7 +415,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) { GasPrice: big.NewInt(0), Value: nil, Data: common.Hex2Bytes("d8b98391"), - }, 0, errors.New("execution reverted"), "revert reason"}, + }, 0, errors.New("execution reverted: revert reason"), "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d72657665727420726561736f6e00000000000000000000000000000000000000"}, {"PureRevert", ethereum.CallMsg{ From: addr,