mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Modify test system to cope with abi coder v2 as default.
This commit is contained in:
parent
9a36199892
commit
8b5d1d440f
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user