diff options
author | subtly <subtly@users.noreply.github.com> | 2015-02-13 02:30:55 +0800 |
---|---|---|
committer | subtly <subtly@users.noreply.github.com> | 2015-02-13 02:30:55 +0800 |
commit | 5eae51be12f82da95506593f65c75419b4bdff4e (patch) | |
tree | 53bced486ac86c43699073e87c601242cf3dfaae | |
parent | e332dfa147db4f838b52dfc9e491682981cf1e23 (diff) | |
parent | b04258b6f46ba613bf51a625bf8d9c6105ec56e4 (diff) | |
download | dexon-solidity-5eae51be12f82da95506593f65c75419b4bdff4e.tar.gz dexon-solidity-5eae51be12f82da95506593f65c75419b4bdff4e.tar.zst dexon-solidity-5eae51be12f82da95506593f65c75419b4bdff4e.zip |
Merge branch 'develop' into p2p
-rw-r--r-- | SolidityEndToEndTest.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 6c90ca62..587d4193 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -2385,6 +2385,45 @@ BOOST_AUTO_TEST_CASE(copy_removes_bytes_data) BOOST_CHECK(m_state.storage(m_contractAddress).empty()); } +BOOST_AUTO_TEST_CASE(bytes_inside_mappings) +{ + char const* sourceCode = R"( + contract c { + function set(uint key) returns (bool) { data[key] = msg.data; return true; } + function copy(uint from, uint to) returns (bool) { data[to] = data[from]; return true; } + mapping(uint => bytes) data; + } + )"; + compileAndRun(sourceCode); + // store a short byte array at 1 and a longer one at 2 + BOOST_CHECK(callContractFunction("set(uint256)", 1, 2) == encodeArgs(true)); + BOOST_CHECK(callContractFunction("set(uint256)", 2, 2, 3, 4, 5) == encodeArgs(true)); + BOOST_CHECK(!m_state.storage(m_contractAddress).empty()); + // copy shorter to longer + BOOST_CHECK(callContractFunction("copy(uint256,uint256)", 1, 2) == encodeArgs(true)); + BOOST_CHECK(!m_state.storage(m_contractAddress).empty()); + // copy empty to both + BOOST_CHECK(callContractFunction("copy(uint256,uint256)", 99, 1) == encodeArgs(true)); + BOOST_CHECK(!m_state.storage(m_contractAddress).empty()); + BOOST_CHECK(callContractFunction("copy(uint256,uint256)", 99, 2) == encodeArgs(true)); + BOOST_CHECK(m_state.storage(m_contractAddress).empty()); +} + +BOOST_AUTO_TEST_CASE(bytes_length_member) +{ + char const* sourceCode = R"( + contract c { + function set() returns (bool) { data = msg.data; return true; } + function getLength() returns (uint) { return data.length; } + bytes data; + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("getLength()") == encodeArgs(0)); + BOOST_CHECK(callContractFunction("set()", 1, 2) == encodeArgs(true)); + BOOST_CHECK(callContractFunction("getLength()") == encodeArgs(4+32+32)); +} + BOOST_AUTO_TEST_SUITE_END() } |