aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-08-17 17:05:20 +0800
committerGitHub <noreply@github.com>2016-08-17 17:05:20 +0800
commitd5505e21ebfef2cd88545cb17f49d281910114e0 (patch)
treeaf0dfbaa1fab0dac59c63370710755acd59c7b2c /test
parenta63f94e0423fb51e10e7d106a50e7dce14ace104 (diff)
parentd731225d02c9b8d6dc9f2ba632923b765d0e111d (diff)
downloaddexon-solidity-d5505e21ebfef2cd88545cb17f49d281910114e0.tar
dexon-solidity-d5505e21ebfef2cd88545cb17f49d281910114e0.tar.gz
dexon-solidity-d5505e21ebfef2cd88545cb17f49d281910114e0.tar.bz2
dexon-solidity-d5505e21ebfef2cd88545cb17f49d281910114e0.tar.lz
dexon-solidity-d5505e21ebfef2cd88545cb17f49d281910114e0.tar.xz
dexon-solidity-d5505e21ebfef2cd88545cb17f49d281910114e0.tar.zst
dexon-solidity-d5505e21ebfef2cd88545cb17f49d281910114e0.zip
Merge pull request #838 from chriseth/ecrecover
Make ecrecover return zero for malformed input.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 46756493..3920d948 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -6880,6 +6880,22 @@ BOOST_AUTO_TEST_CASE(create_dynamic_array_with_zero_length)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(7)));
}
+BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input)
+{
+ // ecrecover should return zero for malformed input
+ // (v should be 27 or 28, not 1)
+ // Note that the precompile does not return zero but returns nothing.
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (address) {
+ return ecrecover(bytes32(uint(-1)), 1, 2, 3);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0)));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}