aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-03-16 23:06:40 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-03-29 16:57:11 +0800
commit5c8a6aac698f6d084a22c6ec9f282b3f26ddb8bb (patch)
tree16232775c6f6c4b9257f0f1fde8cbbf9054a152c /test/libsolidity/SolidityEndToEndTest.cpp
parentc2ae33f8067c2ed2a70a86f9e29cce06e23af28a (diff)
downloaddexon-solidity-5c8a6aac698f6d084a22c6ec9f282b3f26ddb8bb.tar
dexon-solidity-5c8a6aac698f6d084a22c6ec9f282b3f26ddb8bb.tar.gz
dexon-solidity-5c8a6aac698f6d084a22c6ec9f282b3f26ddb8bb.tar.bz2
dexon-solidity-5c8a6aac698f6d084a22c6ec9f282b3f26ddb8bb.tar.lz
dexon-solidity-5c8a6aac698f6d084a22c6ec9f282b3f26ddb8bb.tar.xz
dexon-solidity-5c8a6aac698f6d084a22c6ec9f282b3f26ddb8bb.tar.zst
dexon-solidity-5c8a6aac698f6d084a22c6ec9f282b3f26ddb8bb.zip
Prevent encoding of weird types and support packed encoding of external function types.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index a866e46c..f5813aed 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2077,6 +2077,31 @@ BOOST_AUTO_TEST_CASE(packed_keccak256)
testContractAgainstCpp("a(bytes32)", f, u256(-1));
}
+BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types)
+{
+ char const* sourceCode = R"(
+ contract test {
+ uint120[3] x;
+ function f() view returns (bytes32 hash1, bytes32 hash2, bytes32 hash3) {
+ uint120[] memory y = new uint120[](3);
+ x[0] = y[0] = uint120(-2);
+ x[1] = y[1] = uint120(-3);
+ x[2] = y[2] = uint120(-4);
+ hash1 = keccak256(x);
+ hash2 = keccak256(y);
+ hash3 = keccak256(this.f);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ // Strangely, arrays are encoded with intra-element padding.
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(
+ dev::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))),
+ dev::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))),
+ dev::keccak256(fromHex(m_contractAddress.hex() + "26121ff0"))
+ ));
+}
+
BOOST_AUTO_TEST_CASE(packed_sha256)
{
char const* sourceCode = R"(