diff options
author | chriseth <chris@ethereum.org> | 2018-04-13 02:55:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-13 02:55:03 +0800 |
commit | 44416d1ac65b2cfae4bb15d39bc84b1a78211baa (patch) | |
tree | 7b8ee302e1c4f0604f29d2fe21a2d0393cc60d11 /test/libsolidity/syntaxTests/specialFunctions | |
parent | 7453ff0f3a94ce4ddce55cdbb77146dd75a01e1c (diff) | |
parent | 75b88286667690ffb4a5e079665ed8b70bcaeb87 (diff) | |
download | dexon-solidity-44416d1ac65b2cfae4bb15d39bc84b1a78211baa.tar dexon-solidity-44416d1ac65b2cfae4bb15d39bc84b1a78211baa.tar.gz dexon-solidity-44416d1ac65b2cfae4bb15d39bc84b1a78211baa.tar.bz2 dexon-solidity-44416d1ac65b2cfae4bb15d39bc84b1a78211baa.tar.lz dexon-solidity-44416d1ac65b2cfae4bb15d39bc84b1a78211baa.tar.xz dexon-solidity-44416d1ac65b2cfae4bb15d39bc84b1a78211baa.tar.zst dexon-solidity-44416d1ac65b2cfae4bb15d39bc84b1a78211baa.zip |
Merge pull request #2980 from ethereum/abi-api
Add abi.encode and abi.encodePacked
Diffstat (limited to 'test/libsolidity/syntaxTests/specialFunctions')
4 files changed, 55 insertions, 5 deletions
diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs.sol new file mode 100644 index 00000000..d9eebee4 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs.sol @@ -0,0 +1,17 @@ +contract C { + struct S { uint x; } + S s; + struct T { uint y; } + T t; + function f() public view { + abi.encode(s, t); + } + function g() public view { + abi.encodePacked(s, t); + } +} +// ---- +// TypeError: (131-132): This type cannot be encoded. +// TypeError: (134-135): This type cannot be encoded. +// TypeError: (200-201): This type cannot be encoded. +// TypeError: (203-204): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs_abiv2.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs_abiv2.sol new file mode 100644 index 00000000..d6cf60e4 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs_abiv2.sol @@ -0,0 +1,18 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S { uint x; } + S s; + struct T { uint y; } + T t; + function f() public view { + abi.encode(s, t); + } + function g() public view { + abi.encodePacked(s, t); + } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (235-236): This type cannot be encoded. +// TypeError: (238-239): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol index cc354819..fa910260 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol @@ -1,14 +1,13 @@ contract C { struct S { uint x; } S s; - struct T { } + struct T { uint y; } T t; - function f() public pure { + function f() public view { bytes32 a = sha256(s, t); a; } } // ---- -// Warning: (51-63): Defining empty structs is deprecated. -// TypeError: (131-132): This type cannot be encoded. -// TypeError: (134-135): This type cannot be encoded. +// TypeError: (139-140): This type cannot be encoded. +// TypeError: (142-143): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol new file mode 100644 index 00000000..1187ce4a --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol @@ -0,0 +1,16 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S { uint x; } + S s; + struct T { uint y; } + T t; + function f() public view { + bytes32 a = sha256(s, t); + a; + } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (174-175): This type cannot be encoded. +// TypeError: (177-178): This type cannot be encoded. |