Skip to content

Commit

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

TEST_F(state_transition, txcreate_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);

tx.type = Transaction::Type::initcodes;
tx.initcodes.push_back(init_container);

const auto factory_code = sstore(0, txcreate().initcode(keccak256(init_container)).salt(Salt)) +
sstore(1, returndataload(0)) + OP_STOP;
const auto factory_container = eof_bytecode(factory_code, 5);

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 TXCREATE.
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, txcreate_auxdata_equal_to_declared)
{
rev = EVMC_PRAGUE;
Expand Down

0 comments on commit 17c09c7

Please sign in to comment.