mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Enable more tests.
This commit is contained in:
parent
1066af3b98
commit
6ec5612f35
@ -2857,11 +2857,14 @@ BOOST_AUTO_TEST_CASE(delete_removes_bytes_data)
|
|||||||
bytes data;
|
bytes data;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
ABI_CHECK(callContractFunction("---", 7), bytes());
|
DISABLE_EWASM_TESTRUN()
|
||||||
BOOST_CHECK(!storageEmpty(m_contractAddress));
|
compileAndRun(sourceCode);
|
||||||
ABI_CHECK(callContractFunction("del()", 7), encodeArgs(true));
|
ABI_CHECK(callContractFunction("---", 7), bytes());
|
||||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
BOOST_CHECK(!storageEmpty(m_contractAddress));
|
||||||
|
ABI_CHECK(callContractFunction("del()", 7), encodeArgs(true));
|
||||||
|
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(copy_from_calldata_removes_bytes_data)
|
BOOST_AUTO_TEST_CASE(copy_from_calldata_removes_bytes_data)
|
||||||
@ -2873,13 +2876,16 @@ BOOST_AUTO_TEST_CASE(copy_from_calldata_removes_bytes_data)
|
|||||||
bytes data;
|
bytes data;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
ABI_CHECK(callContractFunction("set()", 1, 2, 3, 4, 5), encodeArgs(true));
|
DISABLE_EWASM_TESTRUN()
|
||||||
BOOST_CHECK(!storageEmpty(m_contractAddress));
|
compileAndRun(sourceCode);
|
||||||
sendMessage(bytes(), false);
|
ABI_CHECK(callContractFunction("set()", 1, 2, 3, 4, 5), encodeArgs(true));
|
||||||
BOOST_CHECK(m_transactionSuccessful);
|
BOOST_CHECK(!storageEmpty(m_contractAddress));
|
||||||
BOOST_CHECK(m_output.empty());
|
sendMessage(bytes(), false);
|
||||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
BOOST_CHECK(m_transactionSuccessful);
|
||||||
|
BOOST_CHECK(m_output.empty());
|
||||||
|
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(copy_removes_bytes_data)
|
BOOST_AUTO_TEST_CASE(copy_removes_bytes_data)
|
||||||
@ -3125,17 +3131,21 @@ BOOST_AUTO_TEST_CASE(bytes_in_arguments)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
|
DISABLE_EWASM_TESTRUN()
|
||||||
|
|
||||||
string innercalldata1 = asString(FixedHash<4>(util::keccak256("f(uint256,uint256)")).asBytes() + encodeArgs(8, 9));
|
compileAndRun(sourceCode);
|
||||||
string innercalldata2 = asString(FixedHash<4>(util::keccak256("g(uint256)")).asBytes() + encodeArgs(3));
|
|
||||||
bytes calldata = encodeArgs(
|
string innercalldata1 = asString(FixedHash<4>(util::keccak256("f(uint256,uint256)")).asBytes() + encodeArgs(8, 9));
|
||||||
12, 32 * 4, u256(32 * 4 + 32 + (innercalldata1.length() + 31) / 32 * 32), 13,
|
string innercalldata2 = asString(FixedHash<4>(util::keccak256("g(uint256)")).asBytes() + encodeArgs(3));
|
||||||
u256(innercalldata1.length()), innercalldata1,
|
bytes calldata = encodeArgs(
|
||||||
u256(innercalldata2.length()), innercalldata2);
|
12, 32 * 4, u256(32 * 4 + 32 + (innercalldata1.length() + 31) / 32 * 32), 13,
|
||||||
ABI_CHECK(
|
u256(innercalldata1.length()), innercalldata1,
|
||||||
callContractFunction("test(uint256,bytes,bytes,uint256)", calldata),
|
u256(innercalldata2.length()), innercalldata2);
|
||||||
encodeArgs(12, (8 + 9) * 3, 13, u256(innercalldata1.length()))
|
ABI_CHECK(
|
||||||
|
callContractFunction("test(uint256,bytes,bytes,uint256)", calldata),
|
||||||
|
encodeArgs(12, (8 + 9) * 3, 13, u256(innercalldata1.length()))
|
||||||
|
);
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3239,12 +3249,16 @@ BOOST_AUTO_TEST_CASE(dynamic_multi_array_cleanup)
|
|||||||
function clear() public { delete data; }
|
function clear() public { delete data; }
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
DISABLE_EWASM_TESTRUN()
|
||||||
ABI_CHECK(callContractFunction("fill()"), encodeArgs(8));
|
|
||||||
BOOST_CHECK(!storageEmpty(m_contractAddress));
|
compileAndRun(sourceCode);
|
||||||
ABI_CHECK(callContractFunction("clear()"), bytes());
|
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
ABI_CHECK(callContractFunction("fill()"), encodeArgs(8));
|
||||||
|
BOOST_CHECK(!storageEmpty(m_contractAddress));
|
||||||
|
ABI_CHECK(callContractFunction("clear()"), bytes());
|
||||||
|
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(array_copy_storage_storage_dyn_dyn)
|
BOOST_AUTO_TEST_CASE(array_copy_storage_storage_dyn_dyn)
|
||||||
@ -3361,20 +3375,24 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_abi)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
bytes valueSequence;
|
DISABLE_EWASM_TESTRUN()
|
||||||
for (size_t i = 0; i < 101; ++i)
|
|
||||||
valueSequence += toBigEndian(u256(i));
|
compileAndRun(sourceCode);
|
||||||
ABI_CHECK(callContractFunction("test1()"), encodeArgs(0x20, 101) + valueSequence);
|
bytes valueSequence;
|
||||||
ABI_CHECK(callContractFunction("test2()"), encodeArgs(0x20, 101) + valueSequence);
|
for (size_t i = 0; i < 101; ++i)
|
||||||
ABI_CHECK(callContractFunction("test3()"), encodeArgs(0x20, 101) + valueSequence);
|
valueSequence += toBigEndian(u256(i));
|
||||||
ABI_CHECK(callContractFunction("test4()"),
|
ABI_CHECK(callContractFunction("test1()"), encodeArgs(0x20, 101) + valueSequence);
|
||||||
encodeArgs(0x20, 5, 0xa0, 0xa0 + 102 * 32 * 1, 0xa0 + 102 * 32 * 2, 0xa0 + 102 * 32 * 3, 0xa0 + 102 * 32 * 4) +
|
ABI_CHECK(callContractFunction("test2()"), encodeArgs(0x20, 101) + valueSequence);
|
||||||
encodeArgs(101) + valueSequence +
|
ABI_CHECK(callContractFunction("test3()"), encodeArgs(0x20, 101) + valueSequence);
|
||||||
encodeArgs(101) + valueSequence +
|
ABI_CHECK(callContractFunction("test4()"),
|
||||||
encodeArgs(101) + valueSequence +
|
encodeArgs(0x20, 5, 0xa0, 0xa0 + 102 * 32 * 1, 0xa0 + 102 * 32 * 2, 0xa0 + 102 * 32 * 3, 0xa0 + 102 * 32 * 4) +
|
||||||
encodeArgs(101) + valueSequence +
|
encodeArgs(101) + valueSequence +
|
||||||
encodeArgs(101) + valueSequence
|
encodeArgs(101) + valueSequence +
|
||||||
|
encodeArgs(101) + valueSequence +
|
||||||
|
encodeArgs(101) + valueSequence +
|
||||||
|
encodeArgs(101) + valueSequence
|
||||||
|
);
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3400,9 +3418,12 @@ BOOST_AUTO_TEST_CASE(array_pop_uint16_transition)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
ABI_CHECK(callContractFunction("test()"), encodeArgs(38, 28, 18));
|
DISABLE_EWASM_TESTRUN()
|
||||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
compileAndRun(sourceCode);
|
||||||
|
ABI_CHECK(callContractFunction("test()"), encodeArgs(38, 28, 18));
|
||||||
|
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(array_pop_uint24_transition)
|
BOOST_AUTO_TEST_CASE(array_pop_uint24_transition)
|
||||||
@ -3427,9 +3448,12 @@ BOOST_AUTO_TEST_CASE(array_pop_uint24_transition)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
ABI_CHECK(callContractFunction("test()"), encodeArgs(20, 10));
|
DISABLE_EWASM_TESTRUN()
|
||||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
compileAndRun(sourceCode);
|
||||||
|
ABI_CHECK(callContractFunction("test()"), encodeArgs(20, 10));
|
||||||
|
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(array_pop_array_transition)
|
BOOST_AUTO_TEST_CASE(array_pop_array_transition)
|
||||||
@ -3475,9 +3499,12 @@ BOOST_AUTO_TEST_CASE(array_pop_storage_empty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
ABI_CHECK(callContractFunction("test()"), encodeArgs());
|
DISABLE_EWASM_TESTRUN()
|
||||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
compileAndRun(sourceCode);
|
||||||
|
ABI_CHECK(callContractFunction("test()"), encodeArgs());
|
||||||
|
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(byte_array_pop_storage_empty)
|
BOOST_AUTO_TEST_CASE(byte_array_pop_storage_empty)
|
||||||
@ -3495,9 +3522,12 @@ BOOST_AUTO_TEST_CASE(byte_array_pop_storage_empty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
ABI_CHECK(callContractFunction("test()"), encodeArgs());
|
DISABLE_EWASM_TESTRUN()
|
||||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
compileAndRun(sourceCode);
|
||||||
|
ABI_CHECK(callContractFunction("test()"), encodeArgs());
|
||||||
|
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(byte_array_pop_long_storage_empty)
|
BOOST_AUTO_TEST_CASE(byte_array_pop_long_storage_empty)
|
||||||
@ -3520,9 +3550,12 @@ BOOST_AUTO_TEST_CASE(byte_array_pop_long_storage_empty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
ALSO_VIA_YUL(
|
||||||
ABI_CHECK(callContractFunction("test()"), encodeArgs(true));
|
DISABLE_EWASM_TESTRUN()
|
||||||
BOOST_CHECK(storageEmpty(m_contractAddress));
|
compileAndRun(sourceCode);
|
||||||
|
ABI_CHECK(callContractFunction("test()"), encodeArgs(true));
|
||||||
|
BOOST_CHECK(storageEmpty(m_contractAddress));
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(byte_array_pop_long_storage_empty_garbage_ref)
|
BOOST_AUTO_TEST_CASE(byte_array_pop_long_storage_empty_garbage_ref)
|
||||||
@ -3598,15 +3631,19 @@ BOOST_AUTO_TEST_CASE(bytes_index_access)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
|
||||||
string array{
|
string array{
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
||||||
30, 31, 32, 33};
|
30, 31, 32, 33};
|
||||||
ABI_CHECK(callContractFunction("direct(bytes,uint256)", 64, 33, u256(array.length()), array), encodeArgs(33));
|
ALSO_VIA_YUL(
|
||||||
ABI_CHECK(callContractFunction("storageCopyRead(bytes,uint256)", 64, 33, u256(array.length()), array), encodeArgs(33));
|
DISABLE_EWASM_TESTRUN()
|
||||||
ABI_CHECK(callContractFunction("storageWrite()"), encodeArgs(0x193));
|
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
ABI_CHECK(callContractFunction("direct(bytes,uint256)", 64, 33, u256(array.length()), array), encodeArgs(33));
|
||||||
|
ABI_CHECK(callContractFunction("storageCopyRead(bytes,uint256)", 64, 33, u256(array.length()), array), encodeArgs(33));
|
||||||
|
ABI_CHECK(callContractFunction("storageWrite()"), encodeArgs(0x193));
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(array_copy_calldata_storage)
|
BOOST_AUTO_TEST_CASE(array_copy_calldata_storage)
|
||||||
|
@ -2,6 +2,8 @@ contract Test {
|
|||||||
bytes x;
|
bytes x;
|
||||||
function set(bytes memory _a) public { x = _a; }
|
function set(bytes memory _a) public { x = _a; }
|
||||||
}
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
// ----
|
// ----
|
||||||
// set(bytes): 0x20, 3, "abc"
|
// set(bytes): 0x20, 3, "abc"
|
||||||
// storage: nonempty
|
// storage: nonempty
|
||||||
|
Loading…
Reference in New Issue
Block a user