accounts/abi: Improve test coverage

This commit is contained in:
Ricardo Domingos 2018-02-08 21:57:48 +01:00
parent 3ca3fffdf0
commit 0bb14ea129
2 changed files with 20 additions and 0 deletions

View file

@ -252,6 +252,9 @@ func TestTypeCheck(t *testing.T) {
{"bytes20", common.Address{}, ""}, {"bytes20", common.Address{}, ""},
{"address", [20]byte{}, ""}, {"address", [20]byte{}, ""},
{"address", common.Address{}, ""}, {"address", common.Address{}, ""},
{"bytes32[]]", "", "invalid arg type in abi"},
{"invalidType", "", "unsupported arg type: invalidType"},
{"invalidSlice[]", "", "unsupported arg type: invalidSlice"},
} { } {
typ, err := NewType(test.typ) typ, err := NewType(test.typ)
if err != nil && len(test.err) == 0 { if err != nil && len(test.err) == 0 {

View file

@ -56,6 +56,23 @@ var unpackTests = []unpackTest{
enc: "0000000000000000000000000000000000000000000000000000000000000001", enc: "0000000000000000000000000000000000000000000000000000000000000001",
want: true, 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"}]`, def: `[{"type": "uint32"}]`,
enc: "0000000000000000000000000000000000000000000000000000000000000001", enc: "0000000000000000000000000000000000000000000000000000000000000001",