diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp index 768ab9b3b..9f8b40dd3 100644 --- a/test/libsolidity/ABIDecoderTests.cpp +++ b/test/libsolidity/ABIDecoderTests.cpp @@ -136,54 +136,6 @@ BOOST_AUTO_TEST_CASE(cleanup) ) } -BOOST_AUTO_TEST_CASE(fixed_arrays) -{ - string sourceCode = R"( - contract C { - function f(uint16[3] memory a, uint16[2][3] memory b, uint i, uint j, uint k) - public pure returns (uint, uint) { - return (a[i], b[j][k]); - } - } - )"; - BOTH_ENCODERS( - compileAndRun(sourceCode); - bytes args = encodeArgs( - 1, 2, 3, - 11, 12, - 21, 22, - 31, 32, - 1, 2, 1 - ); - ABI_CHECK( - callContractFunction("f(uint16[3],uint16[2][3],uint256,uint256,uint256)", args), - encodeArgs(u256(2), u256(32)) - ); - ) -} - -BOOST_AUTO_TEST_CASE(calldata_arrays_too_large) -{ - string sourceCode = R"( - contract C { - function f(uint a, uint[] calldata b, uint c) external pure returns (uint) { - return 7; - } - } - )"; - BOTH_ENCODERS( - compileAndRun(sourceCode); - bytes args = encodeArgs( - 6, 0x60, 9, - (u256(1) << 255) + 2, 1, 2 - ); - ABI_CHECK( - callContractFunction("f(uint256,uint256[],uint256)", args), - encodeArgs() - ); - ) -} - BOOST_AUTO_TEST_CASE(decode_from_memory_simple) { string sourceCode = R"( diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_fixed_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_fixed_arrays.sol new file mode 100644 index 000000000..b421f7bd0 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_fixed_arrays.sol @@ -0,0 +1,10 @@ +contract C { + function f(uint16[3] memory a, uint16[2][3] memory b, uint i, uint j, uint k) + public pure returns (uint, uint) { + return (a[i], b[j][k]); + } +} +// ==== +// compileViaYul: also +// ---- +// f(uint16[3],uint16[2][3],uint256,uint256,uint256): 1, 2, 3, 11, 12, 21, 22, 31, 32, 1, 2, 1 -> 2, 32 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/calldata_arrays_too_large.sol b/test/libsolidity/semanticTests/abiEncoderV1/calldata_arrays_too_large.sol new file mode 100644 index 000000000..7b1f09e10 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV1/calldata_arrays_too_large.sol @@ -0,0 +1,9 @@ +contract C { + function f(uint a, uint[] calldata b, uint c) external pure returns (uint) { + return 7; + } +} +// ==== +// compileViaYul: also +// ---- +// f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE \ No newline at end of file diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_decode_fixed_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_decode_fixed_arrays.sol new file mode 100644 index 000000000..ac0662dd6 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_decode_fixed_arrays.sol @@ -0,0 +1,12 @@ +pragma experimental ABIEncoderV2; + +contract C { + function f(uint16[3] memory a, uint16[2][3] memory b, uint i, uint j, uint k) + public pure returns (uint, uint) { + return (a[i], b[j][k]); + } +} +// ==== +// compileViaYul: also +// ---- +// f(uint16[3],uint16[2][3],uint256,uint256,uint256): 1, 2, 3, 11, 12, 21, 22, 31, 32, 1, 2, 1 -> 2, 32 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_arrays_too_large.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_arrays_too_large.sol new file mode 100644 index 000000000..e24a494c4 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_arrays_too_large.sol @@ -0,0 +1,11 @@ +pragma experimental ABIEncoderV2; + +contract C { + function f(uint a, uint[] calldata b, uint c) external pure returns (uint) { + return 7; + } +} +// ==== +// compileViaYul: also +// ---- +// f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE \ No newline at end of file