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 { contract C {
function f1() public returns (bytes memory) { function f1() public returns (bytes memory) {
return abi.encode(""); return abi.encode("");

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
==== Source: A ==== ==== Source: A ====
pragma abicoder v2; pragma abicoder v2;
struct Data { struct Data {
uint value; uint value;
@ -23,6 +23,8 @@ contract B {
} }
} }
==== Source: B ==== ==== Source: B ====
pragma abicoder v1;
import "A"; import "A";
contract C is B { contract C is B {
@ -39,4 +41,4 @@ contract C is B {
// ---- // ----
// test() -> 5, 10 // test() -> 5, 10
// gas irOptimized: 92624 // 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 // Tests that this will not end up using a "bytes0" type
// (which would assert) // (which would assert)
contract C { contract C {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C { contract C {
function f(int16 a, uint16 b) public returns (int16) { function f(int16 a, uint16 b) public returns (int16) {
return a >> b; return a >> b;

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C { contract C {
function f(int32 a, uint32 b) public returns (int32) { function f(int32 a, uint32 b) public returns (int32) {
return a >> b; return a >> b;

View File

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

View File

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

View File

@ -1,3 +1,4 @@
pragma abicoder v1;
contract C { contract C {
enum E {X, Y} enum E {X, Y}
function f(E[] calldata arr) external { 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 // EVMVersion: >=byzantium
// ABIEncoderV1Only: true
// compileViaYul: false // compileViaYul: false
// revertStrings: debug // 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 { contract C {
function t(uint) public pure {} function t(uint) public pure {}
} }
// ==== // ====
// EVMVersion: >=byzantium // EVMVersion: >=byzantium
// compileViaYul: true // compileViaYul: also
// revertStrings: debug // revertStrings: debug
// ---- // ----
// t(uint256) -> FAILURE, hex"08c379a0", 0x20, 34, "ABI decoding: tuple data too sho", "rt" // 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 { contract C {
function d(bytes memory _data) public pure returns (uint8) { function d(bytes memory _data) public pure returns (uint8) {
return abi.decode(_data, (uint8)); return abi.decode(_data, (uint8));

View File

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

View File

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

View File

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