Skip to content

Commit

Permalink
Add test for initcode-mode non-transitiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
pdobacz authored and gumb0 committed Apr 16, 2024
1 parent 2656062 commit 6e697e7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/unittests/state_transition_eof_create_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,37 @@ TEST_F(state_transition, eofcreate_empty_auxdata)
expect.post[create_address].nonce = 1;
}

TEST_F(state_transition, eofcreate_extcall_returncontract)
{
rev = EVMC_PRAGUE;
constexpr auto callee = 0xca11ee_address;
const auto deploy_container = eof_bytecode(bytecode(OP_INVALID));

pre.insert(
callee, {
.code = eof_bytecode(returncontract(0, 0, 0), 2).container(deploy_container),
});


const auto init_code = mstore(0, extcall(callee)) + revert(0, 32);
const bytecode init_container = eof_bytecode(init_code, 4);

const auto factory_code =
sstore(0, eofcreate().container(0).salt(Salt)) + sstore(1, returndataload(0)) + OP_STOP;
const auto factory_container = eof_bytecode(factory_code, 4).container(init_container);

tx.to = To;

pre.insert(*tx.to, {.nonce = 1, .code = factory_container});

expect.post[*tx.to].nonce = pre.get(*tx.to).nonce + 1;
// No new address returned from EOFCREATE.
expect.post[*tx.to].storage[0x00_bytes32] = 0x00_bytes32;
// Internal EXTCALL returned 2 (abort).
expect.post[*tx.to].storage[0x01_bytes32] = 0x02_bytes32;
expect.post[callee].exists = true;
}

TEST_F(state_transition, eofcreate_auxdata_equal_to_declared)
{
rev = EVMC_PRAGUE;
Expand Down

0 comments on commit 6e697e7

Please sign in to comment.