mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
LLL: fix handling of "sha3" expression
When PR #2317 changed the EVM opcode from SHA3 to KECCAK256 it broke the `(sha3 loc len)` expression in LLL. This PR fixes things while allowing existing code using the sha3 expression (such as the ENS registrar) to continue to compile. I.e. both `(keccak256 loc len)` and `(sha3 loc len)` may be used, and the existing related sha3 macros continue to work. Three end-to-end test cases have been added for kekkac256 and sha3.
This commit is contained in:
@@ -291,6 +291,43 @@ BOOST_AUTO_TEST_CASE(zeroarg_macro)
|
||||
BOOST_CHECK(callFallback() == encodeArgs(u256(0x1234)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(keccak256_32bytes)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
(returnlll
|
||||
(seq
|
||||
(mstore 0x00 0x01)
|
||||
(return (keccak256 0x00 0x20))))
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callFallback() == encodeArgs(
|
||||
fromHex("b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6")));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(sha3_two_args)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
(returnlll
|
||||
(seq
|
||||
(mstore 0x00 0x01)
|
||||
(return (sha3 0x00 0x20))))
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callFallback() == encodeArgs(
|
||||
fromHex("b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6")));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(sha3_one_arg)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
(returnlll
|
||||
(return (sha3 0x01)))
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callFallback() == encodeArgs(
|
||||
fromHex("b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6")));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user