aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/unpack_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-12-30 05:20:02 +0800
committerGitHub <noreply@github.com>2017-12-30 05:20:02 +0800
commitb9731767af634ff90ae9b387bd035d9bc4b128e3 (patch)
treeb9e05770b293a06310948f2f2261f918e8b7064d /accounts/abi/unpack_test.go
parent36a10875c8c1a34aab851e3f65da48ccbb5367ce (diff)
downloadgo-tangerine-b9731767af634ff90ae9b387bd035d9bc4b128e3.tar
go-tangerine-b9731767af634ff90ae9b387bd035d9bc4b128e3.tar.gz
go-tangerine-b9731767af634ff90ae9b387bd035d9bc4b128e3.tar.bz2
go-tangerine-b9731767af634ff90ae9b387bd035d9bc4b128e3.tar.lz
go-tangerine-b9731767af634ff90ae9b387bd035d9bc4b128e3.tar.xz
go-tangerine-b9731767af634ff90ae9b387bd035d9bc4b128e3.tar.zst
go-tangerine-b9731767af634ff90ae9b387bd035d9bc4b128e3.zip
accounts/abi: handle named ouputs prefixed with underscores (#15766)
* accounts/abi: handle named ouputs prefixed with underscores * accounts/abi: handle collinding outputs for struct unpacks * accounts: handle purely underscore output names
Diffstat (limited to 'accounts/abi/unpack_test.go')
-rw-r--r--accounts/abi/unpack_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/accounts/abi/unpack_test.go b/accounts/abi/unpack_test.go
index 391095073..4d7fe638c 100644
--- a/accounts/abi/unpack_test.go
+++ b/accounts/abi/unpack_test.go
@@ -259,6 +259,51 @@ var unpackTests = []unpackTest{
enc: "000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003",
want: [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)},
},
+ // struct outputs
+ {
+ def: `[{"name":"int1","type":"int256"},{"name":"int2","type":"int256"}]`,
+ enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
+ want: struct {
+ Int1 *big.Int
+ Int2 *big.Int
+ }{big.NewInt(1), big.NewInt(2)},
+ },
+ {
+ def: `[{"name":"int","type":"int256"},{"name":"Int","type":"int256"}]`,
+ enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
+ want: struct {
+ Int1 *big.Int
+ Int2 *big.Int
+ }{},
+ err: "abi: multiple outputs mapping to the same struct field 'Int'",
+ },
+ {
+ def: `[{"name":"int","type":"int256"},{"name":"_int","type":"int256"}]`,
+ enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
+ want: struct {
+ Int1 *big.Int
+ Int2 *big.Int
+ }{},
+ err: "abi: multiple outputs mapping to the same struct field 'Int'",
+ },
+ {
+ def: `[{"name":"Int","type":"int256"},{"name":"_int","type":"int256"}]`,
+ enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
+ want: struct {
+ Int1 *big.Int
+ Int2 *big.Int
+ }{},
+ err: "abi: multiple outputs mapping to the same struct field 'Int'",
+ },
+ {
+ def: `[{"name":"Int","type":"int256"},{"name":"_","type":"int256"}]`,
+ enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
+ want: struct {
+ Int1 *big.Int
+ Int2 *big.Int
+ }{},
+ err: "abi: purely underscored output cannot unpack to struct",
+ },
}
func TestUnpack(t *testing.T) {