aboutsummaryrefslogtreecommitdiffstats
path: root/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2015-03-06 22:34:02 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2015-03-06 22:34:02 +0800
commit5fb44b241debf9230aea69b7708e204a88ba9d83 (patch)
tree0644526a7861d260a4b021de0694afec921a2f25 /SolidityEndToEndTest.cpp
parent51e376efb8dc2f410872c682e4bf36955ec7caca (diff)
parent1234526c938504134b6b86252353ab5e2ae6319f (diff)
downloaddexon-solidity-5fb44b241debf9230aea69b7708e204a88ba9d83.tar
dexon-solidity-5fb44b241debf9230aea69b7708e204a88ba9d83.tar.gz
dexon-solidity-5fb44b241debf9230aea69b7708e204a88ba9d83.tar.bz2
dexon-solidity-5fb44b241debf9230aea69b7708e204a88ba9d83.tar.lz
dexon-solidity-5fb44b241debf9230aea69b7708e204a88ba9d83.tar.xz
dexon-solidity-5fb44b241debf9230aea69b7708e204a88ba9d83.tar.zst
dexon-solidity-5fb44b241debf9230aea69b7708e204a88ba9d83.zip
Merge remote-tracking branch 'upstream/develop' into evmjit
Diffstat (limited to 'SolidityEndToEndTest.cpp')
-rw-r--r--SolidityEndToEndTest.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index 0b3836ad..dae0ca03 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -2949,6 +2949,65 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_struct)
BOOST_CHECK(m_state.storage(m_contractAddress).empty());
}
+BOOST_AUTO_TEST_CASE(external_array_args)
+{
+ char const* sourceCode = R"(
+ contract c {
+ function test(uint[8] a, uint[] b, uint[5] c, uint a_index, uint b_index, uint c_index)
+ external returns (uint av, uint bv, uint cv) {
+ av = a[a_index];
+ bv = b[b_index];
+ cv = c[c_index];
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ bytes params = encodeArgs(
+ 1, 2, 3, 4, 5, 6, 7, 8, // a
+ 3, // b.length
+ 21, 22, 23, 24, 25, // c
+ 0, 1, 2, // (a,b,c)_index
+ 11, 12, 13 // b
+ );
+ BOOST_CHECK(callContractFunction("test(uint256[8],uint256[],uint256[5],uint256,uint256,uint256)", params) == encodeArgs(1, 12, 23));
+}
+
+BOOST_AUTO_TEST_CASE(bytes_index_access)
+{
+ char const* sourceCode = R"(
+ contract c {
+ bytes data;
+ function direct(bytes arg, uint index) external returns (uint) {
+ return uint(arg[index]);
+ }
+ function storageCopyRead(bytes arg, uint index) external returns (uint) {
+ data = arg;
+ return uint(data[index]);
+ }
+ function storageWrite() external returns (uint) {
+ data.length = 35;
+ data[31] = 0x77;
+ data[32] = 0x14;
+
+ data[31] = 1;
+ data[31] |= 8;
+ data[30] = 1;
+ data[32] = 3;
+ return uint(data[30]) * 0x100 | uint(data[31]) * 0x10 | uint(data[32]);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ string array{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32, 33};
+ BOOST_CHECK(callContractFunction("direct(bytes,uint256)", u256(array.length()), 32, array) == encodeArgs(32));
+ BOOST_CHECK(callContractFunction("storageCopyRead(bytes,uint256)", u256(array.length()), 32, array) == encodeArgs(32));
+ BOOST_CHECK(callContractFunction("storageWrite()") == encodeArgs(0x193));
+}
+
BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base)
{
char const* sourceCode = R"(