Ethereum Test Tools Package¶
Module containing tools for generating cross-client Ethereum execution layer tests.
CalldataCase
dataclass
¶
Small helper class to represent a single case whose condition depends on the value of the contract's calldata in a Switch case statement.
By default the calldata is read from position zero, but this can be
overridden using position
.
The condition
is generated automatically based on the value
(and
optionally position
) and may not be set directly.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
__post_init__()
¶
Generate the condition base on value
and position
.
Source code in src/ethereum_test_tools/code/generators.py
278 279 280 281 282 283 284 285 286 |
|
Case
dataclass
¶
Small helper class to represent a single, generic case in a Switch
cases
list.
Source code in src/ethereum_test_tools/code/generators.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
|
__post_init__()
¶
Ensure that the condition and action are of type bytes.
Source code in src/ethereum_test_tools/code/generators.py
252 253 254 255 256 257 |
|
Code
¶
Bases: SupportsBytes
, Sized
Generic code object.
Source code in src/ethereum_test_tools/code/code.py
10 11 12 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 |
|
bytecode: Optional[bytes] = None
class-attribute
instance-attribute
¶
bytes array that represents the bytecode of this object.
name: Optional[str] = name
class-attribute
instance-attribute
¶
Name used to describe this code. Usually used to add extra information to a test case.
__init__(code=None, *, name=None)
¶
Create a new Code object.
Source code in src/ethereum_test_tools/code/code.py
25 26 27 28 29 30 31 32 33 34 35 36 |
|
__bytes__()
¶
Transform the Code object into bytes.
Source code in src/ethereum_test_tools/code/code.py
38 39 40 41 42 43 44 45 |
|
__len__()
¶
Get the length of the Code object.
Source code in src/ethereum_test_tools/code/code.py
47 48 49 50 51 52 53 54 |
|
__add__(other)
¶
Adds two code objects together, by converting both to bytes first.
Source code in src/ethereum_test_tools/code/code.py
56 57 58 59 60 |
|
__radd__(other)
¶
Adds two code objects together, by converting both to bytes first.
Source code in src/ethereum_test_tools/code/code.py
62 63 64 65 66 |
|
CodeGasMeasure
dataclass
¶
Bases: Code
Helper class used to generate bytecode that measures gas usage of a bytecode, taking into account and subtracting any extra overhead gas costs required to execute. By default, the result gas calculation is saved to storage key 0.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
code: str | bytes | SupportsBytes
instance-attribute
¶
Bytecode to be executed to measure the gas usage.
overhead_cost: int = 0
class-attribute
instance-attribute
¶
Extra gas cost to be subtracted from extra operations.
extra_stack_items: int = 0
class-attribute
instance-attribute
¶
Extra stack items that remain at the end of the execution. To be considered when subtracting the value of the previous GAS operation, and to be popped at the end of the execution.
sstore_key: int = 0
class-attribute
instance-attribute
¶
Storage key to save the gas used.
__post_init__()
¶
Assemble the bytecode that measures gas usage.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
Conditional
dataclass
¶
Bases: Code
Helper class used to generate conditional bytecode.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
condition: str | bytes | SupportsBytes
instance-attribute
¶
Condition bytecode which must return the true or false condition of the conditional statement.
if_true: str | bytes | SupportsBytes
instance-attribute
¶
Bytecode to execute if the condition is true.
if_false: str | bytes | SupportsBytes
instance-attribute
¶
Bytecode to execute if the condition is false.
__post_init__()
¶
Assemble the conditional bytecode by generating the necessary jump and jumpdest opcodes surrounding the condition and the two possible execution paths.
In the future, PC usage should be replaced by using RJUMP and RJUMPI
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
Initcode
¶
Bases: Code
Helper class used to generate initcode for the specified deployment code.
The execution gas cost of the initcode is calculated, and also the deployment gas costs for the deployed code.
The initcode can be padded to a certain length if necessary, which does not affect the deployed code.
Other costs such as the CREATE2 hashing costs or the initcode_word_cost of EIP-3860 are not taken into account by any of these calculated costs.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
deploy_code: str | bytes | SupportsBytes = deploy_code
instance-attribute
¶
Bytecode to be deployed by the initcode.
execution_gas: int = initcode_prefix_execution_gas
instance-attribute
¶
Gas cost of executing the initcode, without considering deployment gas costs.
deployment_gas: int = GAS_PER_DEPLOYED_CODE_BYTE * len(deploy_code_bytes)
instance-attribute
¶
Gas cost of deploying the cost, subtracted after initcode execution,
__init__(*, deploy_code, initcode_length=None, initcode_prefix=b'', initcode_prefix_execution_gas=0, padding_byte=0, name=None)
¶
Generate legacy initcode that inits a contract with the specified code. The initcode can be padded to a specified length for testing purposes.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
Switch
dataclass
¶
Bases: Code
Helper class used to generate switch-case expressions in EVM bytecode.
Switch-case behavior
- If no condition is met in the list of BytecodeCases conditions,
the
default_action
bytecode is executed. - If multiple conditions are met, the action from the first valid condition is the only one executed.
- There is no fall through; it is not possible to execute multiple actions.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
default_action: str | bytes | SupportsBytes
instance-attribute
¶
The default bytecode to execute; if no condition is met, this bytecode is executed.
cases: List[Case | CalldataCase]
instance-attribute
¶
A list of Case or CalldataCase: The first element with a condition that evaluates to a non-zero value is the one that is executed.
__post_init__()
¶
Assemble the bytecode by looping over the list of cases and adding the necessary JUMPI and JUMPDEST opcodes in order to replicate switch-case behavior.
In the future, PC usage should be replaced by using RJUMP and RJUMPI.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
Yul
¶
Bases: SupportsBytes
, Sized
Yul compiler. Compiles Yul source code into bytecode.
Source code in src/ethereum_test_tools/code/yul.py
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 |
|
__bytes__()
¶
Assembles using solc --assemble
.
Source code in src/ethereum_test_tools/code/yul.py
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 |
|
__len__()
¶
Get the length of the Yul bytecode.
Source code in src/ethereum_test_tools/code/yul.py
108 109 110 111 112 |
|
__add__(other)
¶
Adds two code objects together, by converting both to bytes first.
Source code in src/ethereum_test_tools/code/yul.py
114 115 116 117 118 |
|
__radd__(other)
¶
Adds two code objects together, by converting both to bytes first.
Source code in src/ethereum_test_tools/code/yul.py
120 121 122 123 124 |
|
version()
¶
Return solc's version string
Source code in src/ethereum_test_tools/code/yul.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
AccessList
dataclass
¶
Access List for transactions.
Source code in src/ethereum_test_tools/common/types.py
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 |
|
to_list()
¶
Returns the access list as a list of serializable elements.
Source code in src/ethereum_test_tools/common/types.py
1147 1148 1149 1150 1151 |
|
Account
dataclass
¶
State associated with an address.
Source code in src/ethereum_test_tools/common/types.py
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 571 572 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 649 650 651 652 653 654 655 656 657 658 659 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 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 733 734 735 736 |
|
nonce: Optional[NumberConvertible] = field(default=None, json_encoder=JSONEncoder.Field(name='nonce', cast_type=ZeroPaddedHexNumber, default_value=0))
class-attribute
instance-attribute
¶
The scalar value equal to a) the number of transactions sent by an Externally Owned Account, b) the amount of contracts created by a contract.
balance: Optional[NumberConvertible] = field(default=None, json_encoder=JSONEncoder.Field(name='balance', cast_type=ZeroPaddedHexNumber, default_value=0))
class-attribute
instance-attribute
¶
The amount of Wei (10-18 Eth) the account has.
code: Optional[BytesConvertible] = field(default=None, json_encoder=JSONEncoder.Field(name='code', cast_type=Bytes, default_value=bytes()))
class-attribute
instance-attribute
¶
Bytecode contained by the account.
storage: Optional[Storage | Storage.StorageDictType] = field(default=None, json_encoder=JSONEncoder.Field(name='storage', cast_type=Storage, to_json=True, default_value={}))
class-attribute
instance-attribute
¶
Storage within a contract.
NONEXISTENT: object = object()
class-attribute
¶
Sentinel object used to specify when an account should not exist in the state.
NonceMismatch
¶
Bases: Exception
Test expected a certain nonce value for an account but a different value was found.
Source code in src/ethereum_test_tools/common/types.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
592 593 594 595 596 597 |
|
BalanceMismatch
¶
Bases: Exception
Test expected a certain balance for an account but a different value was found.
Source code in src/ethereum_test_tools/common/types.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
615 616 617 618 619 620 |
|
CodeMismatch
¶
Bases: Exception
Test expected a certain bytecode for an account but a different one was found.
Source code in src/ethereum_test_tools/common/types.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
638 639 640 641 642 643 |
|
check_alloc(address, alloc)
¶
Checks the returned alloc against an expected account in post state. Raises exception on failure.
Source code in src/ethereum_test_tools/common/types.py
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 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 |
|
is_empty()
¶
Returns true if an account deemed empty.
Source code in src/ethereum_test_tools/common/types.py
687 688 689 690 691 692 693 694 695 696 |
|
from_dict(data)
classmethod
¶
Create account from dictionary.
Source code in src/ethereum_test_tools/common/types.py
698 699 700 701 702 703 704 705 |
|
with_code(code)
classmethod
¶
Create account with provided code
and nonce of 1
.
Source code in src/ethereum_test_tools/common/types.py
707 708 709 710 711 712 |
|
merge(account_1, account_2)
classmethod
¶
Create a merged account from two sources.
Source code in src/ethereum_test_tools/common/types.py
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 |
|
Auto
¶
Class to use as a sentinel value for parameters that should be automatically calculated.
Source code in src/ethereum_test_tools/common/types.py
58 59 60 61 62 63 64 65 66 |
|
__repr__()
¶
Print the correct test id.
Source code in src/ethereum_test_tools/common/types.py
64 65 66 |
|
Block
dataclass
¶
Bases: Header
Block type used to describe block properties in test specs
Source code in src/ethereum_test_tools/common/types.py
2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 |
|
rlp: Optional[BytesConvertible] = None
class-attribute
instance-attribute
¶
If set, blockchain test will skip generating the block and will pass this value directly to the Fixture.
Only meant to be used to simulate blocks with bad formats, and therefore requires the block to produce an exception.
header_verify: Optional[Header] = None
class-attribute
instance-attribute
¶
If set, the block header will be verified against the specified values.
rlp_modifier: Optional[Header] = None
class-attribute
instance-attribute
¶
An RLP modifying header which values would be used to override the ones
returned by the evm_transition_tool
.
exception: Optional[str] = None
class-attribute
instance-attribute
¶
If set, the block is expected to be rejected by the client.
engine_api_error_code: Optional[EngineAPIError] = None
class-attribute
instance-attribute
¶
If set, the block is expected to produce an error response from the Engine API.
txs: Optional[List[Transaction]] = None
class-attribute
instance-attribute
¶
List of transactions included in the block.
ommers: Optional[List[Header]] = None
class-attribute
instance-attribute
¶
List of ommer headers included in the block.
withdrawals: Optional[List[Withdrawal]] = None
class-attribute
instance-attribute
¶
List of withdrawals to perform for this block.
set_environment(env)
¶
Creates a copy of the environment with the characteristics of this specific block.
Source code in src/ethereum_test_tools/common/types.py
2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 |
|
copy_with_rlp(rlp)
¶
Creates a copy of the block and adds the specified RLP.
Source code in src/ethereum_test_tools/common/types.py
2405 2406 2407 2408 2409 2410 2411 |
|
EngineAPIError
¶
Bases: IntEnum
List of Engine API errors
Source code in src/ethereum_test_tools/common/constants.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
Environment
dataclass
¶
Structure used to keep track of the context in which a block must be executed.
Source code in src/ethereum_test_tools/common/types.py
877 878 879 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 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 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 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 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 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 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 1123 1124 |
|
from_parent_header(parent)
staticmethod
¶
Instantiates a new environment with the provided header as parent.
Source code in src/ethereum_test_tools/common/types.py
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
|
parent_hash()
¶
Obtains the latest hash according to the highest block number in
block_hashes
.
Source code in src/ethereum_test_tools/common/types.py
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
|
apply_new_parent(new_parent)
¶
Applies a header as parent to a copy of this environment.
Source code in src/ethereum_test_tools/common/types.py
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
|
set_fork_requirements(fork, in_place=False)
¶
Fills the required fields in an environment depending on the fork.
Source code in src/ethereum_test_tools/common/types.py
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 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 1123 1124 |
|
Fixture
dataclass
¶
Bases: BaseFixture
Cross-client specific test fixture information.
Source code in src/ethereum_test_tools/common/types.py
2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 |
|
FixtureEngineNewPayload
dataclass
¶
Representation of the engine_newPayloadVX
information to be
sent using the block information.
Source code in src/ethereum_test_tools/common/types.py
2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 |
|
from_fixture_header(fork, header, transactions, withdrawals, valid, error_code)
classmethod
¶
Creates a FixtureEngineNewPayload
from a FixtureHeader
.
Source code in src/ethereum_test_tools/common/types.py
2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 |
|
Header
dataclass
¶
Header type used to describe block header properties in test specs.
Source code in src/ethereum_test_tools/common/types.py
1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 |
|
HiveFixture
dataclass
¶
Bases: BaseFixture
Hive specific test fixture information.
Source code in src/ethereum_test_tools/common/types.py
2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 |
|
JSONEncoder
¶
Bases: JSONEncoder
Custom JSON encoder for ethereum_test
types.
Source code in src/ethereum_test_tools/common/json.py
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 |
|
Field
dataclass
¶
Settings for a field in a JSON object.
Source code in src/ethereum_test_tools/common/json.py
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 |
|
name: Optional[str] = None
class-attribute
instance-attribute
¶
The name of the field in the JSON object.
cast_type: Optional[Callable] = None
class-attribute
instance-attribute
¶
The type or function to use to cast the field to before serializing.
skip_string_convert: bool = False
class-attribute
instance-attribute
¶
By default, the fields are converted to string after serializing.
to_json: bool = False
class-attribute
instance-attribute
¶
Whether the field should be converted to JSON by itself.
This option and JSON_SKIP_STRING_CONVERT
are mutually exclusive.
default_value: Optional[Any] = None
class-attribute
instance-attribute
¶
Value to use if the field is not set before type casting.
default_value_skip_cast: Optional[Any] = None
class-attribute
instance-attribute
¶
Value to use if the field is not set and also skip type casting.
keep_none: bool = False
class-attribute
instance-attribute
¶
Whether to keep the field if it is None
.
skip: bool = False
class-attribute
instance-attribute
¶
Whether to skip the field when serializing.
apply(encoder, target, field_name, value)
¶
Applies the settings to the target dictionary.
Source code in src/ethereum_test_tools/common/json.py
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 |
|
default(obj)
¶
Encodes types defined in this module using basic python facilities.
Source code in src/ethereum_test_tools/common/json.py
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 |
|
Removable
¶
Sentinel class to detect if a parameter should be removed.
(None
normally means "do not modify")
Source code in src/ethereum_test_tools/common/types.py
49 50 51 52 53 54 55 |
|
Storage
¶
Bases: SupportsJSON
Definition of a storage in pre or post state of a test
Source code in src/ethereum_test_tools/common/types.py
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 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 |
|
StorageDictType: TypeAlias = Dict[str | int | bytes | SupportsBytes, str | int | bytes | SupportsBytes]
class-attribute
¶
Dictionary type to be used when defining an input to initialize a storage.
InvalidType
¶
Bases: Exception
Invalid type used when describing test's expected storage key or value.
Source code in src/ethereum_test_tools/common/types.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
281 282 283 |
|
InvalidValue
¶
Bases: Exception
Invalid value used when describing test's expected storage key or value.
Source code in src/ethereum_test_tools/common/types.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
297 298 299 |
|
AmbiguousKeyValue
¶
Bases: Exception
Key is represented twice in the storage.
Source code in src/ethereum_test_tools/common/types.py
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 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
325 326 327 328 329 330 331 |
|
MissingKey
¶
Bases: Exception
Test expected to find a storage key set but key was missing.
Source code in src/ethereum_test_tools/common/types.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
344 345 346 |
|
KeyValueMismatch
¶
Bases: Exception
Test expected a certain value in a storage key but value found was different.
Source code in src/ethereum_test_tools/common/types.py
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 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
366 367 368 369 370 371 372 373 |
|
parse_key_value(input)
staticmethod
¶
Parses a key or value to a valid int key for storage.
Source code in src/ethereum_test_tools/common/types.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
|
key_value_to_string(value)
staticmethod
¶
Transforms a key or value into an hex string.
Source code in src/ethereum_test_tools/common/types.py
393 394 395 396 397 398 399 400 401 402 403 |
|
__init__(input={}, start_slot=0)
¶
Initializes the storage using a given mapping which can have keys and values either as string or int. Strings must be valid decimal or hexadecimal (starting with 0x) numbers.
Source code in src/ethereum_test_tools/common/types.py
405 406 407 408 409 410 411 412 413 414 415 416 417 |
|
__len__()
¶
Returns number of elements in the storage
Source code in src/ethereum_test_tools/common/types.py
419 420 421 |
|
__contains__(key)
¶
Checks for an item in the storage
Source code in src/ethereum_test_tools/common/types.py
423 424 425 426 |
|
__getitem__(key)
¶
Returns an item from the storage
Source code in src/ethereum_test_tools/common/types.py
428 429 430 431 432 433 |
|
__setitem__(key, value)
¶
Sets an item in the storage
Source code in src/ethereum_test_tools/common/types.py
435 436 437 |
|
__delitem__(key)
¶
Deletes an item from the storage
Source code in src/ethereum_test_tools/common/types.py
439 440 441 |
|
store_next(value)
¶
Stores a value in the storage and returns the key where the value is stored.
Increments the key counter so the next time this function is called, the next key is used.
Source code in src/ethereum_test_tools/common/types.py
443 444 445 446 447 448 449 450 451 |
|
__json__(encoder)
¶
Converts the storage into a string dict with appropriate 32-byte hex string formatting.
Source code in src/ethereum_test_tools/common/types.py
453 454 455 456 457 458 459 460 461 462 463 464 465 |
|
contains(other)
¶
Returns True if self contains all keys with equal value as contained by second storage. Used for comparison with test expected post state and alloc returned by the transition tool.
Source code in src/ethereum_test_tools/common/types.py
467 468 469 470 471 472 473 474 475 476 477 478 479 |
|
must_contain(address, other)
¶
Succeeds only if self contains all keys with equal value as contained by second storage. Used for comparison with test expected post state and alloc returned by the transition tool. Raises detailed exception when a difference is found.
Source code in src/ethereum_test_tools/common/types.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
must_be_equal(address, other)
¶
Succeeds only if "self" is equal to "other" storage.
Source code in src/ethereum_test_tools/common/types.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
Transaction
dataclass
¶
Generic object that can represent all Ethereum transaction types.
Source code in src/ethereum_test_tools/common/types.py
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 1248 1249 1250 1251 1252 1253 1254 1255 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 1281 1282 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 1346 1347 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 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 |
|
ty: Optional[int] = field(default=None, json_encoder=JSONEncoder.Field(name='type', cast_type=HexNumber))
class-attribute
instance-attribute
¶
Transaction type value.
InvalidFeePayment
¶
Bases: Exception
Transaction described more than one fee payment type.
Source code in src/ethereum_test_tools/common/types.py
1320 1321 1322 1323 1324 1325 1326 1327 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
1325 1326 1327 |
|
InvalidSignaturePrivateKey
¶
Bases: Exception
Transaction describes both the signature and private key of source account.
Source code in src/ethereum_test_tools/common/types.py
1329 1330 1331 1332 1333 1334 1335 1336 1337 |
|
__str__()
¶
Print exception string
Source code in src/ethereum_test_tools/common/types.py
1335 1336 1337 |
|
__post_init__()
¶
Ensures the transaction has no conflicting properties.
Source code in src/ethereum_test_tools/common/types.py
1339 1340 1341 1342 1343 1344 1345 1346 1347 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 |
|
with_error(error)
¶
Create a copy of the transaction with an added error.
Source code in src/ethereum_test_tools/common/types.py
1382 1383 1384 1385 1386 1387 1388 |
|
with_nonce(nonce)
¶
Create a copy of the transaction with a modified nonce.
Source code in src/ethereum_test_tools/common/types.py
1390 1391 1392 1393 1394 1395 1396 |
|
with_fields(**kwargs)
¶
Create a deepcopy of the transaction with modified fields.
Source code in src/ethereum_test_tools/common/types.py
1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 |
|
payload_body()
¶
Returns the list of values included in the transaction body.
Source code in src/ethereum_test_tools/common/types.py
1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 |
|
serialized_bytes()
¶
Returns bytes of the serialized representation of the transaction, which is almost always RLP encoding.
Source code in src/ethereum_test_tools/common/types.py
1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 |
|
signing_envelope()
¶
Returns the list of values included in the envelope used for signing.
Source code in src/ethereum_test_tools/common/types.py
1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 |
|
signing_bytes()
¶
Returns the serialized bytes of the transaction used for signing.
Source code in src/ethereum_test_tools/common/types.py
1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 |
|
signature_bytes()
¶
Returns the serialized bytes of the transaction signature.
Source code in src/ethereum_test_tools/common/types.py
1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 |
|
with_signature_and_sender()
¶
Returns a signed version of the transaction using the private key.
Source code in src/ethereum_test_tools/common/types.py
1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 |
|
Withdrawal
dataclass
¶
Structure to represent a single withdrawal of a validator's balance from the beacon chain.
Source code in src/ethereum_test_tools/common/types.py
789 790 791 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 823 824 825 826 827 828 |
|
to_serializable_list()
¶
Returns a list of the withdrawal's attributes in the order they should be serialized.
Source code in src/ethereum_test_tools/common/types.py
818 819 820 821 822 823 824 825 826 827 828 |
|
add_kzg_version(b_hashes, kzg_version)
¶
Adds the Kzg Version to each blob hash.
Source code in src/ethereum_test_tools/common/helpers.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
ceiling_division(a, b)
¶
Calculates the ceil without using floating point. Used by many of the EVM's formulas
Source code in src/ethereum_test_tools/common/helpers.py
18 19 20 21 22 23 |
|
compute_create2_address(address, salt, initcode)
¶
Compute address of the resulting contract created using the CREATE2
opcode.
Source code in src/ethereum_test_tools/common/helpers.py
36 37 38 39 40 41 42 43 44 |
|
compute_create_address(address, nonce)
¶
Compute address of the resulting contract created using a transaction
or the CREATE
opcode.
Source code in src/ethereum_test_tools/common/helpers.py
26 27 28 29 30 31 32 33 |
|
copy_opcode_cost(length)
¶
Calculates the cost of the COPY opcodes, assuming memory expansion from empty memory, based on the costs specified in the yellow paper: https://ethereum.github.io/yellowpaper/paper.pdf
Source code in src/ethereum_test_tools/common/helpers.py
64 65 66 67 68 69 70 |
|
cost_memory_bytes(new_bytes, previous_bytes)
¶
Calculates the cost of memory expansion, based on the costs specified in the yellow paper: https://ethereum.github.io/yellowpaper/paper.pdf
Source code in src/ethereum_test_tools/common/helpers.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
eip_2028_transaction_data_cost(data)
¶
Calculates the cost of a given data as part of a transaction, based on the costs specified in EIP-2028: https://eips.ethereum.org/EIPS/eip-2028
Source code in src/ethereum_test_tools/common/helpers.py
73 74 75 76 77 78 79 80 81 82 83 84 |
|
to_address(input)
¶
Converts an int or str into proper address 20-byte hex string.
Source code in src/ethereum_test_tools/common/helpers.py
87 88 89 90 91 |
|
to_hash(input)
¶
Converts an int or str into proper 32-byte hash hex string.
Source code in src/ethereum_test_tools/common/helpers.py
101 102 103 104 105 |
|
to_hash_bytes(input)
¶
Converts an int or str into proper 32-byte hash.
Source code in src/ethereum_test_tools/common/helpers.py
94 95 96 97 98 |
|
fill_test(t8n, test_spec, fork, spec, eips=None)
¶
Fills default/hive fixture for the specified fork and test spec.
Source code in src/ethereum_test_tools/filling/fill.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
ReferenceSpec
¶
Reference Specification Description Abstract Class.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
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 |
|
name()
abstractmethod
¶
Returns the name of the spec.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
35 36 37 38 39 40 |
|
has_known_version()
abstractmethod
¶
Returns true if the reference spec object is hard-coded with a latest known version.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
42 43 44 45 46 47 48 |
|
known_version()
abstractmethod
¶
Returns the latest known version in the reference.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
50 51 52 53 54 55 |
|
api_url()
abstractmethod
¶
Returns the URL required to poll the version from an API, if needed.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
57 58 59 60 61 62 |
|
latest_version()
abstractmethod
¶
Returns a digest that points to the latest version of the spec.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
64 65 66 67 68 69 |
|
is_outdated()
abstractmethod
¶
Checks whether the reference specification has been updated since the test was last updated.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
71 72 73 74 75 76 77 |
|
write_info(info)
abstractmethod
¶
Writes info about the reference specification used into the output fixture.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
79 80 81 82 83 84 85 |
|
parseable_from_module(module_dict)
abstractmethod
staticmethod
¶
Checks whether the module's dict contains required reference spec information.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
87 88 89 90 91 92 93 94 |
|
parse_from_module(module_dict)
abstractmethod
staticmethod
¶
Parses the module's dict into a reference spec.
Source code in src/ethereum_test_tools/reference_spec/reference_spec.py
96 97 98 99 100 101 102 |
|
BaseTest
dataclass
¶
Represents a base Ethereum test which must return a genesis and a blockchain.
Source code in src/ethereum_test_tools/spec/base_test.py
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 |
|
make_fixture(t8n, fork, eips=None)
abstractmethod
¶
Generate blockchain that must be executed sequentially during test.
Source code in src/ethereum_test_tools/spec/base_test.py
107 108 109 110 111 112 113 114 115 116 117 |
|
make_hive_fixture(t8n, fork, eips=None)
abstractmethod
¶
Generate the blockchain that must be executed sequentially during test.
Source code in src/ethereum_test_tools/spec/base_test.py
119 120 121 122 123 124 125 126 127 128 129 |
|
pytest_parameter_name()
abstractmethod
classmethod
¶
Must return the name of the parameter used in pytest to select this spec type as filler for the test.
Source code in src/ethereum_test_tools/spec/base_test.py
131 132 133 134 135 136 137 138 |
|
get_next_transition_tool_output_path()
¶
Returns the path to the next transition tool output file.
Source code in src/ethereum_test_tools/spec/base_test.py
140 141 142 143 144 145 146 147 148 149 |
|
BaseTestConfig
dataclass
¶
General configuration that all tests must support.
Source code in src/ethereum_test_tools/spec/base_test.py
80 81 82 83 84 85 86 87 88 89 |
|
enable_hive: bool = False
class-attribute
instance-attribute
¶
Enable any hive-related properties that the output could contain.
BlockchainTest
dataclass
¶
Bases: BaseTest
Filler type that tests multiple blocks (valid or invalid) in a chain.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
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 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 |
|
pytest_parameter_name()
classmethod
¶
Returns the parameter name used to identify this filler in a test.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
53 54 55 56 57 58 |
|
hive_enabled: bool
property
¶
Returns true if hive fixture generation is enabled, false otherwise.
make_genesis(t8n, fork)
¶
Create a genesis block from the blockchain test definition.
Source code in src/ethereum_test_tools/spec/blockchain_test.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 |
|
generate_block_data(t8n, fork, block, previous_env, previous_alloc, eips=None)
¶
Generate common block data for both make_fixture and make_hive_fixture.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
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 |
|
network_info(fork, eips=None)
¶
Returns fixture network information for the fork & EIP/s.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
202 203 204 205 206 |
|
verify_post_state(t8n, alloc)
¶
Verifies the post alloc after all block/s or payload/s are generated.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
208 209 210 211 212 213 214 215 216 |
|
make_fixture(t8n, fork, eips=None)
¶
Create a fixture from the blockchain test definition.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
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 |
|
make_hive_fixture(t8n, fork, eips=None)
¶
Create a hive fixture from the blocktest definition.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
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 |
|
StateTest
dataclass
¶
Bases: BaseTest
Filler type that tests transactions over the period of a single block.
Source code in src/ethereum_test_tools/spec/state_test.py
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 231 232 233 234 235 236 237 238 239 240 241 242 |
|
pytest_parameter_name()
classmethod
¶
Returns the parameter name used to identify this filler in a test.
Source code in src/ethereum_test_tools/spec/state_test.py
50 51 52 53 54 55 |
|
make_genesis(t8n, fork)
¶
Create a genesis block from the state test definition.
Source code in src/ethereum_test_tools/spec/state_test.py
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 |
|
generate_fixture_data(t8n, fork, eips=None)
¶
Generate common fixture data for both make_fixture and make_hive_fixture.
Source code in src/ethereum_test_tools/spec/state_test.py
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 |
|
make_fixture(t8n, fork, eips=None)
¶
Create a fixture from the state test definition.
Source code in src/ethereum_test_tools/spec/state_test.py
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 |
|
make_hive_fixture(t8n, fork, eips=None)
¶
Create a hive fixture from the state test definition.
Source code in src/ethereum_test_tools/spec/state_test.py
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 |
|
Opcode
¶
Bases: bytes
Represents a single Opcode instruction in the EVM, with extra metadata useful to parametrize tests.
Parameters¶
- popped_stack_items: number of items the opcode pops from the stack
- pushed_stack_items: number of items the opcode pushes to the stack
- min_stack_height: minimum stack height required by the opcode
- data_portion_length: number of bytes after the opcode in the bytecode that represent data
Source code in src/ethereum_test_tools/vm/opcode.py
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 |
|
__new__(opcode_or_byte, *, popped_stack_items=0, pushed_stack_items=0, min_stack_height=0, data_portion_length=0)
¶
Creates a new opcode instance.
Source code in src/ethereum_test_tools/vm/opcode.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
__call__(*args_t)
¶
Makes all opcode instances callable to return formatted bytecode, which constitutes a data portion, that is located after the opcode byte, and pre-opcode bytecode, which is normally used to set up the stack.
This useful to automatically format, e.g., push opcodes and their
data sections as Opcodes.PUSH1(0x00)
.
Data sign is automatically detected but for this reason the range
of the input must be:
[-2^(data_portion_bits-1), 2^(data_portion_bits)]
where:
data_portion_bits == data_portion_length * 8
For the stack, the arguments are set up in the opposite order they are given, so the first argument is the last item pushed to the stack.
The resulting stack arrangement does not take into account opcode stack element consumption, so the stack height is not guaranteed to be correct and the user must take this into consideration.
Integers can also be used as stack elements, in which case they are automatically converted to PUSH operations, and negative numbers always use a PUSH32 operation.
Hex-strings will automatically be converted to bytes.
Source code in src/ethereum_test_tools/vm/opcode.py
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 |
|
__len__()
¶
Returns the total bytecode length of the opcode, taking into account its data portion.
Source code in src/ethereum_test_tools/vm/opcode.py
159 160 161 162 163 164 |
|
int()
¶
Returns the integer representation of the opcode.
Source code in src/ethereum_test_tools/vm/opcode.py
166 167 168 169 170 |
|
__str__()
¶
Return the name of the opcode, assigned at Enum creation.
Source code in src/ethereum_test_tools/vm/opcode.py
172 173 174 175 176 |
|
Opcodes
¶
Bases: Opcode
, Enum
Enum containing all known opcodes.
Contains deprecated and not yet implemented opcodes.
This enum is !! NOT !! meant to be iterated over by the tests. Instead, create a list with cherry-picked opcodes from this Enum within the test if iteration is needed.
Do !! NOT !! remove or modify existing opcodes from this list.
Source code in src/ethereum_test_tools/vm/opcode.py
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 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 |
|