mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
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:
@@ -330,12 +330,16 @@ BOOST_AUTO_TEST_CASE(immutable)
|
||||
|
||||
checkCompilation(_assembly);
|
||||
|
||||
string genericPush0 = evmVersion.hasPush0() ? "5f" : "6000";
|
||||
// PUSH1 0x1b v/s PUSH1 0x19
|
||||
string dataOffset = evmVersion.hasPush0() ? "6019" : "601b" ;
|
||||
|
||||
BOOST_CHECK_EQUAL(
|
||||
_assembly.assemble().toHex(),
|
||||
// root.asm
|
||||
// assign "someImmutable"
|
||||
"602a" // PUSH1 42 - value for someImmutable
|
||||
"6000" // PUSH1 0 - offset of code into which to insert the immutable
|
||||
"602a" + // PUSH1 42 - value for someImmutable
|
||||
genericPush0 + // PUSH1 0 - offset of code into which to insert the immutable
|
||||
"8181" // DUP2 DUP2
|
||||
"6001" // PUSH1 1 - offset of first someImmutable in sub_0
|
||||
"01" // ADD - add offset of immutable to offset of code
|
||||
@@ -344,13 +348,13 @@ BOOST_AUTO_TEST_CASE(immutable)
|
||||
"01" // ADD - add offset of immutable to offset of code
|
||||
"52" // MSTORE
|
||||
// assign "someOtherImmutable"
|
||||
"6017" // PUSH1 23 - value for someOtherImmutable
|
||||
"6000" // PUSH1 0 - offset of code into which to insert the immutable
|
||||
"6017" + // PUSH1 23 - value for someOtherImmutable
|
||||
genericPush0 + // PUSH1 0 - offset of code into which to insert the immutable
|
||||
"6022" // PUSH1 34 - offset of someOtherImmutable in sub_0
|
||||
"01" // ADD - add offset of immutable to offset of code
|
||||
"52" // MSTORE
|
||||
"6063" // PUSH1 0x63 - dataSize(sub_0)
|
||||
"601b" // PUSH1 0x23 - dataOffset(sub_0)
|
||||
"6063" + // PUSH1 0x63 - dataSize(sub_0)
|
||||
dataOffset + // PUSH1 0x23 - dataOffset(sub_0)
|
||||
"fe" // INVALID
|
||||
// end of root.asm
|
||||
// sub.asm
|
||||
|
||||
Reference in New Issue
Block a user