diff options
author | RJ <rj@erisindustries.com> | 2017-01-05 18:46:44 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-01-05 18:46:44 +0800 |
commit | 2126d8148806b6d8597d6a1c761080e9dc98d745 (patch) | |
tree | 82f83bff1c99701b1664120ef269d2ec9aae16d9 /accounts/abi/abi_test.go | |
parent | 06b381d1c9dd8e47d7862c0846352a0023e53ed0 (diff) | |
download | dexon-2126d8148806b6d8597d6a1c761080e9dc98d745.tar dexon-2126d8148806b6d8597d6a1c761080e9dc98d745.tar.gz dexon-2126d8148806b6d8597d6a1c761080e9dc98d745.tar.bz2 dexon-2126d8148806b6d8597d6a1c761080e9dc98d745.tar.lz dexon-2126d8148806b6d8597d6a1c761080e9dc98d745.tar.xz dexon-2126d8148806b6d8597d6a1c761080e9dc98d745.tar.zst dexon-2126d8148806b6d8597d6a1c761080e9dc98d745.zip |
accounts/abi: add support for function types (#3405)
Diffstat (limited to 'accounts/abi/abi_test.go')
-rw-r--r-- | accounts/abi/abi_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index 99c46df0d..b1bfcb012 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -81,6 +81,7 @@ func TestTypeCheck(t *testing.T) { {"bytes", common.Hash{1}, ""}, {"string", "hello world", ""}, {"bytes32[]", [][32]byte{[32]byte{}}, ""}, + {"function", [24]byte{}, ""}, } { typ, err := NewType(test.typ) if err != nil { @@ -197,6 +198,13 @@ func TestSimpleMethodUnpack(t *testing.T) { "interface", "", }, + { + `[ { "type": "function" } ]`, + pad([]byte{1}, 32, false), + [24]byte{1}, + "function", + "", + }, } { abiDefinition := fmt.Sprintf(`[{ "name" : "method", "outputs": %s}]`, test.def) abi, err := JSON(strings.NewReader(abiDefinition)) @@ -255,6 +263,10 @@ func TestSimpleMethodUnpack(t *testing.T) { var v common.Hash err = abi.Unpack(&v, "method", test.marshalledOutput) outvar = v + case "function": + var v [24]byte + err = abi.Unpack(&v, "method", test.marshalledOutput) + outvar = v case "interface": err = abi.Unpack(&outvar, "method", test.marshalledOutput) default: @@ -333,6 +345,7 @@ func TestPack(t *testing.T) { {"uint256[]", []*big.Int{big.NewInt(1), big.NewInt(2)}, formatSliceOutput([]byte{1}, []byte{2})}, {"address[]", []common.Address{common.Address{1}, common.Address{2}}, formatSliceOutput(pad([]byte{1}, 20, false), pad([]byte{2}, 20, false))}, {"bytes32[]", []common.Hash{common.Hash{1}, common.Hash{2}}, formatSliceOutput(pad([]byte{1}, 32, false), pad([]byte{2}, 32, false))}, + {"function", [24]byte{1}, pad([]byte{1}, 32, false)}, } { typ, err := NewType(test.typ) if err != nil { |