Cleanup ABICoder V1 tests

Include the pragma explicitly, rename the file to have a _v1 suffix, and also add V2 counterparts where missing.
This commit is contained in:
Alex Beregszaszi 2021-05-14 19:54:46 +01:00
parent 1d41ceaed4
commit 299873182b
25 changed files with 37 additions and 11 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,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;