test_bal_callcode_nested_value_transfer()
Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_callcode_nested_value_transfer@87aba1a3.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_callcode_nested_value_transfer --fork Amsterdam
Ensure BAL captures balance changes from nested value transfers
when CALLCODE executes target code that itself makes CALL with value.
Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369 | def test_bal_callcode_nested_value_transfer(
pre: Alloc,
blockchain_test: BlockchainTestFiller,
) -> None:
"""
Ensure BAL captures balance changes from nested value transfers
when CALLCODE executes target code that itself makes CALL with value.
"""
alice = pre.fund_eoa()
bob = pre.fund_eoa(amount=0)
# TargetContract sends 100 wei to bob
target_code = Op.CALL(0, bob, 100, 0, 0, 0, 0)
target_contract = pre.deploy_contract(code=target_code)
# Oracle contract that uses CALLCODE to execute TargetContract's code
oracle_code = Op.CALLCODE(address=target_contract, value=100)
oracle_contract = pre.deploy_contract(code=oracle_code, balance=200)
tx = Transaction(sender=alice, to=oracle_contract)
block = Block(
txs=[tx],
expected_block_access_list=BlockAccessListExpectation(
account_expectations={
alice: BalAccountExpectation(
nonce_changes=[
BalNonceChange(block_access_index=1, post_nonce=1)
],
),
oracle_contract: BalAccountExpectation(
balance_changes=[
BalBalanceChange(
block_access_index=1, post_balance=100
)
],
),
bob: BalAccountExpectation(
balance_changes=[
BalBalanceChange(
block_access_index=1, post_balance=100
)
],
),
target_contract: BalAccountExpectation.empty(),
}
),
)
blockchain_test(pre=pre, blocks=[block], post={})
|
Parametrized Test Cases
This test generates 1 parametrized test case across 1 fork.