aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/bind/backends/simulated.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-04-27 22:31:12 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-04-27 22:31:12 +0800
commit123aa659e4e2bdb9121f787ee8cd68acc9a4fe4c (patch)
treec0b750618d97a278f73ccfd7bbf380b40f1d3a0f /accounts/abi/bind/backends/simulated.go
parentdb62979514c69574aefdcf8c2ed9099aa0cd1abe (diff)
parentcdcbb2f16014077597e5901c0f328920c904409e (diff)
downloaddexon-123aa659e4e2bdb9121f787ee8cd68acc9a4fe4c.tar
dexon-123aa659e4e2bdb9121f787ee8cd68acc9a4fe4c.tar.gz
dexon-123aa659e4e2bdb9121f787ee8cd68acc9a4fe4c.tar.bz2
dexon-123aa659e4e2bdb9121f787ee8cd68acc9a4fe4c.tar.lz
dexon-123aa659e4e2bdb9121f787ee8cd68acc9a4fe4c.tar.xz
dexon-123aa659e4e2bdb9121f787ee8cd68acc9a4fe4c.tar.zst
dexon-123aa659e4e2bdb9121f787ee8cd68acc9a4fe4c.zip
Merge pull request #2496 from karalabe/abibind-missing-contract-error
accounts/abi/bind, eth: add contract non-existent error
Diffstat (limited to 'accounts/abi/bind/backends/simulated.go')
-rw-r--r--accounts/abi/bind/backends/simulated.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go
index 6cdb9a0cc..4866c4f58 100644
--- a/accounts/abi/bind/backends/simulated.go
+++ b/accounts/abi/bind/backends/simulated.go
@@ -92,6 +92,10 @@ func (b *SimulatedBackend) ContractCall(contract common.Address, data []byte, pe
block = b.blockchain.CurrentBlock()
statedb, _ = b.blockchain.State()
}
+ // If there's no code to interact with, respond with an appropriate error
+ if code := statedb.GetCode(contract); len(code) == 0 {
+ return nil, bind.ErrNoCode
+ }
// Set infinite balance to the a fake caller account
from := statedb.GetOrNewStateObject(common.Address{})
from.SetBalance(common.MaxBig)
@@ -134,7 +138,12 @@ func (b *SimulatedBackend) EstimateGasLimit(sender common.Address, contract *com
block = b.pendingBlock
statedb = b.pendingState.Copy()
)
-
+ // If there's no code to interact with, respond with an appropriate error
+ if contract != nil {
+ if code := statedb.GetCode(*contract); len(code) == 0 {
+ return nil, bind.ErrNoCode
+ }
+ }
// Set infinite balance to the a fake caller account
from := statedb.GetOrNewStateObject(sender)
from.SetBalance(common.MaxBig)