aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-05-16 16:22:03 +0800
committerGitHub <noreply@github.com>2018-05-16 16:22:03 +0800
commit23adea88fdc7eafc5b67b759b4c2418bd6b93aa6 (patch)
treea648418931273de87ada16443d3c18b739c76d76 /test/libsolidity/SolidityEndToEndTest.cpp
parent54839fdffbc32f1f918790b1e09143a410bd1c80 (diff)
parent03f60410c9ad57c90a327ffb6e8b6b722ec9c995 (diff)
downloaddexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.tar
dexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.tar.gz
dexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.tar.bz2
dexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.tar.lz
dexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.tar.xz
dexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.tar.zst
dexon-solidity-23adea88fdc7eafc5b67b759b4c2418bd6b93aa6.zip
Merge pull request #4138 from ethereum/warnVarArgs
Warn when hash functions are used with var arguments
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 42f69099..1efcfde0 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -3959,6 +3959,51 @@ BOOST_AUTO_TEST_CASE(call_forward_bytes)
ABI_CHECK(callContractFunction("val()"), encodeArgs(0x80));
}
+BOOST_AUTO_TEST_CASE(call_forward_bytes_length)
+{
+ char const* sourceCode = R"(
+ contract receiver {
+ uint public calledLength;
+ function() { calledLength = msg.data.length; }
+ }
+ contract sender {
+ receiver rec;
+ constructor() { rec = new receiver(); }
+ function viaCalldata() returns (uint) {
+ require(rec.call(msg.data));
+ return rec.calledLength();
+ }
+ function viaMemory() returns (uint) {
+ bytes memory x = msg.data;
+ require(rec.call(x));
+ return rec.calledLength();
+ }
+ bytes s;
+ function viaStorage() returns (uint) {
+ s = msg.data;
+ require(rec.call(s));
+ return rec.calledLength();
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "sender");
+
+ // No additional data, just function selector
+ ABI_CHECK(callContractFunction("viaCalldata()"), encodeArgs(4));
+ ABI_CHECK(callContractFunction("viaMemory()"), encodeArgs(0x20));
+ // Should be this with 0.5.0: encodeArgs(4));
+ ABI_CHECK(callContractFunction("viaStorage()"), encodeArgs(0x20));
+ // Should be this with 0.5.0: encodeArgs(4));
+
+ // Some additional unpadded data
+ bytes unpadded = asBytes(string("abc"));
+ ABI_CHECK(callContractFunctionNoEncoding("viaCalldata()", unpadded), encodeArgs(7));
+ ABI_CHECK(callContractFunctionNoEncoding("viaMemory()", unpadded), encodeArgs(0x20));
+ // Should be this with 0.5.0: encodeArgs(7));
+ ABI_CHECK(callContractFunctionNoEncoding("viaStorage()", unpadded), encodeArgs(0x20));
+ // Should be this with 0.5.0: encodeArgs(7));
+}
+
BOOST_AUTO_TEST_CASE(copying_bytes_multiassign)
{
char const* sourceCode = R"(