Filler Plugin¶
A pytest plugin to fill tests and generate JSON fixtures.
FixtureOutput
¶
Bases: BaseModel
Represents the output destination for generated test fixtures.
Source code in src/pytest_plugins/filler/fixture_output.py
13 14 15 16 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 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 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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
directory
property
¶
Return the actual directory path where fixtures will be written.
metadata_dir
property
¶
Return metadata directory to store fixture meta files.
is_tarball
property
¶
Return True if the output should be packaged as a tarball.
is_stdout
property
¶
Return True if the fixture output is configured to be stdout.
pre_alloc_groups_folder_path
property
¶
Return the path for pre-allocation groups folder.
should_auto_enable_all_formats
property
¶
Check if all formats should be auto-enabled due to tarball output.
strip_tarball_suffix(path)
staticmethod
¶
Strip the '.tar.gz' suffix from the output path.
Source code in src/pytest_plugins/filler/fixture_output.py
79 80 81 82 83 84 |
|
is_directory_empty()
¶
Check if the output directory is empty.
Source code in src/pytest_plugins/filler/fixture_output.py
86 87 88 89 90 91 |
|
is_directory_usable_for_phase()
¶
Check if the output directory is usable for the current phase.
Source code in src/pytest_plugins/filler/fixture_output.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
get_directory_summary()
¶
Return a summary of directory contents for error reporting.
Source code in src/pytest_plugins/filler/fixture_output.py
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 |
|
create_directories(is_master)
¶
Create output and metadata directories if needed.
If clean flag is set, remove and recreate the directory. Otherwise, verify the directory is empty before proceeding.
Source code in src/pytest_plugins/filler/fixture_output.py
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 |
|
create_tarball()
¶
Create tarball of the output directory if configured to do so.
Source code in src/pytest_plugins/filler/fixture_output.py
200 201 202 203 204 205 206 207 208 209 |
|
from_config(config)
classmethod
¶
Create a FixtureOutput instance from pytest configuration.
Source code in src/pytest_plugins/filler/fixture_output.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
Top-level pytest configuration file providing: - Command-line options, - Test-fixtures that can be used by all test cases, and that modifies pytest hooks in order to fill test specs for all tests and writes the generated fixtures to file.
PhaseManager
dataclass
¶
Manages the execution phase for fixture generation.
The filler plugin supports two-phase execution for pre-allocation group generation: - Phase 1: Generate pre-allocation groups (pytest run with --generate-pre-alloc-groups). - Phase 2: Fill fixtures using pre-allocation groups (pytest run with --use-pre-alloc-groups).
Note: These are separate pytest runs orchestrated by the CLI wrapper. Each run gets a fresh PhaseManager instance (no persistence between phases).
Source code in src/pytest_plugins/filler/filler.py
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
from_config(config)
classmethod
¶
Create a PhaseManager from pytest configuration.
Flag logic: - use_pre_alloc_groups: We're in phase 2 (FILL) after phase 1 (PRE_ALLOC_GENERATION). - generate_pre_alloc_groups or generate_all_formats: We're in phase 1 (PRE_ALLOC_GENERATION). - Otherwise: Normal single-phase filling (FILL).
Note: generate_all_formats triggers PRE_ALLOC_GENERATION because the CLI passes it to phase 1 to ensure all formats are considered for grouping.
Source code in src/pytest_plugins/filler/filler.py
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 |
|
is_pre_alloc_generation
property
¶
Check if we're in the pre-allocation generation phase.
is_fill_after_pre_alloc
property
¶
Check if we're filling after pre-allocation generation.
is_single_phase_fill
property
¶
Check if we're in single-phase fill mode (no pre-allocation).
FormatSelector
dataclass
¶
Handles fixture format selection based on the current phase and format capabilities.
This class encapsulates the complex logic for determining which fixture formats should be generated in each phase of the two-phase execution model.
Source code in src/pytest_plugins/filler/filler.py
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 |
|
should_generate(fixture_format)
¶
Determine if a fixture format should be generated in the current phase.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixture_format
|
Type[BaseFixture] | LabeledFixtureFormat
|
The fixture format to check (may be wrapped in LabeledFixtureFormat) |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the format should be generated in the current phase |
Source code in src/pytest_plugins/filler/filler.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
FillingSession
dataclass
¶
Manages all state for a single pytest fill session.
This class serves as the single source of truth for all filler state management, including phase management, format selection, and pre-allocation groups.
Important: Each pytest run gets a fresh FillingSession instance. There is no persistence between phase 1 (generate pre-alloc) and phase 2 (use pre-alloc) except through file I/O.
Source code in src/pytest_plugins/filler/filler.py
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 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 |
|
from_config(config)
classmethod
¶
Initialize a filling session from pytest configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
Config
|
The pytest configuration object. |
required |
Source code in src/pytest_plugins/filler/filler.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
should_generate_format(fixture_format)
¶
Determine if a fixture format should be generated in the current session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixture_format
|
Type[BaseFixture] | LabeledFixtureFormat
|
The fixture format to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the format should be generated. |
Source code in src/pytest_plugins/filler/filler.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
get_pre_alloc_group(hash_key)
¶
Get a pre-allocation group by hash.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hash_key
|
str
|
The hash of the pre-alloc group. |
required |
Returns:
Type | Description |
---|---|
PreAllocGroup
|
The pre-allocation group. |
Raises:
Type | Description |
---|---|
ValueError
|
If pre-alloc groups not initialized or hash not found. |
Source code in src/pytest_plugins/filler/filler.py
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 |
|
update_pre_alloc_group(hash_key, group)
¶
Update or add a pre-allocation group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hash_key
|
str
|
The hash of the pre-alloc group. |
required |
group
|
PreAllocGroup
|
The pre-allocation group. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If not in pre-alloc generation phase. |
Source code in src/pytest_plugins/filler/filler.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
save_pre_alloc_groups()
¶
Save pre-allocation groups to disk.
Source code in src/pytest_plugins/filler/filler.py
298 299 300 301 302 303 304 305 |
|
aggregate_pre_alloc_groups(worker_groups)
¶
Aggregate pre-alloc groups from a worker process (xdist support).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
worker_groups
|
PreAllocGroups
|
Pre-alloc groups from a worker process. |
required |
Source code in src/pytest_plugins/filler/filler.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
calculate_post_state_diff(post_state, genesis_state)
¶
Calculate the state difference between post_state and genesis_state.
This function enables significant space savings in Engine X fixtures by storing only the accounts that changed during test execution, rather than the full post-state which may contain thousands of unchanged accounts.
Returns an Alloc containing only the accounts that: - Changed between genesis and post state (balance, nonce, storage, code) - Were created during test execution (new accounts) - Were deleted during test execution (represented as None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
post_state
|
Alloc
|
Final state after test execution |
required |
genesis_state
|
Alloc
|
Genesis pre-allocation state |
required |
Returns:
Type | Description |
---|---|
Alloc
|
Alloc containing only the state differences for efficient storage |
Source code in src/pytest_plugins/filler/filler.py
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 |
|
default_output_directory()
¶
Directory (default) to store the generated test fixtures. Defined as a function to allow for easier testing.
Source code in src/pytest_plugins/filler/filler.py
378 379 380 381 382 383 |
|
default_html_report_file_path()
¶
File path (default) to store the generated HTML test report. Defined as a function to allow for easier testing.
Source code in src/pytest_plugins/filler/filler.py
386 387 388 389 390 391 |
|
pytest_addoption(parser)
¶
Add command-line options to pytest.
Source code in src/pytest_plugins/filler/filler.py
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 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
|
pytest_configure(config)
¶
Pytest hook called after command line options have been parsed and before test collection begins.
Couple of notes: 1. Register the plugin's custom markers and process command-line options.
Custom marker registration:
https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#registering-custom-markers
@pytest.hookimpl(tryfirst=True)
is applied to ensure that this hook is called before the pytest-html plugin's pytest_configure to ensure that it uses the modifiedhtmlpath
option.
Source code in src/pytest_plugins/filler/filler.py
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
|
pytest_report_header(config)
¶
Add lines to pytest's console output header.
Source code in src/pytest_plugins/filler/filler.py
651 652 653 654 655 656 657 |
|
pytest_report_teststatus(report, config)
¶
Modify test results in pytest's terminal output.
We use this:
- To disable test session progress report if we're writing the JSON
fixtures to stdout to be read by a consume command on stdin. I.e.,
don't write this type of output to the console:
...x...
Source code in src/pytest_plugins/filler/filler.py
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
|
pytest_terminal_summary(terminalreporter, exitstatus, config)
¶
Modify pytest's terminal summary to emphasize that no tests were ran.
Emphasize that fixtures have only been filled; they must now be executed to actually run the tests.
Source code in src/pytest_plugins/filler/filler.py
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
pytest_metadata(metadata)
¶
Add or remove metadata to/from the pytest report.
Source code in src/pytest_plugins/filler/filler.py
735 736 737 |
|
pytest_html_results_table_header(cells)
¶
Customize the table headers of the HTML report table.
Source code in src/pytest_plugins/filler/filler.py
740 741 742 743 744 |
|
pytest_html_results_table_row(report, cells)
¶
Customize the table rows of the HTML report table.
Source code in src/pytest_plugins/filler/filler.py
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 |
|
pytest_runtest_makereport(item, call)
¶
Make each test's fixture json path available to the test report via user_properties.
This hook is called when each test is run and a report is being made.
Source code in src/pytest_plugins/filler/filler.py
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
|
pytest_html_report_title(report)
¶
Set the HTML report title (pytest-html plugin).
Source code in src/pytest_plugins/filler/filler.py
811 812 813 |
|
evm_bin(request)
¶
Return configured evm tool binary path used to run t8n.
Source code in src/pytest_plugins/filler/filler.py
816 817 818 819 |
|
verify_fixtures_bin(request)
¶
Return configured evm tool binary path used to run statetest or blocktest.
Source code in src/pytest_plugins/filler/filler.py
822 823 824 825 826 827 828 |
|
t8n_server_url(request)
¶
Return configured t8n server url.
Source code in src/pytest_plugins/filler/filler.py
831 832 833 834 |
|
t8n(request, evm_bin, t8n_server_url)
¶
Return configured transition tool.
Source code in src/pytest_plugins/filler/filler.py
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
|
do_fixture_verification(request, verify_fixtures_bin)
¶
Return True if evm statetest or evm blocktest should be ran on the generated fixture JSON files.
Source code in src/pytest_plugins/filler/filler.py
864 865 866 867 868 869 870 871 872 873 874 875 876 877 |
|
evm_fixture_verification(request, do_fixture_verification, evm_bin, verify_fixtures_bin)
¶
Return configured evm binary for executing statetest and blocktest commands used to verify generated JSON fixtures.
Source code in src/pytest_plugins/filler/filler.py
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 |
|
base_dump_dir(request)
¶
Path to base directory to dump the evm debug output.
Source code in src/pytest_plugins/filler/filler.py
923 924 925 926 927 928 929 |
|
fixture_output(request)
¶
Return the fixture output configuration.
Source code in src/pytest_plugins/filler/filler.py
932 933 934 935 |
|
is_output_tarball(fixture_output)
¶
Return True if the output directory is a tarball.
Source code in src/pytest_plugins/filler/filler.py
938 939 940 941 |
|
output_dir(fixture_output)
¶
Return directory to store the generated test fixtures.
Source code in src/pytest_plugins/filler/filler.py
944 945 946 947 |
|
create_properties_file(request, fixture_output)
¶
Create ini file with fixture build properties in the fixture output directory.
Source code in src/pytest_plugins/filler/filler.py
950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 |
|
dump_dir_parameter_level(request, base_dump_dir, filler_path)
¶
Directory to dump evm transition tool debug output on a test parameter level.
Example with --evm-dump-dir=/tmp/evm: -> /tmp/evm/shanghai__eip3855_push0__test_push0__test_push0_key_sstore/fork_shanghai/
Source code in src/pytest_plugins/filler/filler.py
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
|
get_fixture_collection_scope(fixture_name, config)
¶
Return the appropriate scope to write fixture JSON files.
See: https://docs.pytest.org/en/stable/how-to/fixtures.html#dynamic-scope
Source code in src/pytest_plugins/filler/filler.py
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 |
|
reference_spec(request)
¶
Pytest fixture that returns the reference spec defined in a module.
See get_ref_spec_from_module
.
Source code in src/pytest_plugins/filler/filler.py
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 |
|
fixture_collector(request, do_fixture_verification, evm_fixture_verification, filler_path, base_dump_dir, fixture_output)
¶
Return configured fixture collector instance used for all tests in one test module.
Source code in src/pytest_plugins/filler/filler.py
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 |
|
filler_path(request)
¶
Return directory containing the tests to execute.
Source code in src/pytest_plugins/filler/filler.py
1075 1076 1077 1078 |
|
node_to_test_info(node)
¶
Return test info of the current node item.
Source code in src/pytest_plugins/filler/filler.py
1081 1082 1083 1084 1085 1086 1087 1088 |
|
commit_hash_or_tag()
¶
Cache the git commit hash or tag for the entire test session.
Source code in src/pytest_plugins/filler/filler.py
1091 1092 1093 1094 |
|
fixture_source_url(request, commit_hash_or_tag)
¶
Return URL to the fixture source.
Source code in src/pytest_plugins/filler/filler.py
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 |
|
base_test_parametrizer(cls)
¶
Generate pytest.fixture for a given BaseTest subclass.
Implementation detail: All spec fixtures must be scoped on test function level to avoid leakage between tests.
Source code in src/pytest_plugins/filler/filler.py
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 |
|
pytest_generate_tests(metafunc)
¶
Pytest hook used to dynamically generate test cases for each fixture format a given test spec supports.
NOTE: The static test filler does NOT use this hook. See FillerFile.collect() in ./static_filler.py for more details.
Source code in src/pytest_plugins/filler/filler.py
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 |
|
pytest_collection_modifyitems(config, items)
¶
Remove pre-Paris tests parametrized to generate hive type fixtures; these can't be used in the Hive Pyspec Simulator.
Replaces the test ID for state tests that use a transition fork with the base fork.
These can't be handled in this plugins pytest_generate_tests() as the fork parametrization occurs in the forks plugin.
Source code in src/pytest_plugins/filler/filler.py
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 |
|
pytest_sessionfinish(session, exitstatus)
¶
Perform session finish tasks.
- Save pre-allocation groups (phase 1)
- Remove any lock files that may have been created.
- Generate index file for all produced fixtures.
- Create tarball of the output directory if the output is a tarball.
Source code in src/pytest_plugins/filler/filler.py
1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 |
|
Pre-alloc specifically conditioned for test filling.
pytest_addoption(parser)
¶
Add command-line options to pytest.
Source code in src/pytest_plugins/filler/pre_alloc.py
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 |
|
AllocMode
¶
Bases: IntEnum
Allocation mode for the state.
Source code in src/pytest_plugins/filler/pre_alloc.py
79 80 81 82 83 |
|
Alloc
¶
Bases: Alloc
Allocation of accounts in the state, pre and post test execution.
Source code in src/pytest_plugins/filler/pre_alloc.py
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 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 |
|
__init__(*args, alloc_mode, contract_address_iterator, eoa_iterator, evm_code_type=None, **kwargs)
¶
Initialize allocation with the given properties.
Source code in src/pytest_plugins/filler/pre_alloc.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
__setitem__(address, account)
¶
Set account associated with an address.
Source code in src/pytest_plugins/filler/pre_alloc.py
113 114 115 116 117 |
|
code_pre_processor(code, *, evm_code_type)
¶
Pre-processes the code before setting it.
Source code in src/pytest_plugins/filler/pre_alloc.py
119 120 121 122 123 124 125 126 127 128 129 130 |
|
deploy_contract(code, *, storage=None, balance=0, nonce=1, address=None, evm_code_type=None, label=None)
¶
Deploy a contract to the allocation.
Warning: address
parameter is a temporary solution to allow tests to hard-code the
contract address. Do NOT use in new tests as it will be removed in the future!
Source code in src/pytest_plugins/filler/pre_alloc.py
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 |
|
fund_eoa(amount=None, label=None, storage=None, delegation=None, nonce=None)
¶
Add a previously unused EOA to the pre-alloc with the balance specified by amount
.
If amount is 0, nothing will be added to the pre-alloc but a new and unique EOA will be returned.
Source code in src/pytest_plugins/filler/pre_alloc.py
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 |
|
fund_address(address, amount)
¶
Fund an address with a given amount.
If the address is already present in the pre-alloc the amount will be added to its existing balance.
Source code in src/pytest_plugins/filler/pre_alloc.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
empty_account()
¶
Add a previously unused account guaranteed to be empty to the pre-alloc.
This ensures the account has: - Zero balance - Zero nonce - No code - No storage
This is different from precompiles or system contracts. The function does not send any transactions, ensuring that the account remains "empty."
Returns:
Name | Type | Description |
---|---|---|
Address |
Address
|
The address of the created empty account. |
Source code in src/pytest_plugins/filler/pre_alloc.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
alloc_mode(request)
¶
Return allocation mode for the tests.
Source code in src/pytest_plugins/filler/pre_alloc.py
276 277 278 279 280 281 |
|
contract_start_address(request)
¶
Return starting address for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
284 285 286 287 |
|
contract_address_increments(request)
¶
Return address increment for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
290 291 292 293 |
|
sha256_from_string(s)
¶
Return SHA-256 hash of a string.
Source code in src/pytest_plugins/filler/pre_alloc.py
296 297 298 |
|
contract_address_iterator(request, contract_start_address, contract_address_increments)
¶
Return iterator over contract addresses with dynamic scoping.
Source code in src/pytest_plugins/filler/pre_alloc.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
eoa_by_index(i)
cached
¶
Return EOA by index.
Source code in src/pytest_plugins/filler/pre_alloc.py
319 320 321 322 |
|
eoa_iterator(request)
¶
Return iterator over EOAs copies with dynamic scoping.
Source code in src/pytest_plugins/filler/pre_alloc.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
|
evm_code_type(request)
¶
Return default EVM code type for all tests (LEGACY).
Source code in src/pytest_plugins/filler/pre_alloc.py
344 345 346 347 348 349 350 351 |
|
pre(alloc_mode, contract_address_iterator, eoa_iterator, evm_code_type)
¶
Return default pre allocation for all tests (Empty alloc).
Source code in src/pytest_plugins/filler/pre_alloc.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
|