Merge pull request #11397 from ethereum/v1-test-cleanup

Cleanup ABICoder V1 tests
This commit is contained in:
Harikrishnan Mulackal 2021-05-17 16:20:22 +02:00 committed by GitHub
commit 21af5408d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 46 additions and 16 deletions

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
function f1() public returns (bytes memory) {
return abi.encode("");

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
function f(bool b) public pure returns (bool) { return b; }
}

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
function f(uint16 a, int16 b, address c, bytes3 d, bool e)
public pure returns (uint v, uint w, uint x, uint y, uint z) {

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
enum E { A, B }
function f(E e) public pure returns (uint x) {

View File

@ -1,5 +1,5 @@
==== Source: A ====
pragma abicoder v2;
pragma abicoder v2;
struct Data {
uint a;
@ -19,6 +19,8 @@ contract B {
}
}
==== Source: B ====
pragma abicoder v1;
import "A";
contract C is B {
@ -31,5 +33,5 @@ contract C is B {
// ----
// test() -> 77
// gas irOptimized: 133635
// gas legacy: 156573
// gas legacyOptimized: 112940
// gas legacy: 156449
// gas legacyOptimized: 112943

View File

@ -1,5 +1,5 @@
==== Source: A ====
pragma abicoder v2;
pragma abicoder v2;
struct Data {
uint value;
@ -23,6 +23,8 @@ contract B {
}
}
==== Source: B ====
pragma abicoder v1;
import "A";
contract C is B {
@ -39,4 +41,4 @@ contract C is B {
// ----
// test() -> 5, 10
// gas irOptimized: 92624
// gas legacy: 100441
// gas legacy: 100237

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
// Tests that this will not end up using a "bytes0" type
// (which would assert)
contract C {

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
// Input is still not checked - this needs ABIEncoderV2!
function f(uint16 a, uint16 b) public returns (uint16) {

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
function f(bool _b) public returns (uint256) {
if (_b) return 1;

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
// Checks that address types are properly cleaned before they are compared.
contract C {
function f(address a) public returns (uint256) {

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
// Checks that bytesXX types are properly cleaned before they are compared.
contract C {
function f(bytes2 a, uint16 x) public returns (uint256) {

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
function f(int8 a, uint8 b) public returns (int256) {
assembly {

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
function f(uint8 a, uint8 b) public returns (uint256) {
assembly {

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
function d(bytes memory _data) public pure returns (uint8) {
return abi.decode(_data, (uint8));

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
enum E {X, Y}
function f(E[] calldata arr) external {

View File

@ -0,0 +1,13 @@
pragma abicoder v2;
contract C {
enum E {X, Y}
function f(E[] calldata arr) external {
arr[1];
}
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: also
// revertStrings: debug
// ----
// f(uint8[]): 0x20, 2, 3, 3 -> FAILURE

View File

@ -4,6 +4,7 @@ contract C {
}
// ====
// EVMVersion: >=byzantium
// ABIEncoderV1Only: true
// compileViaYul: false
// revertStrings: debug
// ----

View File

@ -1,10 +0,0 @@
pragma abicoder v2;
contract C {
function t(uint) public pure {}
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: also
// revertStrings: debug
// ----
// t(uint256) -> FAILURE, hex"08c379a0", 0x20, 34, "ABI decoding: tuple data too sho", "rt"

View File

@ -1,9 +1,10 @@
pragma abicoder v2;
contract C {
function t(uint) public pure {}
}
// ====
// EVMVersion: >=byzantium
// compileViaYul: true
// compileViaYul: also
// revertStrings: debug
// ----
// t(uint256) -> FAILURE, hex"08c379a0", 0x20, 34, "ABI decoding: tuple data too sho", "rt"

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
function d(bytes memory _data) public pure returns (uint8) {
return abi.decode(_data, (uint8));

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C {
function dyn(uint ptr, uint start, uint x) public returns (bytes memory a) {
assembly {

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract test {
enum E { A, B, C }
mapping(E => uint8) public table;

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
enum E { A, B, C }
library L {
function get(mapping(E => uint8) storage table, E k) external returns (uint8) {

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
enum E { A, B, C }
contract test {
mapping(E => uint8) table;