diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-06 23:27:41 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-06 23:27:41 +0800 |
commit | 0037a7694af0f93faf9f98b801faf87a513abd10 (patch) | |
tree | 13a07102fe320de2a6a74346ce820565112644d6 | |
parent | 4b43f1b564e6f6cf88441646c56c598403e510dc (diff) | |
download | dexon-solidity-0037a7694af0f93faf9f98b801faf87a513abd10.tar.gz dexon-solidity-0037a7694af0f93faf9f98b801faf87a513abd10.tar.zst dexon-solidity-0037a7694af0f93faf9f98b801faf87a513abd10.zip |
SHA3 of string literals now should work
-rw-r--r-- | SolidityEndToEndTest.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 083f5502..bd473af5 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -2099,7 +2099,6 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments) { char const* sourceCode = R"( contract c { - // function foo(uint a) returns (hash d) function foo(uint a, uint b, uint c) returns (hash d) { d = sha3(a, b, c); @@ -2114,6 +2113,50 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments) toBigEndian(u256(13))))); } +BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_numeric_literals) +{ + char const* sourceCode = R"( + contract c { + function foo(uint a, uint16 b) returns (hash d) + { + d = sha3(a, b, 145); + } + })"; + compileAndRun(sourceCode); + + BOOST_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12) == encodeArgs( + dev::sha3( + toBigEndian(u256(10)) + + toBigEndian(u256(12)) + + toBigEndian(u256(145))))); +} + +BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals) +{ + char const* sourceCode = R"( + contract c { + function foo() returns (hash d) + { + d = sha3("foo"); + } + function bar(uint a, uint16 b) returns (hash d) + { + d = sha3(a, b, 145, "foo"); + } + })"; + compileAndRun(sourceCode); + + BOOST_CHECK(callContractFunction("foo()") == encodeArgs(dev::sha3("foo"))); +#if 0 // work in progress + BOOST_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12) == encodeArgs( + dev::sha3( + toBigEndian(u256(10)) + + toBigEndian(u256(12)) + + toBigEndian(u256(145)) + + asBytes("foo"))))); +#endif +} + BOOST_AUTO_TEST_SUITE_END() } |