aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-02-12 22:18:50 +0800
committerChristian <c@ethdev.com>2015-02-12 22:18:50 +0800
commit2472e2b9987c1d90b5bdd5a275392d79ba20a27e (patch)
tree2e622f8e275c1b0f21784afd6167b9347af051b2
parentd089703254d9d8243522f94b6585eb2c4e99bd57 (diff)
downloaddexon-solidity-2472e2b9987c1d90b5bdd5a275392d79ba20a27e.tar.gz
dexon-solidity-2472e2b9987c1d90b5bdd5a275392d79ba20a27e.tar.zst
dexon-solidity-2472e2b9987c1d90b5bdd5a275392d79ba20a27e.zip
Test for bytes in mapping.
-rw-r--r--SolidityEndToEndTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index 67d05d6e..a57eb270 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -2385,6 +2385,30 @@ 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_SUITE_END()
}