aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-05-11 20:43:40 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-05-30 19:33:04 +0800
commitff33297786c3a83092c4c39ff9b12bedd2e12801 (patch)
tree6d1d90cdb0834f26a7cf044c7a046201257f0fda
parent9e1c509cf560096b620c3ba627277e622cf8f261 (diff)
downloaddexon-solidity-ff33297786c3a83092c4c39ff9b12bedd2e12801.tar
dexon-solidity-ff33297786c3a83092c4c39ff9b12bedd2e12801.tar.gz
dexon-solidity-ff33297786c3a83092c4c39ff9b12bedd2e12801.tar.bz2
dexon-solidity-ff33297786c3a83092c4c39ff9b12bedd2e12801.tar.lz
dexon-solidity-ff33297786c3a83092c4c39ff9b12bedd2e12801.tar.xz
dexon-solidity-ff33297786c3a83092c4c39ff9b12bedd2e12801.tar.zst
dexon-solidity-ff33297786c3a83092c4c39ff9b12bedd2e12801.zip
Add test for sha3() == keccak256()
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 4c385990..3707a65c 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -1883,6 +1883,23 @@ BOOST_AUTO_TEST_CASE(keccak256)
testContractAgainstCpp("a(bytes32)", f, u256(-1));
}
+BOOST_AUTO_TEST_CASE(sha3)
+{
+ char const* sourceCode = R"(
+ contract test {
+ // to confuse the optimiser
+ function b(bytes32 input) returns (bytes32) {
+ return sha3(input);
+ }
+ function a(bytes32 input) returns (bool) {
+ return keccak256(input) == b(input);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ BOOST_REQUIRE(callContractFunction("a(bytes32)", u256(42)) == encodeArgs(true));
+}
+
BOOST_AUTO_TEST_CASE(sha256)
{
char const* sourceCode = R"(