Skip to content

Commit c6d9832

Browse files
committed
Special treatment for differences between encoders.
1 parent 010ec15 commit c6d9832

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

test/libsolidity/ABIDecoderTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(enums)
8686
}
8787
}
8888
)";
89-
bool newDecoder = false;
89+
bool newDecoder = dev::test::Options::get().useABIEncoderV2;
9090
BOTH_ENCODERS(
9191
compileAndRun(sourceCode);
9292
ABI_CHECK(callContractFunction("f(uint8)", 0), encodeArgs(u256(0)));

test/libsolidity/ABIEncoderTests.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,13 @@ BOOST_AUTO_TEST_CASE(memory_array_one_dim)
164164
}
165165
)";
166166

167-
compileAndRun(sourceCode);
168-
callContractFunction("f()");
169-
// The old encoder does not clean array elements.
170-
REQUIRE_LOG_DATA(encodeArgs(10, 0x60, 11, 3, u256("0xfffffffe"), u256("0xffffffff"), u256("0x100000000")));
167+
if (!dev::test::Options::get().useABIEncoderV2)
168+
{
169+
compileAndRun(sourceCode);
170+
callContractFunction("f()");
171+
// The old encoder does not clean array elements.
172+
REQUIRE_LOG_DATA(encodeArgs(10, 0x60, 11, 3, u256("0xfffffffe"), u256("0xffffffff"), u256("0x100000000")));
173+
}
171174

172175
compileAndRun(NewEncoderPragma + sourceCode);
173176
callContractFunction("f()");

test/libsolidity/GasCosts.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,17 @@ BOOST_AUTO_TEST_CASE(string_storage)
7070

7171
if (Options::get().evmVersion() <= EVMVersion::byzantium())
7272
CHECK_GAS(134435, 130591, 100);
73+
else if (Options::get().useABIEncoderV2)
74+
CHECK_GAS(151819, 142753, 100);
7375
else
7476
CHECK_GAS(127225, 124873, 100);
7577
if (Options::get().evmVersion() >= EVMVersion::byzantium())
7678
{
7779
callContractFunction("f()");
7880
if (Options::get().evmVersion() == EVMVersion::byzantium())
7981
CHECK_GAS(21551, 21526, 20);
82+
else if (Options::get().useABIEncoderV2)
83+
CHECK_GAS(21713, 21635, 20);
8084
else
8185
CHECK_GAS(21546, 21526, 20);
8286
}

test/libsolidity/SolidityEndToEndTest.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14288,12 +14288,17 @@ BOOST_AUTO_TEST_CASE(abi_encode_empty_string)
1428814288
}
1428914289
}
1429014290
)";
14291+
1429114292
compileAndRun(sourceCode, 0, "C");
14292-
ABI_CHECK(callContractFunction("f()"), encodeArgs(
14293-
0x40, 0xc0,
14294-
0x60, 0x20, 0x00, 0x00,
14295-
0x00
14296-
));
14293+
if (!dev::test::Options::get().useABIEncoderV2)
14294+
{
14295+
// ABI Encoder V2 has slightly different padding, tested below.
14296+
ABI_CHECK(callContractFunction("f()"), encodeArgs(
14297+
0x40, 0xc0,
14298+
0x60, 0x20, 0x00, 0x00,
14299+
0x00
14300+
));
14301+
}
1429714302
}
1429814303

1429914304
BOOST_AUTO_TEST_CASE(abi_encode_empty_string_v2)

0 commit comments

Comments
 (0)