diff options
author | chriseth <chris@ethereum.org> | 2018-07-11 20:28:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-11 20:28:20 +0800 |
commit | 238dbe1b9904cee916089ab51b81a5368b80dda3 (patch) | |
tree | b1c42459ae4cce29241b4e2a933bd6649e0c3b7c /test/libsolidity | |
parent | 28ac3f0a6c8c532e79aaa3bff1e1a7d8ac7d8cb0 (diff) | |
parent | f7a9c4203e35439de6ff4bdd94c7083c16b73e43 (diff) | |
download | dexon-solidity-238dbe1b9904cee916089ab51b81a5368b80dda3.tar.gz dexon-solidity-238dbe1b9904cee916089ab51b81a5368b80dda3.tar.zst dexon-solidity-238dbe1b9904cee916089ab51b81a5368b80dda3.zip |
Merge pull request #4388 from ethereum/noPackedLiterals
Disallow packed encoding of literals.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 10 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/tight_packing_literals.sol | 2 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/tight_packing_literals_050.sol | 9 |
3 files changed, 6 insertions, 15 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c6c11df5..3cd3b9b7 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -2082,7 +2082,7 @@ BOOST_AUTO_TEST_CASE(packed_keccak256) function a(bytes32 input) public returns (bytes32 hash) { uint24 b = 65536; uint c = 256; - return keccak256(abi.encodePacked(8, input, b, input, c)); + return keccak256(abi.encodePacked(uint8(8), input, b, input, c)); } } )"; @@ -2134,7 +2134,7 @@ BOOST_AUTO_TEST_CASE(packed_sha256) function a(bytes32 input) public returns (bytes32 hash) { uint24 b = 65536; uint c = 256; - return sha256(abi.encodePacked(8, input, b, input, c)); + return sha256(abi.encodePacked(uint8(8), input, b, input, c)); } } )"; @@ -2161,7 +2161,7 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160) function a(bytes32 input) public returns (bytes32 hash) { uint24 b = 65536; uint c = 256; - return ripemd160(abi.encodePacked(8, input, b, input, c)); + return ripemd160(abi.encodePacked(uint8(8), input, b, input, c)); } } )"; @@ -3560,7 +3560,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_numeric_literals) contract c { function foo(uint a, uint16 b) public returns (bytes32 d) { - d = keccak256(abi.encodePacked(a, b, 145)); + d = keccak256(abi.encodePacked(a, b, uint8(145))); } } )"; @@ -3585,7 +3585,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_string_literals) } function bar(uint a, uint16 b) public returns (bytes32 d) { - d = keccak256(abi.encodePacked(a, b, 145, "foo")); + d = keccak256(abi.encodePacked(a, b, uint8(145), "foo")); } } )"; diff --git a/test/libsolidity/syntaxTests/tight_packing_literals.sol b/test/libsolidity/syntaxTests/tight_packing_literals.sol index be8482ff..a136aa77 100644 --- a/test/libsolidity/syntaxTests/tight_packing_literals.sol +++ b/test/libsolidity/syntaxTests/tight_packing_literals.sol @@ -5,4 +5,4 @@ contract C { } // ---- -// Warning: (92-93): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. +// TypeError: (92-93): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol b/test/libsolidity/syntaxTests/tight_packing_literals_050.sol deleted file mode 100644 index 4e6210c6..00000000 --- a/test/libsolidity/syntaxTests/tight_packing_literals_050.sol +++ /dev/null @@ -1,9 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function k() pure public returns (bytes) { - return abi.encodePacked(1); - } -} - -// ---- -// TypeError: (122-123): Cannot perform packed encoding for a literal. Please convert it to an explicit type first. |