diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-10-06 19:08:25 +0800 |
---|---|---|
committer | Yoichi Hirai <i@yoichihirai.com> | 2016-10-06 22:34:41 +0800 |
commit | 34df80c502c5e20fda6db1d2152beccdfb3342cc (patch) | |
tree | 1952c30abb077da548d64a80d121d2ecf1287f2b | |
parent | e69173f910e8454a7dc13f79598e7e9fd5c147c9 (diff) | |
download | dexon-solidity-34df80c502c5e20fda6db1d2152beccdfb3342cc.tar dexon-solidity-34df80c502c5e20fda6db1d2152beccdfb3342cc.tar.gz dexon-solidity-34df80c502c5e20fda6db1d2152beccdfb3342cc.tar.bz2 dexon-solidity-34df80c502c5e20fda6db1d2152beccdfb3342cc.tar.lz dexon-solidity-34df80c502c5e20fda6db1d2152beccdfb3342cc.tar.xz dexon-solidity-34df80c502c5e20fda6db1d2152beccdfb3342cc.tar.zst dexon-solidity-34df80c502c5e20fda6db1d2152beccdfb3342cc.zip |
Add alias keccak256() for sha3()
-rw-r--r-- | Changelog.md | 2 | ||||
-rw-r--r-- | libsolidity/analysis/GlobalContext.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 18 |
3 files changed, 22 insertions, 0 deletions
diff --git a/Changelog.md b/Changelog.md index 8e639a2d..0d77fbc9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,8 +1,10 @@ ### 0.4.3 (unreleased) Features: + * Inline assembly: support both `sucide` and `selfdestruct` opcodes (note: `suicide` is deprecated) + * Include `keccak256()` as an alias to `sha3()` ### 0.4.2 (2016-09-17) diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp index a7ffcfad..d075949e 100644 --- a/libsolidity/analysis/GlobalContext.cpp +++ b/libsolidity/analysis/GlobalContext.cpp @@ -48,6 +48,8 @@ m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{make_shared< make_shared<FunctionType>(strings{"uint256", "uint256", "uint256"}, strings{"uint256"}, FunctionType::Location::MulMod)), make_shared<MagicVariableDeclaration>("sha3", make_shared<FunctionType>(strings(), strings{"bytes32"}, FunctionType::Location::SHA3, true)), + make_shared<MagicVariableDeclaration>("keccak256", + make_shared<FunctionType>(strings(), strings{"bytes32"}, FunctionType::Location::SHA3, true)), make_shared<MagicVariableDeclaration>("log0", make_shared<FunctionType>(strings{"bytes32"}, strings{}, FunctionType::Location::Log0)), make_shared<MagicVariableDeclaration>("log1", diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 23bd2abc..9485c5fa 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -2872,6 +2872,24 @@ BOOST_AUTO_TEST_CASE(iterated_sha3_with_bytes) )); } +BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments) +{ + char const* sourceCode = R"( + contract c { + function foo(uint a, uint b, uint c) returns (bytes32 d) + { + d = keccak256(a, b, c); + } + })"; + compileAndRun(sourceCode); + + BOOST_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10, 12, 13) == encodeArgs( + dev::sha3( + toBigEndian(u256(10)) + + toBigEndian(u256(12)) + + toBigEndian(u256(13))))); +} + BOOST_AUTO_TEST_CASE(generic_call) { char const* sourceCode = R"**( |