test: some tests for push0

1. `push0_disallowed.yul`: checks if `push0()` is a valid builtin in strict Yul
2. `push0_disallowed.sol`: checks if `push0()` is a valid builtin in inline assembly
3. `push0.sol`: simple semantic test that returns 0
4. `evmone_support.sol`: tests if push0 works properly in evmone
5. Updated some bytecode too large tests to use `shanghai` as version
6. Updated various tests where `push1 0` was hardcoded in different forms / expectations on bytecode
size (`Assembler.cpp`, `GasCosts.cpp`, `SolidityCompiler.cpp`, `SolidityExpressionCompiler.cpp`)
This commit is contained in:
hrkrshnn
2023-04-12 00:10:24 +02:00
parent 802f895062
commit 41ce3feb0a
14 changed files with 130 additions and 27 deletions
+13 -3
View File
@@ -112,15 +112,21 @@ BOOST_AUTO_TEST_CASE(string_storage)
// Costs with 0 are cases which cannot be triggered in tests.
if (evmVersion < EVMVersion::istanbul())
CHECK_DEPLOY_GAS(0, 109241, evmVersion);
else
else if (evmVersion < EVMVersion::shanghai())
CHECK_DEPLOY_GAS(0, 97697, evmVersion);
// Shanghai is cheaper due to `push0`
else
CHECK_DEPLOY_GAS(0, 97071, evmVersion);
}
else
{
if (evmVersion < EVMVersion::istanbul())
CHECK_DEPLOY_GAS(139013, 123969, evmVersion);
else
else if (evmVersion < EVMVersion::shanghai())
CHECK_DEPLOY_GAS(123361, 110969, evmVersion);
// Shanghai is cheaper due to `push0`
else
CHECK_DEPLOY_GAS(121493, 110969, evmVersion);
}
}
else if (evmVersion < EVMVersion::istanbul())
@@ -198,7 +204,11 @@ BOOST_AUTO_TEST_CASE(single_callvaluecheck)
size_t bytecodeSizeNonpayable = m_compiler.object("Nonpayable").bytecode.size();
size_t bytecodeSizePayable = m_compiler.object("Payable").bytecode.size();
BOOST_CHECK_EQUAL(bytecodeSizePayable - bytecodeSizeNonpayable, 26);
auto evmVersion = solidity::test::CommonOptions::get().evmVersion();
if (evmVersion < EVMVersion::shanghai())
BOOST_CHECK_EQUAL(bytecodeSizePayable - bytecodeSizeNonpayable, 26);
else
BOOST_CHECK_EQUAL(bytecodeSizePayable - bytecodeSizeNonpayable, 24);
}
BOOST_AUTO_TEST_SUITE_END()