-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Reorganize semantic tests for calldata and abicoder #16483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0993ab1
Reorganize calldata and abicoder semantic tests
cameel c0a83bc
calldata_array_dynamic_bytes.sol: Enable testing via Yul
cameel 388b75d
Fix whitespace in some abiEncodeDecode tests
cameel f5e733b
Remove redundant ABI coder tests
cameel 511cdc0
Enable debug revert strings in some of the existing calldata/encoding…
cameel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
test/libsolidity/semanticTests/abiEncodeDecode/abi_encode_empty_string_v1.sol
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
test/libsolidity/semanticTests/abiEncodeDecode/offset_overflow_in_array_decoding.sol
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
test/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array_v2.sol
This file was deleted.
Oops, something went wrong.
69 changes: 0 additions & 69 deletions
69
test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
test/libsolidity/semanticTests/abiEncoderV2/abi_encode_rational_v2.sol
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
test/libsolidity/semanticTests/abiEncoderV2/dynamic_arrays.sol
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
test/libsolidity/semanticTests/abiEncoderV2/memory_params_in_external_function.sol
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
test/libsolidity/semanticTests/abicoder/abi_decode_offset_overflow_in_array.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| pragma abicoder v2; | ||
| contract Test { | ||
| struct MemoryUint { | ||
| uint field; | ||
| } | ||
| function test() public pure returns (uint) { | ||
| uint[] memory before = new uint[](1); // at offset 0x80 | ||
| // Two problems here: The first offset is zero, the second offset is missing. | ||
| bytes memory corrupt = abi.encode( | ||
| uint(32), // offset to "tuple" | ||
| uint(0) // bogus first element | ||
| ); | ||
|
|
||
| // At this point the free pointer is 0x80 + 64 (size of before) + 32 (length field of corrupt) + 64 (two encoded words) | ||
| // | ||
| // Now let's put random junk into memory immediately after the bogus first element. Our goal is to overflow the read pointer to point to before. | ||
| // The value read out at this point will be added to beginning of the encoded tuple, AKA corrupt + 64. We need then to write x where: | ||
| // x + 0x80 + 64 (before) + 32 (length of corrupt) + 32 (first word of corrupt) = 0x80 (mod 2^256) | ||
| // that is MAX_UINT - 128 | ||
| MemoryUint memory afterCorrupt; | ||
| afterCorrupt.field = uint(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80); | ||
| before[0] = 123456; | ||
| uint[][2] memory decoded = abi.decode(corrupt, (uint[][2])); | ||
| return decoded[1][0]; | ||
| } | ||
| } | ||
| // ==== | ||
| // revertStrings: debug | ||
| // ---- | ||
| // test() -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions
2
...iEncoderV2/abi_encode_empty_string_v2.sol → ...er/abi_encode_empty_string_not_bytes0.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,4 +5,3 @@ contract C { | |
| // f(uint256[]): 0x20, 0 -> | ||
| // f(uint256[]): 0x20, 1 -> FAILURE | ||
| // f(uint256[]): 0x20, 2 -> FAILURE | ||
|
|
||
13 changes: 13 additions & 0 deletions
13
test/libsolidity/semanticTests/abicoder/validation/array_exceeds_calldatasize_v1.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| pragma abicoder v1; | ||
|
|
||
| contract C { | ||
| function f(uint[] calldata) public {} | ||
| } | ||
| // ==== | ||
| // ABIEncoderV1Only: true | ||
| // compileViaYul: false | ||
| // revertStrings: debug | ||
| // ---- | ||
| // f(uint256[]): 0x20, 0 -> | ||
| // f(uint256[]): 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI calldata decoding: invalid d", "ata pointer" | ||
| // f(uint256[]): 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI calldata decoding: invalid d", "ata pointer" |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
...dity/semanticTests/abicoder/validation/array_exceeds_size_limit_for_calldata_types_v1.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| pragma abicoder v1; | ||
|
|
||
| contract C { | ||
| function f(uint a, uint[] calldata b, uint c) external pure returns (uint) { | ||
| return 7; | ||
| } | ||
| } | ||
| // ==== | ||
| // ABIEncoderV1Only: true | ||
| // compileViaYul: false | ||
| // revertStrings: debug | ||
| // ---- | ||
| // f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI calldata decoding: invalid d", "ata pointer" |
6 changes: 5 additions & 1 deletion
6
...biEncoderV1/calldata_arrays_too_large.sol → ...eeds_size_limit_for_calldata_types_v2.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| pragma abicoder v2; | ||
|
|
||
| contract C { | ||
| function f(uint a, uint[] calldata b, uint c) external pure returns (uint) { | ||
| return 7; | ||
| } | ||
| } | ||
| // ==== | ||
| // revertStrings: debug | ||
|
cameel marked this conversation as resolved.
|
||
| // ---- | ||
| // f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE | ||
| // f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray length" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.