Skip to content

test: Add a state test reaching CALL max depth #1007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/unittests/state_transition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
void state_transition::SetUp()
{
pre.insert(tx.sender, {.nonce = 1, .balance = tx.gas_limit * tx.max_gas_price + tx.value + 1});
pre[tx.sender] = {.nonce = 1, .balance = tx.gas_limit * tx.max_gas_price + tx.value + 1};

Check warning on line 16 in test/unittests/state_transition.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/state_transition.cpp#L16

Added line #L16 was not covered by tests

// Default expectation (coinbase is added later for valid txs only).
expect.post[tx.sender].exists = true;
Expand Down
17 changes: 17 additions & 0 deletions test/unittests/state_transition_call_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,20 @@
expect.post[CALLEE1].storage[0x01_bytes32] = 0xdd_bytes32;
expect.post[CALLEE2].storage[0x01_bytes32] = 0xdd_bytes32;
}

TEST_F(state_transition, call_max_depth)

Check warning on line 54 in test/unittests/state_transition_call_test.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/state_transition_call_test.cpp#L54

Added line #L54 was not covered by tests
{
static constexpr auto JUMPDEST_POS = 38;
const auto code = jumpi(JUMPDEST_POS, eq(calldataload(0), 1024)) +
mstore(0, add(calldataload(0), 1)) +
call(OP_ADDRESS).input(0, 32).gas(0xffffffffff) + OP_STOP + OP_JUMPDEST +
sstore(0, calldataload(0));
ASSERT_EQ(code.find(OP_JUMPDEST), JUMPDEST_POS);

Check warning on line 61 in test/unittests/state_transition_call_test.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/state_transition_call_test.cpp#L57-L61

Added lines #L57 - L61 were not covered by tests

block.gas_limit = 1'000'000'000'000;
tx.gas_limit = block.gas_limit;
tx.to = To;
pre[To].code = code;
pre[Sender].balance = tx.gas_limit * tx.max_gas_price;
expect.post[To].storage[0x00_bytes32] = 0x0400_bytes32;

Check warning on line 68 in test/unittests/state_transition_call_test.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/state_transition_call_test.cpp#L63-L68

Added lines #L63 - L68 were not covered by tests
}