Skip to content

Commit

Permalink
test: Test gas refund propagation in calls
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Aug 18, 2022
1 parent 8137bf7 commit 715aa42
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/unittests/evm_calls_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,35 @@ TEST_P(evm, returndatacopy_outofrange)
execute(735, "60008080808080fa6000600260003e");
EXPECT_EQ(result.status_code, EVMC_INVALID_MEMORY_ACCESS);
}

TEST_P(evm, call_gas_refund_propagation)
{
rev = EVMC_LONDON;
host.accounts[msg.recipient].set_balance(1);
host.call_result.status_code = EVMC_SUCCESS;
host.call_result.gas_refund = 1;

const auto code_prolog = 7 * push(1);
for (const auto op :
{OP_CALL, OP_CALLCODE, OP_DELEGATECALL, OP_STATICCALL, OP_CREATE, OP_CREATE2})
{
execute(code_prolog + op);
EXPECT_STATUS(EVMC_SUCCESS);
EXPECT_EQ(result.gas_refund, 1);
}
}

TEST_P(evm, call_gas_refund_aggregation)
{
rev = EVMC_LONDON;
host.accounts[msg.recipient].set_balance(1);
host.call_result.status_code = EVMC_SUCCESS;
host.call_result.gas_refund = 1;

const auto a = 0xaa_address;
const auto code =
call(a) + callcode(a) + delegatecall(a) + staticcall(a) + create() + create2();
execute(code);
EXPECT_STATUS(EVMC_SUCCESS);
EXPECT_EQ(result.gas_refund, 6);
}

0 comments on commit 715aa42

Please sign in to comment.