Ethereum Test Fixtures package¶
Ethereum test fixture format definitions.
BaseFixture
¶
Bases: CamelModel
Represents a base Ethereum test fixture of any type.
Source code in packages/testing/src/execution_testing/fixtures/base.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
output_base_dir_name()
classmethod
¶
Return name of the subdirectory where this type of fixture should be dumped to.
Source code in packages/testing/src/execution_testing/fixtures/base.py
90 91 92 93 94 95 96 | |
__pydantic_init_subclass__(**kwargs)
classmethod
¶
Register all subclasses of BaseFixture with a fixture format name set as possible fixture formats.
Source code in packages/testing/src/execution_testing/fixtures/base.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
json_dict
cached
property
¶
Returns the JSON representation of the fixture.
hash
cached
property
¶
Returns the hash of the fixture.
json_dict_with_info(hash_only=False)
¶
Return JSON representation of the fixture with the info field.
Source code in packages/testing/src/execution_testing/fixtures/base.py
151 152 153 154 155 156 157 | |
model_post_init(__context)
¶
Model post-init to assert that the custom pre-allocation was provided and the default was not used.
Source code in packages/testing/src/execution_testing/fixtures/base.py
159 160 161 162 163 164 165 | |
fill_info(t8n_version, test_case_description, fixture_source_url, ref_spec, _info_metadata, metadata=None)
¶
Fill the info field for this fixture.
Source code in packages/testing/src/execution_testing/fixtures/base.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
get_fork()
¶
Return fork of the fixture as a string.
Source code in packages/testing/src/execution_testing/fixtures/base.py
189 190 191 | |
supports_fork(fork)
classmethod
¶
Return whether the fixture can be generated for the given fork.
By default, all fixtures support all forks.
Source code in packages/testing/src/execution_testing/fixtures/base.py
193 194 195 196 197 198 199 200 201 | |
discard_fixture_format_by_marks(fork, markers)
classmethod
¶
Discard a fixture format from filling if the appropriate marker is used.
Source code in packages/testing/src/execution_testing/fixtures/base.py
203 204 205 206 207 208 209 210 211 212 213 214 | |
FixtureFillingPhase
¶
Bases: Enum
Execution phase for fixture generation.
Source code in packages/testing/src/execution_testing/fixtures/base.py
60 61 62 63 64 | |
LabeledFixtureFormat
¶
Represents a fixture format with a custom label.
This label will be used in the test id and also will be added as a marker to the generated test case when filling the test.
Source code in packages/testing/src/execution_testing/fixtures/base.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
__init__(fixture_format, label, description)
¶
Initialize the fixture format with a custom label.
Source code in packages/testing/src/execution_testing/fixtures/base.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
format_name
property
¶
Get the filling format name.
format_phases
property
¶
Get the filling format phases where it should be included.
transition_tool_cache_key
property
¶
Get the transition tool cache key.
__eq__(other)
¶
Check if two labeled fixture formats are equal.
If the other object is a FixtureFormat type, the format of the labeled fixture format will be compared with the format of the other object.
Source code in packages/testing/src/execution_testing/fixtures/base.py
263 264 265 266 267 268 269 270 271 272 273 274 | |
strip_fixture_format_from_node(item)
¶
Remove fixture format suffix from a test nodeid.
Used for cache keys and xdist grouping to ensure related fixture formats (e.g., blockchain_test and blockchain_test_engine) share the same key.
Example
'test.py::test[fork_Osaka-state_test]' -> 'test.py::test[fork_Osaka]'
Source code in packages/testing/src/execution_testing/fixtures/base.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
BlockchainEngineFixture
¶
Bases: BlockchainEngineFixtureCommon
Engine specific test fixture information.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
738 739 740 741 742 743 744 745 746 747 748 749 750 751 | |
BlockchainEngineFixtureCommon
¶
Bases: BaseFixture
Base blockchain test fixture model for Engine API based execution.
Similar to BlockchainFixtureCommon but excludes the 'pre' field to avoid duplicating large pre-allocations.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 | |
get_fork()
¶
Return fixture's Fork.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
724 725 726 | |
supports_fork(fork)
classmethod
¶
Return whether the fixture can be generated for the given fork.
The Engine API is available only on Paris and afterwards.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
728 729 730 731 732 733 734 735 | |
BlockchainEngineStatefulFixture
¶
Bases: BlockchainEngineFixtureCommon
Engine fixture for snapshot-based stateful testing.
Instead of embedding pre-allocation or referencing a computed group, this fixture references an external snapshot that the consumer must pre-load. Setup payloads deploy contracts and seed accounts on top of the snapshot before the actual test payloads execute.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 | |
BlockchainEngineSyncFixture
¶
Bases: BlockchainEngineFixture
Engine Sync specific test fixture information.
This fixture format is specifically designed for sync testing where: - The client under test receives all payloads - A sync client attempts to sync from the client under test - Both client types are parametrized from hive client config
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | |
discard_fixture_format_by_marks(fork, markers)
classmethod
¶
Discard the fixture format based on the provided markers.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
843 844 845 846 847 848 849 850 851 852 | |
BlockchainEngineXFixture
¶
Bases: BlockchainEngineFixtureCommon
Engine X specific test fixture information.
Uses pre-allocation groups (and a single client instance) for efficient test execution without client restarts.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
pre_hash
instance-attribute
¶
Hash of the pre-allocation group this test belongs to.
post_state_diff = None
class-attribute
instance-attribute
¶
State difference from genesis after test execution (efficiency optimization).
payloads = Field(..., alias='engineNewPayloads')
class-attribute
instance-attribute
¶
Engine API payloads for blockchain execution.
BlockchainFixture
¶
Bases: BlockchainFixtureCommon
Cross-client specific blockchain test model use in JSON fixtures.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
695 696 697 698 699 700 701 702 703 704 705 706 | |
BlockchainFixtureCommon
¶
Bases: BaseFixture
Base blockchain test fixture model.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | |
config_defaults_for_backwards_compatibility(data)
classmethod
¶
Check if the config field is populated, otherwise use the root-level field values for backwards compatibility.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | |
get_fork()
¶
Return fork of the fixture as a string.
Source code in packages/testing/src/execution_testing/fixtures/blockchain.py
690 691 692 | |
FixtureCollector
dataclass
¶
Collects all fixtures generated by the test cases.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 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 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
get_fixture_basename(info)
¶
Return basename of the fixture file for a given test case.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
add_fixture(info, fixture, output_subdir=None)
¶
Add fixture and immediately stream to partial JSONL file.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
close_streaming_files()
¶
Close all open streaming file handles.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
359 360 361 362 363 364 365 366 367 | |
dump_fixtures()
¶
Dump collected fixtures (only used for stdout mode).
Source code in packages/testing/src/execution_testing/fixtures/collector.py
369 370 371 372 373 374 375 376 377 378 | |
verify_fixture_files(evm_fixture_verification)
¶
Run evm [state|block]test on each fixture.
For streaming mode, uses lightweight tracking of fixture paths/formats rather than keeping full fixtures in memory.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
TestInfo
dataclass
¶
Contains test information from the current node.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
strip_test_name(name)
classmethod
¶
Remove test prefix from a python test case name.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
113 114 115 116 117 118 119 120 | |
get_name_and_parameters()
¶
Convert test name to a tuple containing the test name and test parameters.
Example: test_push0_key_sstore[fork_Shanghai] -> test_push0_key_sstore, fork_Shanghai
Source code in packages/testing/src/execution_testing/fixtures/collector.py
122 123 124 125 126 127 128 129 130 131 | |
get_single_test_name(mode='module')
¶
Convert test name to a single test name.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
133 134 135 136 137 138 139 140 141 142 143 144 | |
get_dump_dir_path(base_dump_dir, filler_path, level='test_parameter')
¶
Path to dump the debug output as defined by the level to dump at.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
get_id()
¶
Return the test id.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
173 174 175 | |
get_module_relative_output_dir(filler_path)
¶
Return a directory name for the provided test_module (relative to the base ./tests directory) that can be used for output (within the configured fixtures output path or the base_dump_dir directory).
Example: tests/shanghai/eip3855_push0/test_push0.py -> shanghai/eip3855_push0/test_push0
Source code in packages/testing/src/execution_testing/fixtures/collector.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
merge_partial_fixture_files(output_dir)
¶
Merge all partial fixture JSONL files into final JSON fixture files.
Called at session end after all workers have written their partials. Each partial file contains JSONL lines: {"k": fixture_id, "v": json_str}
Processes one target file at a time, reading its partials sequentially into a dict. Memory = O(entries per target), freed before next target.
Source code in packages/testing/src/execution_testing/fixtures/collector.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
FixtureConsumer
¶
Bases: ABC
Abstract class for verifying Ethereum test fixtures.
Source code in packages/testing/src/execution_testing/fixtures/consume.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
can_consume(fixture_format)
¶
Return whether the fixture format is consumable by this consumer.
Source code in packages/testing/src/execution_testing/fixtures/consume.py
22 23 24 25 26 27 | |
consume_fixture(fixture_format, fixture_path, fixture_name=None, debug_output_path=None)
abstractmethod
¶
Test the client with the specified fixture using its direct consumer interface.
Source code in packages/testing/src/execution_testing/fixtures/consume.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
AccountCheck
¶
Bases: CamelModel
Capture which fields are verified for a single account.
A None value means the field is not checked (it was not
explicitly set by the test author). A present value records the
expected value that check_alloc would assert against.
Source code in packages/testing/src/execution_testing/fixtures/post_verifications.py
18 19 20 21 22 23 24 25 26 27 28 29 30 | |
PostVerifications
¶
Bases: CamelModel
Record every post-state check performed during a fill session.
Accounts mapped to None represent should-not-exist checks.
Source code in packages/testing/src/execution_testing/fixtures/post_verifications.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
from_alloc(alloc)
classmethod
¶
Derive verification checks from an expected post Alloc.
Walk each address/account pair and inspect
model_fields_set to determine which fields will actually
be compared by Account.check_alloc.
Source code in packages/testing/src/execution_testing/fixtures/post_verifications.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
PreAllocGroup
¶
Bases: PreAllocGroupBuilder
Pre-allocation group for tests with identical Environment and fork values.
Groups tests by a hash of their fixture Environment and fork to enable pre-allocation group optimization.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
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 | |
model_post_init(__context)
¶
Model post init method to cache the state root in GroupPreAlloc.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
341 342 343 344 345 346 | |
from_file(file)
classmethod
¶
Load a pre-allocation group from a JSON file.
Files are stored in builder format (without genesis). Genesis is computed on-demand when loading, ensuring state root computation happens exactly once in Phase 2, not during Phase 1 merging.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
PreAllocGroupBuilder
¶
Bases: CamelModel
Pre-allocation group builder.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
get_pre_account_count()
¶
Return the amount of accounts the pre-allocation group holds.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
45 46 47 | |
get_test_count()
¶
Return the amount of tests that use this pre-allocation group.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
49 50 51 | |
calculate_genesis()
¶
Get the genesis header for this group.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
53 54 55 56 57 58 59 | |
add_test_alloc(test_id, new_pre)
¶
Adds a pre to this builder's pre.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
61 62 63 64 65 66 67 68 | |
build()
¶
Build the pre-alloc group.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
70 71 72 73 74 75 76 77 78 79 80 81 | |
to_partial_file(file, worker_id=None)
¶
Save PreAllocGroupBuilder to a partial file (no locking).
Each worker writes its own partial file, which are merged at session end by merge_partial_group_files(). This eliminates lock contention that caused workers to take 30-180+ seconds each.
Saves the builder format (without genesis/state_root) to avoid expensive state root computation during Phase 1. State root is computed once when loading in Phase 2 via PreAllocGroup.from_file().
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
PreAllocGroupBuilders
¶
Bases: EthereumTestRootModel
Root model mapping pre-allocation group hashes to test groups.
If lazy_load is True, the groups are not loaded from the folder until they are accessed.
Iterating will fail if lazy_load is True.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
to_folder(folder, worker_id=None)
¶
Save PreAllocGroups to a folder as partial files.
Each worker writes its own partial files (no lock contention). Call merge_partial_group_files() on master after all workers finish.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
195 196 197 198 199 200 201 202 203 204 | |
add_test_pre(*, pre_alloc_hash, test_id, fork, chain_id, environment, pre)
¶
Adds a single test to the appropriate group based on the hash.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
PreAllocGroups
¶
Bases: EthereumTestRootModel
Root model mapping pre-allocation group hashes to test groups.
If lazy_load is True, the groups are not loaded from the folder until they are accessed.
Iterating will fail if lazy_load is True.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | |
__setitem__(key, value)
¶
Set item in root dict.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
380 381 382 383 384 385 | |
from_folder(folder, *, lazy_load=False)
classmethod
¶
Create PreAllocGroups from a folder of pre-allocation files.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
__getitem__(item)
¶
Get item from root dict.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
__iter__()
¶
Iterate over root dict.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
421 422 423 | |
__contains__(item)
¶
Check if item in root dict.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
425 426 427 | |
__len__()
¶
Get length of root dict.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
429 430 431 | |
keys()
¶
Get keys from root dict.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
433 434 435 | |
values()
¶
Get values from root dict.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
437 438 439 440 441 | |
items()
¶
Get items from root dict.
Source code in packages/testing/src/execution_testing/fixtures/pre_alloc_groups.py
443 444 445 446 447 | |
StateFixture
¶
Bases: BaseFixture
Fixture for a single StateTest.
Source code in packages/testing/src/execution_testing/fixtures/state.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
get_fork()
¶
Return fork of the fixture as a string.
Source code in packages/testing/src/execution_testing/fixtures/state.py
126 127 128 129 130 | |
TransactionFixture
¶
Bases: BaseFixture
Fixture for a single TransactionTest.
Source code in packages/testing/src/execution_testing/fixtures/transaction.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
get_fork()
¶
Return the fork of the fixture as a string.
Source code in packages/testing/src/execution_testing/fixtures/transaction.py
40 41 42 43 44 45 46 | |