aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-01-18 21:16:44 +0800
committerchriseth <c@ethdev.com>2016-01-18 21:16:44 +0800
commit02340e84647171872e267a0a1635926a3243da16 (patch)
tree469ea245eaf435762e101c314901378553892fbf /test
parent0099513cd430d82a62a7bff6737aef7efa829ee2 (diff)
parenta88835bbce89da14e89591c58c2a74bdaedb2c19 (diff)
downloaddexon-solidity-02340e84647171872e267a0a1635926a3243da16.tar.gz
dexon-solidity-02340e84647171872e267a0a1635926a3243da16.tar.zst
dexon-solidity-02340e84647171872e267a0a1635926a3243da16.zip
Merge pull request #358 from chriseth/fix_storage
Test for incorrect storage access.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 732f599f..2f1eb04e 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -369,6 +369,27 @@ BOOST_AUTO_TEST_CASE(successor_not_found_bug)
compileBothVersions(sourceCode);
}
+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
+ // take the max of the min sequence numbers when merging the states.
+ char const* sourceCode = R"(
+ contract C
+ {
+ mapping(uint => uint) data;
+ function f() returns (uint)
+ {
+ if(data[now] == 0)
+ data[uint(-7)] = 5;
+ return data[now];
+ }
+ }
+ )";
+ compileBothVersions(sourceCode);
+ compareVersions("f()");
+}
+
BOOST_AUTO_TEST_CASE(cse_intermediate_swap)
{
eth::KnownState state;