|
|
@@ -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
|