aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-10-11 16:45:24 +0800
committerchriseth <chris@ethereum.org>2017-10-18 05:17:36 +0800
commita3db1fc1976e1b2e67aedecb771c288b6dca6b1c (patch)
treeb1d6eb63c4ac64acdee5374488e2639ffcbbc8b3 /test/libsolidity/SolidityEndToEndTest.cpp
parenta17996cdadc9e6e941ee7c85681ad3e30f9cf998 (diff)
downloaddexon-solidity-a3db1fc1976e1b2e67aedecb771c288b6dca6b1c.tar.gz
dexon-solidity-a3db1fc1976e1b2e67aedecb771c288b6dca6b1c.tar.zst
dexon-solidity-a3db1fc1976e1b2e67aedecb771c288b6dca6b1c.zip
Do not accept truncated function selectors.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 648c13cb..9a837113 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2899,6 +2899,25 @@ BOOST_AUTO_TEST_CASE(default_fallback_throws)
ABI_CHECK(callContractFunction("f()"), encodeArgs(0));
}
+BOOST_AUTO_TEST_CASE(short_data_calls_fallback)
+{
+ char const* sourceCode = R"(
+ contract A {
+ uint public x;
+ // Signature is d88e0b00
+ function fow() { x = 3; }
+ function () { x = 2; }
+ }
+ )";
+ compileAndRun(sourceCode);
+ // should call fallback
+ sendMessage(asBytes("\xd8\x8e\x0b"), false, 0);
+ ABI_CHECK(callContractFunction("x()"), encodeArgs(2));
+ // should call function
+ sendMessage(asBytes(string("\xd8\x8e\x0b") + string(1, 0)), false, 0);
+ ABI_CHECK(callContractFunction("x()"), encodeArgs(3));
+}
+
BOOST_AUTO_TEST_CASE(event)
{
char const* sourceCode = R"(