From 0bb14ea12900ff13d8162afa51d764d1c97ab049 Mon Sep 17 00:00:00 2001 From: Ricardo Domingos Date: Thu, 8 Feb 2018 21:57:48 +0100 Subject: [PATCH] accounts/abi: Improve test coverage --- accounts/abi/type_test.go | 3 +++ accounts/abi/unpack_test.go | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/accounts/abi/type_test.go b/accounts/abi/type_test.go index e55af12939..7c6fcf7265 100644 --- a/accounts/abi/type_test.go +++ b/accounts/abi/type_test.go @@ -252,6 +252,9 @@ func TestTypeCheck(t *testing.T) { {"bytes20", common.Address{}, ""}, {"address", [20]byte{}, ""}, {"address", common.Address{}, ""}, + {"bytes32[]]", "", "invalid arg type in abi"}, + {"invalidType", "", "unsupported arg type: invalidType"}, + {"invalidSlice[]", "", "unsupported arg type: invalidSlice"}, } { typ, err := NewType(test.typ) if err != nil && len(test.err) == 0 { diff --git a/accounts/abi/unpack_test.go b/accounts/abi/unpack_test.go index 742211244b..2308fab8d5 100644 --- a/accounts/abi/unpack_test.go +++ b/accounts/abi/unpack_test.go @@ -56,6 +56,23 @@ var unpackTests = []unpackTest{ enc: "0000000000000000000000000000000000000000000000000000000000000001", want: true, }, + { + def: `[{ "type": "bool" }]`, + enc: "0000000000000000000000000000000000000000000000000000000000000000", + want: false, + }, + { + def: `[{ "type": "bool" }]`, + enc: "0000000000000000000000000000000000000000000000000001000000000001", + want: false, + err: "abi: improperly encoded boolean value", + }, + { + def: `[{ "type": "bool" }]`, + enc: "0000000000000000000000000000000000000000000000000000000000000003", + want: false, + err: "abi: improperly encoded boolean value", + }, { def: `[{"type": "uint32"}]`, enc: "0000000000000000000000000000000000000000000000000000000000000001",