diff options
author | chriseth <c@ethdev.com> | 2016-01-15 23:23:49 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-01-16 00:02:37 +0800 |
commit | a88835bbce89da14e89591c58c2a74bdaedb2c19 (patch) | |
tree | 2e851848ed83048196c4472f941c605f147fc601 /test | |
parent | d2f18c73f75ad5983550fe8a985824d0fda0b640 (diff) | |
download | dexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.tar dexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.tar.gz dexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.tar.bz2 dexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.tar.lz dexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.tar.xz dexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.tar.zst dexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.zip |
Test for incorrect storage access.
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityOptimizer.cpp | 21 |
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; |