|
9 | 9 | from ethereum_test_exceptions import TransactionException |
10 | 10 | from ethereum_test_fixtures import BlockchainFixture, FixtureFormat, StateFixture |
11 | 11 | from ethereum_test_forks import Fork, get_deployed_forks |
| 12 | +from ethereum_test_tools import Block |
12 | 13 | from ethereum_test_types import Alloc, Environment, Storage, Transaction, TransactionReceipt |
13 | 14 |
|
| 15 | +from ..blockchain import BlockchainTest |
14 | 16 | from ..helpers import ( |
15 | 17 | TransactionExceptionMismatchError, |
16 | 18 | TransactionReceiptMismatchError, |
@@ -349,3 +351,53 @@ def test_transaction_expectation( |
349 | 351 | else: |
350 | 352 | with pytest.raises(exception_type) as _: |
351 | 353 | state_test.generate(request=None, t8n=t8n, fork=fork, fixture_format=fixture_format) |
| 354 | + |
| 355 | + |
| 356 | +@pytest.mark.parametrize( |
| 357 | + "fixture_format", |
| 358 | + [ |
| 359 | + BlockchainFixture, |
| 360 | + ], |
| 361 | +) |
| 362 | +def test_block_intermediate_state(pre, t8n, fork, fixture_format: FixtureFormat): |
| 363 | + """Validate the state when building blockchain.""" |
| 364 | + env = Environment() |
| 365 | + # pre = Alloc() |
| 366 | + sender = pre.fund_eoa() |
| 367 | + |
| 368 | + tx = Transaction(gas_limit=100_000, to=None, data=b"", sender=sender) |
| 369 | + tx_2 = Transaction(gas_limit=100_000, to=None, data=b"", sender=sender) |
| 370 | + |
| 371 | + block_1 = Block( |
| 372 | + txs=[tx], |
| 373 | + expected_post_state={ |
| 374 | + sender: Account( |
| 375 | + nonce=1, |
| 376 | + ), |
| 377 | + }, |
| 378 | + ) |
| 379 | + |
| 380 | + block_2 = Block(txs=[]) |
| 381 | + |
| 382 | + block_3 = Block( |
| 383 | + txs=[tx_2], |
| 384 | + expected_post_state={ |
| 385 | + sender: Account( |
| 386 | + nonce=2, |
| 387 | + ), |
| 388 | + }, |
| 389 | + ) |
| 390 | + |
| 391 | + BlockchainTest( |
| 392 | + genesis_environment=env, |
| 393 | + fork=fork, |
| 394 | + t8n=t8n, |
| 395 | + pre=pre, |
| 396 | + post=block_3.expected_post_state, |
| 397 | + blocks=[block_1, block_2, block_3], |
| 398 | + ).generate( |
| 399 | + request=None, # type: ignore |
| 400 | + t8n=t8n, |
| 401 | + fork=fork, |
| 402 | + fixture_format=fixture_format, |
| 403 | + ) |
0 commit comments