aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityOptimizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/SolidityOptimizer.cpp')
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index bbd09ce5..bdcdacff 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -322,18 +322,18 @@ BOOST_AUTO_TEST_CASE(storage_write_in_loops)
// Information in joining branches is not retained anymore.
BOOST_AUTO_TEST_CASE(retain_information_in_branches)
{
- // This tests that the optimizer knows that we already have "z == sha3(y)" inside both branches.
+ // This tests that the optimizer knows that we already have "z == keccak256(y)" inside both branches.
char const* sourceCode = R"(
contract c {
bytes32 d;
uint a;
function f(uint x, bytes32 y) returns (uint r_a, bytes32 r_d) {
- bytes32 z = sha3(y);
+ bytes32 z = keccak256(y);
if (x > 8) {
- z = sha3(y);
+ z = keccak256(y);
a = x;
} else {
- z = sha3(y);
+ z = keccak256(y);
a = x;
}
r_a = a;
@@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(retain_information_in_branches)
BOOST_AUTO_TEST_CASE(store_tags_as_unions)
{
- // This calls the same function from two sources and both calls have a certain sha3 on
+ // This calls the same function from two sources and both calls have a certain Keccak-256 on
// the stack at the same position.
// Without storing tags as unions, the return from the shared function would not know where to
// jump and thus all jumpdests are forced to clear their state and we do not know about the
@@ -370,19 +370,19 @@ BOOST_AUTO_TEST_CASE(store_tags_as_unions)
contract test {
bytes32 data;
function f(uint x, bytes32 y) external returns (uint r_a, bytes32 r_d) {
- r_d = sha3(y);
+ r_d = keccak256(y);
shared(y);
- r_d = sha3(y);
+ r_d = keccak256(y);
r_a = 5;
}
function g(uint x, bytes32 y) external returns (uint r_a, bytes32 r_d) {
- r_d = sha3(y);
+ r_d = keccak256(y);
shared(y);
- r_d = bytes32(uint(sha3(y)) + 2);
+ r_d = bytes32(uint(keccak256(y)) + 2);
r_a = 7;
}
function shared(bytes32 y) internal {
- data = sha3(y);
+ data = keccak256(y);
}
}
)";
@@ -401,8 +401,8 @@ BOOST_AUTO_TEST_CASE(store_tags_as_unions)
BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug)
{
- // This bug appeared because a sha3 operation with too low sequence number was used,
- // resulting in memory not being rewritten before the sha3. The fix was to
+ // This bug appeared because a Keccak-256 operation with too low sequence number was used,
+ // resulting in memory not being rewritten before the Keccak-256. The fix was to
// take the max of the min sequence numbers when merging the states.
char const* sourceCode = R"(
contract C
@@ -821,7 +821,7 @@ BOOST_AUTO_TEST_CASE(cse_jumpi_jump)
});
}
-BOOST_AUTO_TEST_CASE(cse_empty_sha3)
+BOOST_AUTO_TEST_CASE(cse_empty_keccak256)
{
AssemblyItems input{
u256(0),
@@ -833,7 +833,7 @@ BOOST_AUTO_TEST_CASE(cse_empty_sha3)
});
}
-BOOST_AUTO_TEST_CASE(cse_partial_sha3)
+BOOST_AUTO_TEST_CASE(cse_partial_keccak256)
{
AssemblyItems input{
u256(0xabcd) << (256 - 16),
@@ -851,9 +851,9 @@ BOOST_AUTO_TEST_CASE(cse_partial_sha3)
});
}
-BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_location)
+BOOST_AUTO_TEST_CASE(cse_keccak256_twice_same_location)
{
- // sha3 twice from same dynamic location
+ // Keccak-256 twice from same dynamic location
AssemblyItems input{
Instruction::DUP2,
Instruction::DUP1,
@@ -876,9 +876,9 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_location)
});
}
-BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content)
+BOOST_AUTO_TEST_CASE(cse_keccak256_twice_same_content)
{
- // sha3 twice from different dynamic location but with same content
+ // Keccak-256 twice from different dynamic location but with same content
AssemblyItems input{
Instruction::DUP1,
u256(0x80),
@@ -909,10 +909,10 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content)
});
}
-BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_dynamic_store_in_between)
+BOOST_AUTO_TEST_CASE(cse_keccak256_twice_same_content_dynamic_store_in_between)
{
- // sha3 twice from different dynamic location but with same content,
- // dynamic mstore in between, which forces us to re-calculate the sha3
+ // Keccak-256 twice from different dynamic location but with same content,
+ // dynamic mstore in between, which forces us to re-calculate the hash
AssemblyItems input{
u256(0x80),
Instruction::DUP2,
@@ -937,10 +937,10 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_dynamic_store_in_between)
checkCSE(input, input);
}
-BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_noninterfering_store_in_between)
+BOOST_AUTO_TEST_CASE(cse_keccak256_twice_same_content_noninterfering_store_in_between)
{
- // sha3 twice from different dynamic location but with same content,
- // dynamic mstore in between, but does not force us to re-calculate the sha3
+ // Keccak-256 twice from different dynamic location but with same content,
+ // dynamic mstore in between, but does not force us to re-calculate the hash
AssemblyItems input{
u256(0x80),
Instruction::DUP2,
@@ -1296,7 +1296,7 @@ BOOST_AUTO_TEST_CASE(constant_optimization_early_exit)
// Store and hash
assembly {
mstore(32, x)
- ret := sha3(0, 40)
+ ret := keccak256(0, 40)
}
}
}