aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/bind/bind_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-04-27 21:29:13 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-04-27 22:15:23 +0800
commitcdcbb2f16014077597e5901c0f328920c904409e (patch)
treec0b750618d97a278f73ccfd7bbf380b40f1d3a0f /accounts/abi/bind/bind_test.go
parentdb62979514c69574aefdcf8c2ed9099aa0cd1abe (diff)
downloadgo-tangerine-cdcbb2f16014077597e5901c0f328920c904409e.tar
go-tangerine-cdcbb2f16014077597e5901c0f328920c904409e.tar.gz
go-tangerine-cdcbb2f16014077597e5901c0f328920c904409e.tar.bz2
go-tangerine-cdcbb2f16014077597e5901c0f328920c904409e.tar.lz
go-tangerine-cdcbb2f16014077597e5901c0f328920c904409e.tar.xz
go-tangerine-cdcbb2f16014077597e5901c0f328920c904409e.tar.zst
go-tangerine-cdcbb2f16014077597e5901c0f328920c904409e.zip
accounts/abi/bind, eth: add contract non-existent error
Diffstat (limited to 'accounts/abi/bind/bind_test.go')
-rw-r--r--accounts/abi/bind/bind_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go
index 5c36bc48f..f9cc8aba4 100644
--- a/accounts/abi/bind/bind_test.go
+++ b/accounts/abi/bind/bind_test.go
@@ -303,6 +303,34 @@ var bindTests = []struct {
}
`,
},
+ // Tests that non-existent contracts are reported as such (though only simulator test)
+ {
+ `NonExistent`,
+ `
+ contract NonExistent {
+ function String() constant returns(string) {
+ return "I don't exist";
+ }
+ }
+ `,
+ `6060604052609f8060106000396000f3606060405260e060020a6000350463f97a60058114601a575b005b600060605260c0604052600d60809081527f4920646f6e27742065786973740000000000000000000000000000000000000060a052602060c0908152600d60e081905281906101009060a09080838184600060046012f15050815172ffffffffffffffffffffffffffffffffffffff1916909152505060405161012081900392509050f3`,
+ `[{"constant":true,"inputs":[],"name":"String","outputs":[{"name":"","type":"string"}],"type":"function"}]`,
+ `
+ // Create a simulator and wrap a non-deployed contract
+ sim := backends.NewSimulatedBackend()
+
+ nonexistent, err := NewNonExistent(common.Address{}, sim)
+ if err != nil {
+ t.Fatalf("Failed to access non-existent contract: %v", err)
+ }
+ // Ensure that contract calls fail with the appropriate error
+ if res, err := nonexistent.String(nil); err == nil {
+ t.Fatalf("Call succeeded on non-existent contract: %v", res)
+ } else if (err != bind.ErrNoCode) {
+ t.Fatalf("Error mismatch: have %v, want %v", err, bind.ErrNoCode)
+ }
+ `,
+ },
}
// Tests that packages generated by the binder can be successfully compiled and