Skip to content

Commit 511cdc0

Browse files
committed
Enable debug revert strings in some of the existing calldata/encoding tests
1 parent f5e733b commit 511cdc0

11 files changed

Lines changed: 68 additions & 24 deletions

test/libsolidity/semanticTests/abicoder/abi_decode_offset_overflow_in_array.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ contract Test {
2424
return decoded[1][0];
2525
}
2626
}
27+
// ====
28+
// revertStrings: debug
2729
// ----
28-
// test() -> FAILURE
30+
// test() -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"

test/libsolidity/semanticTests/abicoder/abi_decode_offset_overflow_in_array_2.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ contract Test {
2424
return decoded[0][0] + decoded[1][0];
2525
}
2626
}
27+
// ====
28+
// revertStrings: debug
2729
// ----
28-
// withinArray() -> FAILURE
30+
// withinArray() -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"

test/libsolidity/semanticTests/abicoder/abi_decode_offset_overflow_in_array_3.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ contract Test {
1717
return decoded[1][0];
1818
}
1919
}
20+
// ====
21+
// revertStrings: debug
2022
// ----
21-
// test() -> FAILURE
23+
// test() -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray offset"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pragma abicoder v1;
2+
3+
contract C {
4+
function f(uint[] calldata) public {}
5+
}
6+
// ====
7+
// ABIEncoderV1Only: true
8+
// compileViaYul: false
9+
// revertStrings: debug
10+
// ----
11+
// f(uint256[]): 0x20, 0 ->
12+
// f(uint256[]): 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI calldata decoding: invalid d", "ata pointer"
13+
// f(uint256[]): 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI calldata decoding: invalid d", "ata pointer"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pragma abicoder v1;
2+
3+
contract C {
4+
function f(uint a, uint[] calldata b, uint c) external pure returns (uint) {
5+
return 7;
6+
}
7+
}
8+
// ====
9+
// ABIEncoderV1Only: true
10+
// compileViaYul: false
11+
// revertStrings: debug
12+
// ----
13+
// f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI calldata decoding: invalid d", "ata pointer"

test/libsolidity/semanticTests/abicoder/validation/array_exceeds_size_limit_for_calldata_types.sol renamed to test/libsolidity/semanticTests/abicoder/validation/array_exceeds_size_limit_for_calldata_types_v2.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
pragma abicoder v2;
2+
13
contract C {
24
function f(uint a, uint[] calldata b, uint c) external pure returns (uint) {
35
return 7;
46
}
57
}
8+
// ====
9+
// revertStrings: debug
610
// ----
7-
// f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE
11+
// f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray length"

test/libsolidity/semanticTests/abicoder/validation/calldata_array_dynamic_invalid_static_middle_v2.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
pragma abicoder v2;
2-
1+
pragma abicoder v2;
32

43
contract C {
54
function f(uint256[][1][] calldata a) external returns (uint256) {
@@ -16,14 +15,16 @@ contract C {
1615
return 42;
1716
}
1817
}
18+
// ====
19+
// revertStrings: debug
1920
// ----
2021
// f(uint256[][1][]): 0x20, 0x0 -> 42 # valid access stub #
21-
// f(uint256[][1][]): 0x20, 0x1 -> FAILURE # invalid on argument decoding #
22+
// f(uint256[][1][]): 0x20, 0x1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride" # invalid on argument decoding #
2223
// f(uint256[][1][]): 0x20, 0x1, 0x20 -> 42 # invalid on outer access #
23-
// g(uint256[][1][]): 0x20, 0x1, 0x20 -> FAILURE
24+
// g(uint256[][1][]): 0x20, 0x1, 0x20 -> FAILURE, hex"08c379a0", 0x20, 0x1c, "Invalid calldata tail offset"
2425
// f(uint256[][1][]): 0x20, 0x1, 0x20, 0x20 -> 42 # invalid on inner access #
2526
// g(uint256[][1][]): 0x20, 0x1, 0x20, 0x20 -> 42
26-
// h(uint256[][1][]): 0x20, 0x1, 0x20, 0x20 -> FAILURE
27+
// h(uint256[][1][]): 0x20, 0x1, 0x20, 0x20 -> FAILURE, hex"08c379a0", 0x20, 0x1c, "Invalid calldata tail offset"
2728
// f(uint256[][1][]): 0x20, 0x1, 0x20, 0x20, 0x1 -> 42
2829
// g(uint256[][1][]): 0x20, 0x1, 0x20, 0x20, 0x1 -> 42
29-
// h(uint256[][1][]): 0x20, 0x1, 0x20, 0x20, 0x1 -> FAILURE
30+
// h(uint256[][1][]): 0x20, 0x1, 0x20, 0x20, 0x1 -> FAILURE, hex"08c379a0", 0x20, 0x17, "Calldata tail too short"
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
pragma abicoder v2;
2-
1+
pragma abicoder v2;
32

43
contract C {
54
function f(uint256[][] calldata a) external returns (uint256) {
@@ -11,10 +10,12 @@ contract C {
1110
return 42;
1211
}
1312
}
13+
// ====
14+
// revertStrings: debug
1415
// ----
1516
// f(uint256[][]): 0x20, 0x0 -> 42 # valid access stub #
16-
// f(uint256[][]): 0x20, 0x1 -> FAILURE # invalid on argument decoding #
17+
// f(uint256[][]): 0x20, 0x1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride" # invalid on argument decoding #
1718
// f(uint256[][]): 0x20, 0x1, 0x20 -> 42 # invalid on outer access #
18-
// g(uint256[][]): 0x20, 0x1, 0x20 -> FAILURE
19+
// g(uint256[][]): 0x20, 0x1, 0x20 -> FAILURE, hex"08c379a0", 0x20, 0x1c, "Invalid calldata tail offset"
1920
// f(uint256[][]): 0x20, 0x1, 0x20, 0x2, 0x42 -> 42 # invalid on inner access #
20-
// g(uint256[][]): 0x20, 0x1, 0x20, 0x2, 0x42 -> FAILURE
21+
// g(uint256[][]): 0x20, 0x1, 0x20, 0x2, 0x42 -> FAILURE, hex"08c379a0", 0x20, 0x17, "Calldata tail too short"

test/libsolidity/semanticTests/abicoder/validation/calldata_with_garbage_v2.sol

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,30 @@ contract C {
3939
return (a[which], b[0]);
4040
}
4141
}
42+
// ====
43+
// revertStrings: debug
4244
// ----
4345
// f_memory(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0
4446
// f_memory(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 1, 7
45-
// f_memory(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE
47+
// f_memory(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"
4648
// f_encode(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0x40, 0x20, 0
4749
// f_encode(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 0x60, 0x20, 1, 7
48-
// f_encode(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE
50+
// f_encode(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"
4951
// f_storage(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0x40, 0x20, 0
5052
// f_storage(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 0x60, 0x20, 1, 7
51-
// f_storage(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE
53+
// f_storage(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"
5254
// f_index(uint256[],uint256): 0xa0, 0, 9, 9, 9, 2, 7, 8 -> 7
5355
// f_index(uint256[],uint256): 0xa0, 1, 9, 9, 9, 2, 7, 8 -> 8
5456
// f_index(uint256[],uint256): 0xa0, 2, 9, 9, 9, 2, 7, 8 -> FAILURE, hex"4e487b71", 0x32
5557
// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 0 -> 0x60, 1, 2, 0
5658
// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 1, 7 -> 0x60, 1, 2, 1, 7
57-
// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE
59+
// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"
5860
// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 0 -> 0x20, 0x80, 0x60, 1, 2, 0
5961
// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 1, 7 -> 0x20, 0xa0, 0x60, 1, 2, 1, 7
60-
// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE
62+
// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"
6163
// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 0 -> 0x20, 0x80, 0x60, 1, 2, 0
6264
// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 1, 7 -> 0x20, 0xa0, 0x60, 1, 2, 1, 7
63-
// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE
65+
// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"
6466
// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 0, 9, 9, 9, 2, 7, 8 -> 7, 1
6567
// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 1, 9, 9, 9, 2, 7, 8 -> 8, 1
66-
// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 1, 9, 9, 9, 2, 7 -> FAILURE
68+
// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 1, 9, 9, 9, 2, 7 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"

test/libsolidity/semanticTests/abicoder/validation/external_function_type_inside_struct_v2.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
pragma abicoder v2;
1+
pragma abicoder v2;
22

33
contract C {
44
struct S { function () external x; }
55
function f(S memory) public pure returns (uint r) { r = 1; }
66
function g(S calldata) external pure returns (uint r) { r = 2; }
77
function h(S calldata s) external pure returns (uint r) { s.x; r = 3; }
88
}
9+
// ====
10+
// revertStrings: debug
911
// ----
1012
// f((function)): "01234567890123456789abcd" -> 1
1113
// f((function)): "01234567890123456789abcdX" -> FAILURE

0 commit comments

Comments
 (0)