mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for abi.encode.
This commit is contained in:
parent
e06d4303fb
commit
79d9a1ca81
@ -2,8 +2,16 @@ contract C {
|
||||
function f(bytes calldata x) public returns (C[] memory) {
|
||||
return abi.decode(x, (C[]));
|
||||
}
|
||||
function g() public returns (bytes memory) {
|
||||
C[] memory c = new C[](3);
|
||||
c[0] = C(address(0x42));
|
||||
c[1] = C(address(0x21));
|
||||
c[2] = C(address(0x23));
|
||||
return abi.encode(c);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bytes): 0x20, 0xA0, 0x20, 3, 0x01, 0x02, 0x03 -> 0x20, 3, 0x01, 0x02, 0x03
|
||||
// g() -> 0x20, 0xa0, 0x20, 3, 0x42, 0x21, 0x23
|
||||
|
@ -3,6 +3,13 @@ contract C {
|
||||
function f(bytes calldata x) public returns (C[] memory) {
|
||||
return abi.decode(x, (C[]));
|
||||
}
|
||||
function g() public returns (bytes memory) {
|
||||
C[] memory c = new C[](3);
|
||||
c[0] = C(address(0x42));
|
||||
c[1] = C(address(0x21));
|
||||
c[2] = C(address(0x23));
|
||||
return abi.encode(c);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
@ -10,3 +17,4 @@ contract C {
|
||||
// f(bytes): 0x20, 0xA0, 0x20, 3, 0x01, 0x02, 0x03 -> 0x20, 3, 0x01, 0x02, 0x03
|
||||
// f(bytes): 0x20, 0x60, 0x20, 1, 0x0102030405060708090a0b0c0d0e0f1011121314 -> 0x20, 1, 0x0102030405060708090a0b0c0d0e0f1011121314
|
||||
// f(bytes): 0x20, 0x60, 0x20, 1, 0x0102030405060708090a0b0c0d0e0f101112131415 -> FAILURE
|
||||
// g() -> 0x20, 0xa0, 0x20, 3, 0x42, 0x21, 0x23
|
||||
|
Loading…
Reference in New Issue
Block a user