From 67a9c805f64656fdddc7df81f45a50750fa2716b Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Wed, 8 Apr 2020 12:41:15 +0200 Subject: [PATCH] accounts/abi: test invalid abi --- accounts/abi/abi_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index a07ba0dea9..21bf2397c0 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -200,6 +200,19 @@ func TestReader(t *testing.T) { } } +func TestInvalidABI(t *testing.T) { + json := `[{ "type" : "function", "name" : "", "constant" : fals }]` + _, err := JSON(strings.NewReader(json)) + if err == nil { + t.Fatal("invalid json should produce error") + } + json2 := `[{ "type" : "function", "name" : "send", "constant" : false, "inputs" : [ { "name" : "amount", "typ" : "uint256" } ] }]` + _, err = JSON(strings.NewReader(json2)) + if err == nil { + t.Fatal("invalid json should produce error") + } +} + // TestConstructor tests a constructor function. // The test is based on the following contract: // contract TestConstructor {