mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add alias keccak256() for sha3()
This commit is contained in:
parent
e69173f910
commit
34df80c502
@ -1,8 +1,10 @@
|
|||||||
### 0.4.3 (unreleased)
|
### 0.4.3 (unreleased)
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
* Inline assembly: support both `sucide` and `selfdestruct` opcodes
|
* Inline assembly: support both `sucide` and `selfdestruct` opcodes
|
||||||
(note: `suicide` is deprecated)
|
(note: `suicide` is deprecated)
|
||||||
|
* Include `keccak256()` as an alias to `sha3()`
|
||||||
|
|
||||||
### 0.4.2 (2016-09-17)
|
### 0.4.2 (2016-09-17)
|
||||||
|
|
||||||
|
@ -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<FunctionType>(strings{"uint256", "uint256", "uint256"}, strings{"uint256"}, FunctionType::Location::MulMod)),
|
||||||
make_shared<MagicVariableDeclaration>("sha3",
|
make_shared<MagicVariableDeclaration>("sha3",
|
||||||
make_shared<FunctionType>(strings(), strings{"bytes32"}, FunctionType::Location::SHA3, true)),
|
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<MagicVariableDeclaration>("log0",
|
||||||
make_shared<FunctionType>(strings{"bytes32"}, strings{}, FunctionType::Location::Log0)),
|
make_shared<FunctionType>(strings{"bytes32"}, strings{}, FunctionType::Location::Log0)),
|
||||||
make_shared<MagicVariableDeclaration>("log1",
|
make_shared<MagicVariableDeclaration>("log1",
|
||||||
|
@ -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)
|
BOOST_AUTO_TEST_CASE(generic_call)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"**(
|
char const* sourceCode = R"**(
|
||||||
|
Loading…
Reference in New Issue
Block a user