aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2017-10-18 17:22:21 +0800
committerGitHub <noreply@github.com>2017-10-18 17:22:21 +0800
commit4a9a986d8cf2e457ab1b36e20bcbefb714292a37 (patch)
tree82b6eb1132ecbf8c243ac2d796e891c7de8c53e3 /test/libsolidity/SolidityEndToEndTest.cpp
parenta17996cdadc9e6e941ee7c85681ad3e30f9cf998 (diff)
parent7849b920cf3ba6502f8a45e0c35be6393392cc00 (diff)
downloaddexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.gz
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.bz2
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.lz
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.xz
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.zst
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.zip
Merge pull request #3065 from ethereum/reject_truncated_selectors
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"(