Small fixes for proper multitype/multiarg SHA3

This commit is contained in:
Lefteris Karapetsas 2015-02-06 17:25:29 +01:00
parent 0037a7694a
commit 895b5c13f0

View File

@ -933,7 +933,7 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("data()") == encodeArgs(8)); BOOST_CHECK(callContractFunction("data()") == encodeArgs(8));
BOOST_CHECK(callContractFunction("name()") == encodeArgs("Celina")); BOOST_CHECK(callContractFunction("name()") == encodeArgs("Celina"));
BOOST_CHECK(callContractFunction("a_hash()") == encodeArgs(dev::sha3(toBigEndian(u256(123))))); BOOST_CHECK(callContractFunction("a_hash()") == encodeArgs(dev::sha3(bytes({0x7b}))));
BOOST_CHECK(callContractFunction("an_address()") == encodeArgs(toBigEndian(u160(0x1337)))); BOOST_CHECK(callContractFunction("an_address()") == encodeArgs(toBigEndian(u160(0x1337))));
BOOST_CHECK(callContractFunction("super_secret_data()") == bytes()); BOOST_CHECK(callContractFunction("super_secret_data()") == bytes());
} }
@ -2127,8 +2127,8 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_numeric_literals)
BOOST_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12) == encodeArgs( BOOST_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12) == encodeArgs(
dev::sha3( dev::sha3(
toBigEndian(u256(10)) + toBigEndian(u256(10)) +
toBigEndian(u256(12)) + bytes({0x0, 0xc}) +
toBigEndian(u256(145))))); bytes({0x91}))));
} }
BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals) BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals)
@ -2147,14 +2147,13 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals)
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("foo()") == encodeArgs(dev::sha3("foo"))); BOOST_CHECK(callContractFunction("foo()") == encodeArgs(dev::sha3("foo")));
#if 0 // work in progress
BOOST_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12) == encodeArgs( BOOST_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12) == encodeArgs(
dev::sha3( dev::sha3(
toBigEndian(u256(10)) + toBigEndian(u256(10)) +
toBigEndian(u256(12)) + bytes({0x0, 0xc}) +
toBigEndian(u256(145)) + bytes({0x91}) +
asBytes("foo"))))); bytes({0x66, 0x6f, 0x6f}))));
#endif
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()