aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-08-08 01:40:19 +0800
committerchriseth <c@ethdev.com>2016-08-16 20:53:01 +0800
commit034d436933806c204b84b0500e2116938cb6a030 (patch)
tree03c6d183fc5358a56a271df9f2587f3918929cba /test/libsolidity
parente3e4d84f3353eaaaadae7c1c6eac9e890188d0f8 (diff)
downloaddexon-solidity-034d436933806c204b84b0500e2116938cb6a030.tar.gz
dexon-solidity-034d436933806c204b84b0500e2116938cb6a030.tar.zst
dexon-solidity-034d436933806c204b84b0500e2116938cb6a030.zip
Make ecrecover throw for malformed input.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 1b7c5ea4..338a47da 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -6853,6 +6853,24 @@ 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 throw for malformed input
+ // (v should be 27 or 28, not 1)
+ // This is quite hard to test because the precompiled does NOT throw, instead it just
+ // does not write to its output area, we have to check that and currently do it
+ // by checking whether ecrecover "returns" zero.
+ 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());
+}
+
BOOST_AUTO_TEST_SUITE_END()
}