diff --git a/test/Common.h b/test/Common.h index a665d563f..741b7047a 100644 --- a/test/Common.h +++ b/test/Common.h @@ -57,7 +57,7 @@ struct CommonOptions: boost::noncopyable bool optimize = false; bool enforceViaYul = false; bool disableSMT = false; - bool useABIEncoderV2 = false; + bool useABIEncoderV2 = false; // TODO bool showMessages = false; bool showMetadata = false; diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp index d7c164a46..d076ae536 100644 --- a/test/libsolidity/ABIDecoderTests.cpp +++ b/test/libsolidity/ABIDecoderTests.cpp @@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(both_encoders_macro) string sourceCode; int runs = 0; BOTH_ENCODERS(runs++;) - BOOST_CHECK(sourceCode == NewEncoderPragma); + BOOST_CHECK(sourceCode == "pragma abicoder v2;\n"); BOOST_CHECK_EQUAL(runs, 2); } diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp index 8cb08df86..af859f53d 100644 --- a/test/libsolidity/ABIEncoderTests.cpp +++ b/test/libsolidity/ABIEncoderTests.cpp @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(both_encoders_macro) string sourceCode; int runs = 0; BOTH_ENCODERS(runs++;) - BOOST_CHECK(sourceCode == NewEncoderPragma); + BOOST_CHECK(sourceCode == "pragma abicoder v2;\n"); BOOST_CHECK_EQUAL(runs, 2); } @@ -166,17 +166,18 @@ BOOST_AUTO_TEST_CASE(memory_array_one_dim) } )"; - if (!solidity::test::CommonOptions::get().useABIEncoderV2) - { + OLD_ENCODER( compileAndRun(sourceCode); callContractFunction("f()"); // The old encoder does not clean array elements. REQUIRE_LOG_DATA(encodeArgs(10, 0x60, 11, 3, u256("0xfffffffe"), u256("0xffffffff"), u256("0x100000000"))); - } + ) - compileAndRun(NewEncoderPragma + sourceCode); - callContractFunction("f()"); - REQUIRE_LOG_DATA(encodeArgs(10, 0x60, 11, 3, u256(-2), u256(-1), u256(0))); + NEW_ENCODER( + compileAndRun(sourceCode); + callContractFunction("f()"); + REQUIRE_LOG_DATA(encodeArgs(10, 0x60, 11, 3, u256(-2), u256(-1), u256(0))); + ); } BOOST_AUTO_TEST_CASE(memory_array_two_dim) diff --git a/test/libsolidity/ABITestsCommon.h b/test/libsolidity/ABITestsCommon.h index c5eea01ca..d8b5d1fe1 100644 --- a/test/libsolidity/ABITestsCommon.h +++ b/test/libsolidity/ABITestsCommon.h @@ -21,18 +21,24 @@ namespace solidity::frontend::test { -static std::string const NewEncoderPragma = "pragma experimental ABIEncoderV2;\n"; +#define OLD_ENCODER(CODE) \ +{\ + sourceCode = "pragma abicoder v1;\n" + sourceCode;\ + { CODE }\ +} #define NEW_ENCODER(CODE) \ -{ \ - sourceCode = NewEncoderPragma + sourceCode; \ - { CODE } \ +{\ + sourceCode = "pragma abicoder v2;\n" + sourceCode;\ + { CODE }\ } #define BOTH_ENCODERS(CODE) \ -{ \ - { CODE } \ - NEW_ENCODER(CODE) \ +{\ + string originalSourceCode = sourceCode;\ + OLD_ENCODER(CODE)\ + sourceCode = originalSourceCode;\ + NEW_ENCODER(CODE)\ } } // end namespaces