Ethereum Test Tools Package¶
Module containing tools for generating cross-client Ethereum execution layer tests.
AccessList
¶
Bases: CamelModel
Access List for transactions.
Source code in src/ethereum_test_base_types/composite_types.py
463 464 465 466 467 468 469 470 471 |
|
to_list()
¶
Return access list as a list of serializable elements.
Source code in src/ethereum_test_base_types/composite_types.py
469 470 471 |
|
Account
¶
Bases: CamelModel
State associated with an address.
Source code in src/ethereum_test_base_types/composite_types.py
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 |
|
nonce: ZeroPaddedHexNumber = ZeroPaddedHexNumber(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: ZeroPaddedHexNumber = ZeroPaddedHexNumber(0)
class-attribute
instance-attribute
¶
The amount of Wei (10-18 Eth) the account has.
code: Bytes = Bytes(b'')
class-attribute
instance-attribute
¶
Bytecode contained by the account.
storage: Storage = Field(default_factory=Storage)
class-attribute
instance-attribute
¶
Storage within a contract.
NONEXISTENT: None = None
class-attribute
¶
Sentinel object used to specify when an account should not exist in the state.
NonceMismatchError
dataclass
¶
Bases: Exception
Test expected a certain nonce value for an account but a different value was found.
Source code in src/ethereum_test_base_types/composite_types.py
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 |
|
__init__(address, want, got, *args)
¶
Initialize the exception with the address, wanted and got values.
Source code in src/ethereum_test_base_types/composite_types.py
322 323 324 325 326 327 |
|
__str__()
¶
Print exception string.
Source code in src/ethereum_test_base_types/composite_types.py
329 330 331 332 333 334 335 336 337 |
|
BalanceMismatchError
dataclass
¶
Bases: Exception
Test expected a certain balance for an account but a different value was found.
Source code in src/ethereum_test_base_types/composite_types.py
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 |
|
__init__(address, want, got, *args)
¶
Initialize the exception with the address, wanted and got values.
Source code in src/ethereum_test_base_types/composite_types.py
350 351 352 353 354 355 |
|
__str__()
¶
Print exception string.
Source code in src/ethereum_test_base_types/composite_types.py
357 358 359 360 361 362 363 364 365 |
|
CodeMismatchError
dataclass
¶
Bases: Exception
Test expected a certain bytecode for an account but a different one was found.
Source code in src/ethereum_test_base_types/composite_types.py
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 |
|
__init__(address, want, got, *args)
¶
Initialize the exception with the address, wanted and got values.
Source code in src/ethereum_test_base_types/composite_types.py
378 379 380 381 382 383 |
|
__str__()
¶
Print exception string.
Source code in src/ethereum_test_base_types/composite_types.py
385 386 387 388 389 390 391 392 393 |
|
check_alloc(address, account)
¶
Check the returned alloc against an expected account in post state. Raises exception on failure.
Source code in src/ethereum_test_base_types/composite_types.py
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 |
|
__bool__()
¶
Return True on a non-empty account.
Source code in src/ethereum_test_base_types/composite_types.py
427 428 429 |
|
with_code(code)
classmethod
¶
Create account with provided code
and nonce of 1
.
Source code in src/ethereum_test_base_types/composite_types.py
431 432 433 434 |
|
merge(account_1, account_2)
classmethod
¶
Create a merged account from two sources.
Source code in src/ethereum_test_base_types/composite_types.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
|
Address
¶
Bases: FixedSizeBytes[20]
Class that helps represent Ethereum addresses in tests.
Source code in src/ethereum_test_base_types/base_types.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
__new__(input_bytes, *args, label=None, **kwargs)
¶
Create a new Address object with an optional label.
Source code in src/ethereum_test_base_types/base_types.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
Bytes
¶
Bases: bytes
, ToStringSchema
Class that helps represent bytes of variable length in tests.
Source code in src/ethereum_test_base_types/base_types.py
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 |
|
__new__(input_bytes=b'')
¶
Create a new Bytes object.
Source code in src/ethereum_test_base_types/base_types.py
137 138 139 140 141 |
|
__hash__()
¶
Return the hash of the bytes.
Source code in src/ethereum_test_base_types/base_types.py
143 144 145 |
|
__str__()
¶
Return the hexadecimal representation of the bytes.
Source code in src/ethereum_test_base_types/base_types.py
147 148 149 |
|
hex(*args, **kwargs)
¶
Return the hexadecimal representation of the bytes.
Source code in src/ethereum_test_base_types/base_types.py
151 152 153 |
|
or_none(input_bytes)
classmethod
¶
Convert the input to a Bytes while accepting None.
Source code in src/ethereum_test_base_types/base_types.py
155 156 157 158 159 160 |
|
keccak256()
¶
Return the keccak256 hash of the opcode byte representation.
Source code in src/ethereum_test_base_types/base_types.py
162 163 164 165 |
|
sha256()
¶
Return the sha256 hash of the opcode byte representation.
Source code in src/ethereum_test_base_types/base_types.py
167 168 169 |
|
Hash
¶
Bases: FixedSizeBytes[32]
Class that helps represent hashes in tests.
Source code in src/ethereum_test_base_types/base_types.py
316 317 318 319 |
|
ReferenceSpec
¶
Reference Specification Description Abstract Class.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
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 |
|
name()
abstractmethod
¶
Return the name of the spec.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
32 33 34 35 |
|
has_known_version()
abstractmethod
¶
Return true if the reference spec object is hard-coded with a latest known version.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
37 38 39 40 |
|
known_version()
abstractmethod
¶
Return the latest known version in the reference.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
42 43 44 45 |
|
api_url()
abstractmethod
¶
Return the URL required to poll the version from an API, if needed.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
47 48 49 50 |
|
latest_version()
abstractmethod
¶
Return a digest that points to the latest version of the spec.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
52 53 54 55 |
|
is_outdated()
abstractmethod
¶
Check whether the reference specification has been updated since the test was last updated.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
57 58 59 60 61 62 63 |
|
write_info(info)
abstractmethod
¶
Write info about the reference specification used into the output fixture.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
65 66 67 68 |
|
parseable_from_module(module_dict)
abstractmethod
staticmethod
¶
Check whether the module's dict contains required reference spec information.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
70 71 72 73 74 |
|
parse_from_module(module_dict)
abstractmethod
staticmethod
¶
Parse the module's dict into a reference spec.
Source code in src/ethereum_test_base_types/reference_spec/reference_spec.py
76 77 78 79 80 |
|
BlockException
¶
Bases: ExceptionBase
Exception raised when a block is invalid, but not due to a transaction.
E.g. all transactions in the block are valid, and can be applied to the state, but the block header contains an invalid field.
Source code in src/ethereum_test_exceptions/exceptions.py
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 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 |
|
TOO_MANY_UNCLES = auto()
class-attribute
instance-attribute
¶
Block declares too many uncles over the allowed limit.
UNCLE_IN_CHAIN = auto()
class-attribute
instance-attribute
¶
Block declares uncle header that is already imported into chain.
UNCLE_IS_ANCESTOR = auto()
class-attribute
instance-attribute
¶
Block declares uncle header that is directly a parent of this block.
UNCLE_IS_BROTHER = auto()
class-attribute
instance-attribute
¶
Block declares two similar uncle headers.
UNCLE_PARENT_INCORRECT = auto()
class-attribute
instance-attribute
¶
Block declares uncle header that is an outdated block to be an uncle.
EXTRA_DATA_TOO_BIG = auto()
class-attribute
instance-attribute
¶
Block header's extra data >32 bytes.
EXTRA_DATA_INVALID_DAO = auto()
class-attribute
instance-attribute
¶
Block header's extra data after dao fork must be a fixed pre defined hash.
UNKNOWN_PARENT = auto()
class-attribute
instance-attribute
¶
Block header's parent hash does not correspond to any of existing blocks on chain.
UNCLE_UNKNOWN_PARENT = auto()
class-attribute
instance-attribute
¶
Uncle header's parent hash does not correspond to any of existing blocks on chain.
UNKNOWN_PARENT_ZERO = auto()
class-attribute
instance-attribute
¶
Block header's parent hash is zero hash.
GASLIMIT_TOO_BIG = auto()
class-attribute
instance-attribute
¶
Block header's gas limit > 0x7fffffffffffffff.
INVALID_BLOCK_NUMBER = auto()
class-attribute
instance-attribute
¶
Block header's number != parent header's number + 1.
INVALID_BLOCK_TIMESTAMP_OLDER_THAN_PARENT = auto()
class-attribute
instance-attribute
¶
Block header's timestamp <= parent header's timestamp.
INVALID_DIFFICULTY = auto()
class-attribute
instance-attribute
¶
Block header's difficulty does not match the difficulty formula calculated from previous block.
INVALID_LOG_BLOOM = auto()
class-attribute
instance-attribute
¶
Block header's logs bloom hash does not match the actually computed log bloom.
INVALID_STATE_ROOT = auto()
class-attribute
instance-attribute
¶
Block header's state root hash does not match the actually computed hash of the state.
INVALID_RECEIPTS_ROOT = auto()
class-attribute
instance-attribute
¶
Block header's receipts root hash does not match the actually computed hash of receipts.
INVALID_TRANSACTIONS_ROOT = auto()
class-attribute
instance-attribute
¶
Block header's transactions root hash does not match the actually computed hash of tx tree.
INVALID_UNCLES_HASH = auto()
class-attribute
instance-attribute
¶
Block header's uncle hash does not match the actually computed hash of block's uncles.
GAS_USED_OVERFLOW = auto()
class-attribute
instance-attribute
¶
Block transactions consume more gas than block header allow.
INVALID_GASLIMIT = auto()
class-attribute
instance-attribute
¶
Block header's gas limit does not match the gas limit formula calculated from previous block.
INVALID_BASEFEE_PER_GAS = auto()
class-attribute
instance-attribute
¶
Block header's base_fee_per_gas field is calculated incorrect.
INVALID_GAS_USED = auto()
class-attribute
instance-attribute
¶
Block header's actual gas used does not match the provided header's value
INVALID_WITHDRAWALS_ROOT = auto()
class-attribute
instance-attribute
¶
Block header's withdrawals root does not match calculated withdrawals root.
INCORRECT_BLOCK_FORMAT = auto()
class-attribute
instance-attribute
¶
Block's format is incorrect, contains invalid fields, is missing fields, or contains fields of a fork that is not active yet.
BLOB_GAS_USED_ABOVE_LIMIT = auto()
class-attribute
instance-attribute
¶
Block's blob gas used in header is above the limit.
INCORRECT_BLOB_GAS_USED = auto()
class-attribute
instance-attribute
¶
Block's blob gas used in header is incorrect.
INCORRECT_EXCESS_BLOB_GAS = auto()
class-attribute
instance-attribute
¶
Block's excess blob gas in header is incorrect.
RLP_STRUCTURES_ENCODING = auto()
class-attribute
instance-attribute
¶
Block's rlp encoding is valid but ethereum structures in it are invalid.
RLP_WITHDRAWALS_NOT_READ = auto()
class-attribute
instance-attribute
¶
Block's rlp encoding is missing withdrawals.
RLP_INVALID_FIELD_OVERFLOW_64 = auto()
class-attribute
instance-attribute
¶
One of block's fields rlp is overflow 2**64 value.
RLP_INVALID_ADDRESS = auto()
class-attribute
instance-attribute
¶
Block withdrawals address is rlp of invalid address != 20 bytes.
INVALID_REQUESTS = auto()
class-attribute
instance-attribute
¶
Block's requests are invalid.
IMPORT_IMPOSSIBLE_LEGACY = auto()
class-attribute
instance-attribute
¶
Legacy block import is impossible in this chain configuration.
IMPORT_IMPOSSIBLE_LEGACY_WRONG_PARENT = auto()
class-attribute
instance-attribute
¶
Legacy block import is impossible, trying to import on top of a block that is not legacy.
IMPORT_IMPOSSIBLE_LONDON_WRONG_PARENT = auto()
class-attribute
instance-attribute
¶
Trying to import london (basefee) block on top of block that is not 1559.
IMPORT_IMPOSSIBLE_PARIS_WRONG_POW = auto()
class-attribute
instance-attribute
¶
Trying to import paris(merge) block with PoW enabled.
IMPORT_IMPOSSIBLE_PARIS_WRONG_POS = auto()
class-attribute
instance-attribute
¶
Trying to import paris(merge) block with PoS enabled before TTD is reached.
IMPORT_IMPOSSIBLE_LONDON_OVER_PARIS = auto()
class-attribute
instance-attribute
¶
Trying to import london looking block over paris network (POS).
IMPORT_IMPOSSIBLE_PARIS_OVER_SHANGHAI = auto()
class-attribute
instance-attribute
¶
Trying to import paris block on top of shanghai block.
IMPORT_IMPOSSIBLE_SHANGHAI = auto()
class-attribute
instance-attribute
¶
Shanghai block import is impossible in this chain configuration.
IMPORT_IMPOSSIBLE_UNCLES_OVER_PARIS = auto()
class-attribute
instance-attribute
¶
Trying to import a block after paris fork that has not empty uncles hash.
IMPORT_IMPOSSIBLE_DIFFICULTY_OVER_PARIS = auto()
class-attribute
instance-attribute
¶
Trying to import a block after paris fork that has difficulty != 0.
EngineAPIError
¶
Bases: IntEnum
List of Engine API errors.
Source code in src/ethereum_test_exceptions/engine_api.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
EOFException
¶
Bases: ExceptionBase
Exception raised when an EOF container is invalid.
Source code in src/ethereum_test_exceptions/exceptions.py
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 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
|
DEFAULT_EXCEPTION = auto()
class-attribute
instance-attribute
¶
Expect some exception, not yet known.
UNDEFINED_EXCEPTION = auto()
class-attribute
instance-attribute
¶
Indicates that exception string is not mapped to an exception enum.
UNDEFINED_INSTRUCTION = auto()
class-attribute
instance-attribute
¶
EOF container has undefined instruction in it's body code.
UNKNOWN_VERSION = auto()
class-attribute
instance-attribute
¶
EOF container has an unknown version.
INCOMPLETE_MAGIC = auto()
class-attribute
instance-attribute
¶
EOF container has not enough bytes to read magic.
INVALID_MAGIC = auto()
class-attribute
instance-attribute
¶
EOF container has not allowed magic version byte.
INVALID_VERSION = auto()
class-attribute
instance-attribute
¶
EOF container version bytes mismatch.
INVALID_NON_RETURNING_FLAG = auto()
class-attribute
instance-attribute
¶
EOF container's section has non-returning flag set incorrectly.
INVALID_RJUMP_DESTINATION = auto()
class-attribute
instance-attribute
¶
Code has RJUMP instruction with invalid parameters.
MISSING_TYPE_HEADER = auto()
class-attribute
instance-attribute
¶
EOF container missing types section.
INVALID_TYPE_SECTION_SIZE = auto()
class-attribute
instance-attribute
¶
EOF container types section has wrong size.
INVALID_TYPE_BODY = auto()
class-attribute
instance-attribute
¶
EOF container types body section bytes are wrong.
MISSING_CODE_HEADER = auto()
class-attribute
instance-attribute
¶
EOF container missing code section.
INVALID_CODE_SECTION = auto()
class-attribute
instance-attribute
¶
EOF container code section bytes are incorrect.
INCOMPLETE_CODE_HEADER = auto()
class-attribute
instance-attribute
¶
EOF container code header missing bytes.
INCOMPLETE_DATA_HEADER = auto()
class-attribute
instance-attribute
¶
EOF container data header missing bytes.
ZERO_SECTION_SIZE = auto()
class-attribute
instance-attribute
¶
EOF container data header construction is wrong.
MISSING_DATA_SECTION = auto()
class-attribute
instance-attribute
¶
EOF container missing data section
INCOMPLETE_CONTAINER = auto()
class-attribute
instance-attribute
¶
EOF container bytes are incomplete.
INVALID_SECTION_BODIES_SIZE = auto()
class-attribute
instance-attribute
¶
Sections bodies does not match sections headers.
TRAILING_BYTES = auto()
class-attribute
instance-attribute
¶
EOF container has bytes beyond data section.
MISSING_TERMINATOR = auto()
class-attribute
instance-attribute
¶
EOF container missing terminator bytes between header and body.
MISSING_HEADERS_TERMINATOR = auto()
class-attribute
instance-attribute
¶
Some type of another exception about missing headers terminator.
INVALID_FIRST_SECTION_TYPE = auto()
class-attribute
instance-attribute
¶
EOF container header does not have types section first.
INCOMPLETE_SECTION_NUMBER = auto()
class-attribute
instance-attribute
¶
EOF container header has section that is missing declaration bytes.
INCOMPLETE_SECTION_SIZE = auto()
class-attribute
instance-attribute
¶
EOF container header has section that is defined incorrectly.
TOO_MANY_CODE_SECTIONS = auto()
class-attribute
instance-attribute
¶
EOF container header has too many code sections.
MISSING_STOP_OPCODE = auto()
class-attribute
instance-attribute
¶
EOF container's code missing STOP bytecode at it's end.
INPUTS_OUTPUTS_NUM_ABOVE_LIMIT = auto()
class-attribute
instance-attribute
¶
EOF container code section inputs/outputs number is above the limit
UNREACHABLE_INSTRUCTIONS = auto()
class-attribute
instance-attribute
¶
EOF container's code have instructions that are unreachable.
UNREACHABLE_CODE_SECTIONS = auto()
class-attribute
instance-attribute
¶
EOF container's body have code sections that are unreachable.
STACK_UNDERFLOW = auto()
class-attribute
instance-attribute
¶
EOF container's code produces an stack underflow.
STACK_OVERFLOW = auto()
class-attribute
instance-attribute
¶
EOF container's code produces an stack overflow.
STACK_HEIGHT_MISMATCH = auto()
class-attribute
instance-attribute
¶
EOF container section stack height mismatch.
MAX_STACK_HEIGHT_ABOVE_LIMIT = auto()
class-attribute
instance-attribute
¶
EOF container's specified max stack height is above the limit.
STACK_HIGHER_THAN_OUTPUTS = auto()
class-attribute
instance-attribute
¶
EOF container section stack height is higher than the outputs. when returning
JUMPF_DESTINATION_INCOMPATIBLE_OUTPUTS = auto()
class-attribute
instance-attribute
¶
EOF container section JUMPF's to a destination section with incompatible outputs.
INVALID_MAX_STACK_HEIGHT = auto()
class-attribute
instance-attribute
¶
EOF container section's specified max stack height does not match the actual stack height.
INVALID_DATALOADN_INDEX = auto()
class-attribute
instance-attribute
¶
A DATALOADN instruction has out-of-bounds index for the data section.
TRUNCATED_INSTRUCTION = auto()
class-attribute
instance-attribute
¶
EOF container's code section has truncated instruction.
TOPLEVEL_CONTAINER_TRUNCATED = auto()
class-attribute
instance-attribute
¶
Top-level EOF container has data section truncated
ORPHAN_SUBCONTAINER = auto()
class-attribute
instance-attribute
¶
EOF container has an unreferenced subcontainer. '
CONTAINER_SIZE_ABOVE_LIMIT = auto()
class-attribute
instance-attribute
¶
EOF container is above size limit
INVALID_CONTAINER_SECTION_INDEX = auto()
class-attribute
instance-attribute
¶
Instruction references container section that does not exist.
INCOMPATIBLE_CONTAINER_KIND = auto()
class-attribute
instance-attribute
¶
Incompatible instruction found in a container of a specific kind.
TOO_MANY_CONTAINERS = auto()
class-attribute
instance-attribute
¶
EOF container header has too many sub-containers.
INVALID_CODE_SECTION_INDEX = auto()
class-attribute
instance-attribute
¶
CALLF Operation referes to a non-existent code section
UNEXPECTED_HEADER_KIND = auto()
class-attribute
instance-attribute
¶
Header parsing encounterd a section kind it wasn't expecting
CALLF_TO_NON_RETURNING = auto()
class-attribute
instance-attribute
¶
CALLF instruction targeting a non-returning code section
EOFCREATE_WITH_TRUNCATED_CONTAINER = auto()
class-attribute
instance-attribute
¶
EOFCREATE with truncated container
TransactionException
¶
Bases: ExceptionBase
Exception raised when a transaction is invalid, and thus cannot be executed.
If a transaction with any of these exceptions is included in a block, the block is invalid.
Source code in src/ethereum_test_exceptions/exceptions.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 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 363 364 365 366 367 368 369 370 |
|
TYPE_NOT_SUPPORTED = auto()
class-attribute
instance-attribute
¶
Transaction type is not supported on this chain configuration.
SENDER_NOT_EOA = auto()
class-attribute
instance-attribute
¶
Transaction is coming from address that is not exist anymore.
ADDRESS_TOO_SHORT = auto()
class-attribute
instance-attribute
¶
Transaction to
is not allowed to be less than 20 bytes.
ADDRESS_TOO_LONG = auto()
class-attribute
instance-attribute
¶
Transaction to
is not allowed to be more than 20 bytes.
NONCE_MISMATCH_TOO_HIGH = auto()
class-attribute
instance-attribute
¶
Transaction nonce > sender.nonce.
NONCE_MISMATCH_TOO_LOW = auto()
class-attribute
instance-attribute
¶
Transaction nonce < sender.nonce.
NONCE_TOO_BIG = auto()
class-attribute
instance-attribute
¶
Transaction nonce
is not allowed to be max_uint64 - 1 (this is probably TransactionTest).
NONCE_IS_MAX = auto()
class-attribute
instance-attribute
¶
Transaction nonce
is not allowed to be max_uint64 - 1 (this is StateTests).
NONCE_OVERFLOW = auto()
class-attribute
instance-attribute
¶
Transaction nonce
is not allowed to be more than uint64.
GASLIMIT_OVERFLOW = auto()
class-attribute
instance-attribute
¶
Transaction gaslimit exceeds 2^64-1 maximum value.
VALUE_OVERFLOW = auto()
class-attribute
instance-attribute
¶
Transaction value exceeds 2^256-1 maximum value.
GASPRICE_OVERFLOW = auto()
class-attribute
instance-attribute
¶
Transaction gasPrice exceeds 2^256-1 maximum value.
GASLIMIT_PRICE_PRODUCT_OVERFLOW = auto()
class-attribute
instance-attribute
¶
Transaction gasPrice * gasLimit exceeds 2^256-1 maximum value.
INVALID_SIGNATURE_VRS = auto()
class-attribute
instance-attribute
¶
Invalid transaction v, r, s values.
RLP_INVALID_SIGNATURE_R = auto()
class-attribute
instance-attribute
¶
Error reading transaction signature R value.
RLP_INVALID_SIGNATURE_S = auto()
class-attribute
instance-attribute
¶
Error reading transaction signature S value.
RLP_LEADING_ZEROS_GASLIMIT = auto()
class-attribute
instance-attribute
¶
Error reading transaction gaslimit field RLP.
RLP_LEADING_ZEROS_GASPRICE = auto()
class-attribute
instance-attribute
¶
Error reading transaction gasprice field RLP.
RLP_LEADING_ZEROS_VALUE = auto()
class-attribute
instance-attribute
¶
Error reading transaction value field RLP.
RLP_LEADING_ZEROS_NONCE = auto()
class-attribute
instance-attribute
¶
Error reading transaction nonce field RLP.
RLP_LEADING_ZEROS_R = auto()
class-attribute
instance-attribute
¶
Error reading transaction signature R field RLP.
RLP_LEADING_ZEROS_S = auto()
class-attribute
instance-attribute
¶
Error reading transaction signature S field RLP.
RLP_LEADING_ZEROS_V = auto()
class-attribute
instance-attribute
¶
Error reading transaction signature V field RLP.
RLP_LEADING_ZEROS_BASEFEE = auto()
class-attribute
instance-attribute
¶
Error reading transaction basefee field RLP.
RLP_LEADING_ZEROS_PRIORITY_FEE = auto()
class-attribute
instance-attribute
¶
Error reading transaction priority fee field RLP.
RLP_LEADING_ZEROS_DATA_SIZE = auto()
class-attribute
instance-attribute
¶
Error reading transaction data field RLP, (rlp field length has leading zeros).
RLP_LEADING_ZEROS_NONCE_SIZE = auto()
class-attribute
instance-attribute
¶
Error reading transaction nonce field RLP, (rlp field length has leading zeros).
RLP_TOO_FEW_ELEMENTS = auto()
class-attribute
instance-attribute
¶
Error reading transaction RLP, structure has too few elements than expected.
RLP_TOO_MANY_ELEMENTS = auto()
class-attribute
instance-attribute
¶
Error reading transaction RLP, structure has too many elements than expected.
RLP_ERROR_EOF = auto()
class-attribute
instance-attribute
¶
Error reading transaction RLP, rlp stream unexpectedly finished.
RLP_ERROR_SIZE = auto()
class-attribute
instance-attribute
¶
Error reading transaction RLP, rlp size is invalid.
RLP_ERROR_SIZE_LEADING_ZEROS = auto()
class-attribute
instance-attribute
¶
Error reading transaction RLP, field size has leading zeros.
INVALID_CHAINID = auto()
class-attribute
instance-attribute
¶
Transaction chain id encoding is incorrect.
RLP_INVALID_DATA = auto()
class-attribute
instance-attribute
¶
Transaction data field is invalid rlp.
RLP_INVALID_GASLIMIT = auto()
class-attribute
instance-attribute
¶
Transaction gaslimit field is invalid rlp.
RLP_INVALID_NONCE = auto()
class-attribute
instance-attribute
¶
Transaction nonce field is invalid rlp.
RLP_INVALID_TO = auto()
class-attribute
instance-attribute
¶
Transaction to field is invalid rlp.
RLP_INVALID_ACCESS_LIST_ADDRESS_TOO_LONG = auto()
class-attribute
instance-attribute
¶
Transaction access list address is > 20 bytes.
RLP_INVALID_ACCESS_LIST_ADDRESS_TOO_SHORT = auto()
class-attribute
instance-attribute
¶
Transaction access list address is < 20 bytes.
RLP_INVALID_ACCESS_LIST_STORAGE_TOO_LONG = auto()
class-attribute
instance-attribute
¶
Transaction access list storage hash > 32 bytes.
RLP_INVALID_ACCESS_LIST_STORAGE_TOO_SHORT = auto()
class-attribute
instance-attribute
¶
Transaction access list storage hash < 32 bytes.
RLP_INVALID_HEADER = auto()
class-attribute
instance-attribute
¶
Transaction failed to read from RLP as rlp header is invalid.
RLP_INVALID_VALUE = auto()
class-attribute
instance-attribute
¶
Transaction value field is invalid rlp/structure.
EC_RECOVERY_FAIL = auto()
class-attribute
instance-attribute
¶
Transaction has correct signature, but ec recovery failed.
INSUFFICIENT_ACCOUNT_FUNDS = auto()
class-attribute
instance-attribute
¶
Transaction's sender does not have enough funds to pay for the transaction.
INSUFFICIENT_MAX_FEE_PER_GAS = auto()
class-attribute
instance-attribute
¶
Transaction's max-fee-per-gas is lower than the block base-fee.
PRIORITY_OVERFLOW = auto()
class-attribute
instance-attribute
¶
Transaction's max-priority-fee-per-gas is exceeds 2^256-1 maximum value.
PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS = auto()
class-attribute
instance-attribute
¶
Transaction's max-priority-fee-per-gas is greater than the max-fee-per-gas.
PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS_2 = auto()
class-attribute
instance-attribute
¶
Transaction's max-priority-fee-per-gas is greater than the max-fee-per-gas (TransactionTests).
INSUFFICIENT_MAX_FEE_PER_BLOB_GAS = auto()
class-attribute
instance-attribute
¶
Transaction's max-fee-per-blob-gas is lower than the block's blob-gas price.
INTRINSIC_GAS_TOO_LOW = auto()
class-attribute
instance-attribute
¶
Transaction's gas limit is too low.
INITCODE_SIZE_EXCEEDED = auto()
class-attribute
instance-attribute
¶
Transaction's initcode for a contract-creating transaction is too large.
TYPE_3_TX_PRE_FORK = auto()
class-attribute
instance-attribute
¶
Transaction type 3 included before activation fork.
TYPE_3_TX_ZERO_BLOBS_PRE_FORK = auto()
class-attribute
instance-attribute
¶
Transaction type 3, with zero blobs, included before activation fork.
TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH = auto()
class-attribute
instance-attribute
¶
Transaction contains a blob versioned hash with an invalid version.
TYPE_3_TX_WITH_FULL_BLOBS = auto()
class-attribute
instance-attribute
¶
Transaction contains full blobs (network-version of the transaction).
TYPE_3_TX_BLOB_COUNT_EXCEEDED = auto()
class-attribute
instance-attribute
¶
Transaction contains too many blob versioned hashes.
TYPE_3_TX_CONTRACT_CREATION = auto()
class-attribute
instance-attribute
¶
Transaction is a type 3 transaction and has an empty to
.
TYPE_3_TX_MAX_BLOB_GAS_ALLOWANCE_EXCEEDED = auto()
class-attribute
instance-attribute
¶
Transaction causes block to go over blob gas limit.
GAS_ALLOWANCE_EXCEEDED = auto()
class-attribute
instance-attribute
¶
Transaction causes block to go over blob gas limit.
TYPE_3_TX_ZERO_BLOBS = auto()
class-attribute
instance-attribute
¶
Transaction is type 3, but has no blobs.
TYPE_4_EMPTY_AUTHORIZATION_LIST = auto()
class-attribute
instance-attribute
¶
Transaction is type 4, but has an empty authorization list.
TYPE_4_INVALID_AUTHORITY_SIGNATURE = auto()
class-attribute
instance-attribute
¶
Transaction authority signature is invalid
TYPE_4_INVALID_AUTHORITY_SIGNATURE_S_TOO_HIGH = auto()
class-attribute
instance-attribute
¶
Transaction authority signature is invalid
TYPE_4_TX_CONTRACT_CREATION = auto()
class-attribute
instance-attribute
¶
Transaction is a type 4 transaction and has an empty to
.
TYPE_4_INVALID_AUTHORIZATION_FORMAT = auto()
class-attribute
instance-attribute
¶
Transaction is type 4, but contains an authorization that has an invalid format.
BaseFixture
¶
Bases: CamelModel
Represents a base Ethereum test fixture of any type.
Source code in src/ethereum_test_fixtures/base.py
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 |
|
output_base_dir_name()
classmethod
¶
Return name of the subdirectory where this type of fixture should be dumped to.
Source code in src/ethereum_test_fixtures/base.py
53 54 55 56 |
|
__pydantic_init_subclass__(**kwargs)
classmethod
¶
Register all subclasses of BaseFixture with a fixture format name set as possible fixture formats.
Source code in src/ethereum_test_fixtures/base.py
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 |
|
json_dict: Dict[str, Any]
cached
property
¶
Returns the JSON representation of the fixture.
hash: str
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 src/ethereum_test_fixtures/base.py
105 106 107 108 109 110 111 |
|
fill_info(t8n_version, test_case_description, fixture_source_url, ref_spec, _info_metadata)
¶
Fill the info field for this fixture.
Source code in src/ethereum_test_fixtures/base.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
get_fork()
¶
Return fork of the fixture as a string.
Source code in src/ethereum_test_fixtures/base.py
133 134 135 |
|
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 src/ethereum_test_fixtures/base.py
137 138 139 140 141 142 143 144 |
|
FixtureCollector
dataclass
¶
Collects all fixtures generated by the test cases.
Source code in src/ethereum_test_fixtures/collector.py
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 |
|
get_fixture_basename(info)
¶
Return basename of the fixture file for a given test case.
Source code in src/ethereum_test_fixtures/collector.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
add_fixture(info, fixture)
¶
Add fixture to the list of fixtures of a given test case.
Source code in src/ethereum_test_fixtures/collector.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
dump_fixtures()
¶
Dump all collected fixtures to their respective files.
Source code in src/ethereum_test_fixtures/collector.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
verify_fixture_files(evm_fixture_verification)
¶
Run evm [state|block]test
on each fixture.
Source code in src/ethereum_test_fixtures/collector.py
157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
TestInfo
dataclass
¶
Contains test information from the current node.
Source code in src/ethereum_test_fixtures/collector.py
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 |
|
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 src/ethereum_test_fixtures/collector.py
56 57 58 59 60 61 62 63 64 65 |
|
get_single_test_name()
¶
Convert test name to a single test name.
Source code in src/ethereum_test_fixtures/collector.py
67 68 69 70 |
|
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 src/ethereum_test_fixtures/collector.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
BaseTest
¶
Bases: BaseModel
Represents a base Ethereum test which must return a single test fixture.
Source code in src/ethereum_test_specs/base.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 |
|
discard_fixture_format_by_marks(fixture_format, fork, markers)
classmethod
¶
Discard a fixture format from filling if the appropriate marker is used.
Source code in src/ethereum_test_specs/base.py
59 60 61 62 63 64 65 66 67 |
|
discard_execute_format_by_marks(execute_format, fork, markers)
classmethod
¶
Discard an execute format from executing if the appropriate marker is used.
Source code in src/ethereum_test_specs/base.py
69 70 71 72 73 74 75 76 77 |
|
generate(*, request, t8n, fork, fixture_format, eips=None)
abstractmethod
¶
Generate the list of test fixtures.
Source code in src/ethereum_test_specs/base.py
79 80 81 82 83 84 85 86 87 88 89 90 |
|
execute(*, fork, execute_format, eips=None)
¶
Generate the list of test fixtures.
Source code in src/ethereum_test_specs/base.py
92 93 94 95 96 97 98 99 100 |
|
pytest_parameter_name()
classmethod
¶
Must return the name of the parameter used in pytest to select this spec type as filler for the test.
By default, it returns the underscore separated name of the class.
Source code in src/ethereum_test_specs/base.py
102 103 104 105 106 107 108 109 110 |
|
get_next_transition_tool_output_path()
¶
Return path to the next transition tool output file.
Source code in src/ethereum_test_specs/base.py
112 113 114 115 116 117 118 119 |
|
BlockchainTest
¶
Bases: BaseTest
Filler type that tests multiple blocks (valid or invalid) in a chain.
Source code in src/ethereum_test_specs/blockchain.py
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 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 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 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
|
discard_fixture_format_by_marks(fixture_format, fork, markers)
classmethod
¶
Discard a fixture format from filling if the appropriate marker is used.
Source code in src/ethereum_test_specs/blockchain.py
309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
make_genesis(genesis_environment, pre, fork)
staticmethod
¶
Create a genesis block from the blockchain test definition.
Source code in src/ethereum_test_specs/blockchain.py
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 |
|
generate_block_data(t8n, fork, block, previous_env, previous_alloc, eips=None, slow=False)
¶
Generate common block data for both make_fixture and make_hive_fixture.
Source code in src/ethereum_test_specs/blockchain.py
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 |
|
network_info(fork, eips=None)
staticmethod
¶
Return fixture network information for the fork & EIP/s.
Source code in src/ethereum_test_specs/blockchain.py
510 511 512 513 514 515 516 517 |
|
verify_post_state(t8n, t8n_state, expected_state=None)
¶
Verify post alloc after all block/s or payload/s are generated.
Source code in src/ethereum_test_specs/blockchain.py
519 520 521 522 523 524 525 526 527 528 |
|
make_fixture(t8n, fork, eips=None, slow=False)
¶
Create a fixture from the blockchain test definition.
Source code in src/ethereum_test_specs/blockchain.py
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 |
|
make_hive_fixture(t8n, fork, eips=None, slow=False)
¶
Create a hive fixture from the blocktest definition.
Source code in src/ethereum_test_specs/blockchain.py
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 |
|
generate(request, t8n, fork, fixture_format, eips=None)
¶
Generate the BlockchainTest fixture.
Source code in src/ethereum_test_specs/blockchain.py
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 |
|
execute(*, fork, execute_format, eips=None)
¶
Generate the list of test fixtures.
Source code in src/ethereum_test_specs/blockchain.py
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
|
EOFStateTest
¶
Bases: EOFTest
, Transaction
Filler type that generates an EOF test for container validation, and also tests the container during runtime using a state test (and blockchain test).
In the state or blockchain test, the container is first deployed to the pre-allocation and then a transaction is sent to the deployed container.
Container deployment/validation is not tested like in the EOFTest
unless the container
under test is an initcode container.
All fields from ethereum_test_types.Transaction
are available for use in the test.
Source code in src/ethereum_test_specs/eof.py
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 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 |
|
gas_limit: HexNumber = Field(HexNumber(10000000), serialization_alias='gas')
class-attribute
instance-attribute
¶
Gas limit for the transaction that deploys the container.
tx_sender_funding_amount: int = 1000000000000000000000
class-attribute
instance-attribute
¶
Amount of funds to send to the sender EOA before the transaction.
env: Environment = Field(default_factory=Environment)
class-attribute
instance-attribute
¶
Environment object that is used during State Test generation.
container_post: Account = Field(default_factory=Account)
class-attribute
instance-attribute
¶
Account object used to verify the container post state.
pytest_parameter_name()
classmethod
¶
Workaround for pytest parameter name.
Source code in src/ethereum_test_specs/eof.py
534 535 536 537 |
|
model_post_init(__context)
¶
Prepare the transaction parameters required to fill the test.
Source code in src/ethereum_test_specs/eof.py
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 |
|
generate_state_test(fork)
¶
Generate the StateTest filler.
Source code in src/ethereum_test_specs/eof.py
577 578 579 580 581 582 583 584 585 586 587 588 |
|
generate(*, request, t8n, fork, eips=None, fixture_format, **_)
¶
Generate the BlockchainTest fixture.
Source code in src/ethereum_test_specs/eof.py
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
|
EOFTest
¶
Bases: BaseTest
Filler type that generates a test for EOF container validation.
A state test is also automatically generated where the container is wrapped in a contract-creating transaction to test deployment/validation on the instantiated blockchain.
Source code in src/ethereum_test_specs/eof.py
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 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 |
|
container: Container
instance-attribute
¶
EOF container that will be tested for validity.
The only supported type at the moment is ethereum_test_types.eof.v1.Container
.
If an invalid container needs to be tested, and it cannot be generated using the
Container class features, the raw_bytes
field can be used to provide the raw
container bytes.
expect_exception: EOFExceptionInstanceOrList | None = None
class-attribute
instance-attribute
¶
Expected exception that the container should raise when parsed by an EOF parser.
Can be a single exception or a list of exceptions that the container is expected to raise, in which case the test will pass if any of the exceptions are raised.
The list of supported exceptions can be found in the ethereum_test_exceptions.EOFException
class.
container_kind: ContainerKind = ContainerKind.RUNTIME
class-attribute
instance-attribute
¶
Container kind type that the container should be treated as.
The container kind can be one of the following:
- ContainerKind.INITCODE
: The container is an initcode container.
- ContainerKind.RUNTIME
: The container is a runtime container.
The default value is ContainerKind.RUNTIME
.
deployed_container: Container | None = None
class-attribute
instance-attribute
¶
To be used when the container is an initcode container and the expected deployed container is known.
The value is only used when a State Test is generated from this EOF test to set the expected deployed container that should be found in the post state.
If this field is not set, and the container is valid:
- If the container kind is ContainerKind.RUNTIME
, the deployed container is assumed to be
the container itself, and an initcode container that wraps the container is generated
automatically.
- If the container kind is ContainerKind.INITCODE
, model_post_init
will attempt to infer
the deployed container from the sections of the init-container, and the first
container-type section will be used. An error will be raised if the deployed container
cannot be inferred.
If the value is set to None
, it is assumed that the container is invalid and the test will
expect that no contract is created.
It is considered an error if
- The
deployed_container
field is set and thecontainer_kind
field is not set toContainerKind.INITCODE
. - The
deployed_container
field is set and theexpect_exception
is notNone
.
The deployed container is not executed at any point during the EOF validation test nor
the generated State Test. For container runtime testing use the EOFStateTest
class.
pre: Alloc | None = None
class-attribute
instance-attribute
¶
Pre alloc object that is used during State Test generation.
This field is automatically set by the test filler when generating a State Test from this EOF test and should otherwise be left unset.
post: Alloc | None = None
class-attribute
instance-attribute
¶
Post alloc object that is used during State Test generation.
This field is automatically set by the test filler when generating a State Test from this EOF test and is normally not set by the user.
sender: EOA | None = None
class-attribute
instance-attribute
¶
Sender EOA object that is used during State Test generation.
This field is automatically set by the model_post_init
method and should otherwise be left
unset.
discard_fixture_format_by_marks(fixture_format, fork, markers)
classmethod
¶
Discard a fixture format from filling if the appropriate marker is used.
Source code in src/ethereum_test_specs/eof.py
255 256 257 258 259 260 261 262 263 264 265 |
|
pytest_parameter_name()
classmethod
¶
Workaround for pytest parameter name.
Source code in src/ethereum_test_specs/eof.py
267 268 269 270 |
|
model_post_init(__context)
¶
Prepare the test exception based on the container.
Source code in src/ethereum_test_specs/eof.py
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 |
|
make_eof_test_fixture(*, request, fork, eips)
¶
Generate the EOF test fixture.
Source code in src/ethereum_test_specs/eof.py
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 |
|
verify_result(result, expected_result, code)
¶
Check that the reported exception string matches the expected error.
Source code in src/ethereum_test_specs/eof.py
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 |
|
generate_eof_contract_create_transaction()
¶
Generate a transaction that creates a contract.
Source code in src/ethereum_test_specs/eof.py
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 |
|
generate_state_test(fork)
¶
Generate the StateTest filler.
Source code in src/ethereum_test_specs/eof.py
437 438 439 440 441 442 443 444 445 |
|
generate(*, request, t8n, fork, eips=None, fixture_format, **_)
¶
Generate the BlockchainTest fixture.
Source code in src/ethereum_test_specs/eof.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
execute(*, fork, execute_format, eips=None)
¶
Generate the list of test fixtures.
Source code in src/ethereum_test_specs/eof.py
466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
StateTest
¶
Bases: BaseTest
Filler type that tests transactions over the period of a single block.
Source code in src/ethereum_test_specs/state.py
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 |
|
discard_fixture_format_by_marks(fixture_format, fork, markers)
classmethod
¶
Discard a fixture format from filling if the appropriate marker is used.
Source code in src/ethereum_test_specs/state.py
68 69 70 71 72 73 74 75 76 77 78 |
|
generate_blockchain_test(*, fork)
¶
Generate a BlockchainTest fixture from this StateTest fixture.
Source code in src/ethereum_test_specs/state.py
125 126 127 128 129 130 131 132 133 |
|
make_state_test_fixture(t8n, fork, eips=None, slow=False)
¶
Create a fixture from the state test definition.
Source code in src/ethereum_test_specs/state.py
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 |
|
generate(request, t8n, fork, fixture_format, eips=None)
¶
Generate the BlockchainTest fixture.
Source code in src/ethereum_test_specs/state.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
execute(*, fork, execute_format, eips=None)
¶
Generate the list of test fixtures.
Source code in src/ethereum_test_specs/state.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
TransactionTest
¶
Bases: BaseTest
Filler type that tests the transaction over the period of a single block.
Source code in src/ethereum_test_specs/transaction.py
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 |
|
make_transaction_test_fixture(fork, eips=None)
¶
Create a fixture from the transaction test definition.
Source code in src/ethereum_test_specs/transaction.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 |
|
generate(request, t8n, fork, fixture_format, eips=None)
¶
Generate the TransactionTest fixture.
Source code in src/ethereum_test_specs/transaction.py
75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
execute(*, fork, execute_format, eips=None)
¶
Execute the transaction test by sending it to the live network.
Source code in src/ethereum_test_specs/transaction.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
Block
¶
Bases: Header
Block type used to describe block properties in test specs.
Source code in src/ethereum_test_specs/blockchain.py
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 |
|
rlp: Bytes | None = 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: Header | None = None
class-attribute
instance-attribute
¶
If set, the block header will be verified against the specified values.
rlp_modifier: Header | None = None
class-attribute
instance-attribute
¶
An RLP modifying header which values would be used to override the ones
returned by the ethereum_clis.TransitionTool
.
exception: List[TransactionException | BlockException] | TransactionException | BlockException | None = None
class-attribute
instance-attribute
¶
If set, the block is expected to be rejected by the client.
engine_api_error_code: EngineAPIError | None = None
class-attribute
instance-attribute
¶
If set, the block is expected to produce an error response from the Engine API.
txs: List[Transaction] = Field(default_factory=list)
class-attribute
instance-attribute
¶
List of transactions included in the block.
ommers: List[Header] | None = None
class-attribute
instance-attribute
¶
List of ommer headers included in the block.
withdrawals: List[Withdrawal] | None = None
class-attribute
instance-attribute
¶
List of withdrawals to perform for this block.
requests: List[Bytes] | None = None
class-attribute
instance-attribute
¶
Custom list of requests to embed in this block.
expected_post_state: Alloc | None = None
class-attribute
instance-attribute
¶
Post state for verification after block execution in BlockchainTest
set_environment(env)
¶
Create copy of the environment with the characteristics of this specific block.
Source code in src/ethereum_test_specs/blockchain.py
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 |
|
Header
¶
Bases: CamelModel
Header type used to describe block header properties in test specs.
Source code in src/ethereum_test_specs/blockchain.py
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 |
|
REMOVE_FIELD: Removable = Removable()
class-attribute
¶
Sentinel object used to specify that a header field should be removed.
EMPTY_FIELD: Removable = Removable()
class-attribute
¶
Sentinel object used to specify that a header field must be empty during verification.
This can be used in a test to explicitly skip a field in a block's RLP encoding. included in the (json) output when the model is serialized. For example:
header_modifier = Header(
excess_blob_gas=Header.REMOVE_FIELD,
)
block = Block(
timestamp=TIMESTAMP,
rlp_modifier=header_modifier,
exception=BlockException.INCORRECT_BLOCK_FORMAT,
engine_api_error_code=EngineAPIError.InvalidParams,
)
validate_withdrawals_root(value)
classmethod
¶
Convert a list of withdrawals into the withdrawals root hash.
Source code in src/ethereum_test_specs/blockchain.py
151 152 153 154 155 156 157 |
|
apply(target)
¶
Produce a fixture header copy with the set values from the modifier.
Source code in src/ethereum_test_specs/blockchain.py
159 160 161 162 163 164 165 166 |
|
verify(target)
¶
Verify that the header fields from self are as expected.
Source code in src/ethereum_test_specs/blockchain.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
CalldataCase
¶
Bases: Case
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
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|
__init__(value, position=0, **kwargs)
¶
Generate the condition base on value
and position
.
Source code in src/ethereum_test_tools/code/generators.py
269 270 271 272 |
|
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
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
is_terminating: bool
property
¶
Returns whether the case is terminating.
CodeGasMeasure
¶
Bases: Bytecode
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
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 |
|
code: Bytecode
instance-attribute
¶
Bytecode to be executed to measure the gas usage.
overhead_cost: int
instance-attribute
¶
Extra gas cost to be subtracted from extra operations.
extra_stack_items: int
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
instance-attribute
¶
Storage key to save the gas used.
__new__(*, code, overhead_cost=0, extra_stack_items=0, sstore_key=0, stop=True)
¶
Assemble the bytecode that measures gas usage.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
Conditional
¶
Bases: Bytecode
Helper class used to generate conditional bytecode.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
__new__(*, condition, if_true=None, if_false=None, evm_code_type=EVMCodeType.LEGACY)
¶
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
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 |
|
Initcode
¶
Bases: Bytecode
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
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 |
|
deploy_code: SupportsBytes | Bytes
instance-attribute
¶
Bytecode to be deployed by the initcode.
execution_gas: int
instance-attribute
¶
Gas cost of executing the initcode, without considering deployment gas costs.
deployment_gas: int
instance-attribute
¶
Gas cost of deploying the cost, subtracted after initcode execution,
__new__(*, deploy_code=None, initcode_length=None, initcode_prefix=None, initcode_prefix_execution_gas=0, padding_byte=0, name='')
¶
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
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 |
|
Switch
¶
Bases: Bytecode
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
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 |
|
default_action: Bytecode | Op | None
instance-attribute
¶
The default bytecode to execute; if no condition is met, this bytecode is executed.
cases: List[Case]
instance-attribute
¶
A list of Cases: The first element with a condition that evaluates to a non-zero value is the one that is executed.
evm_code_type: EVMCodeType
instance-attribute
¶
The EVM code type to use for the switch-case bytecode.
__new__(*, default_action=None, cases, evm_code_type=EVMCodeType.LEGACY)
¶
Assemble the bytecode by looping over the list of cases and adding the necessary [R]JUMPI and JUMPDEST opcodes in order to replicate switch-case behavior.
Source code in src/ethereum_test_tools/code/generators.py
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 |
|
Yul
¶
Bases: Bytecode
Yul compiler. Compiles Yul source code into bytecode.
Source code in src/ethereum_test_tools/code/yul.py
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 |
|
__new__(source, fork=None, binary=None)
¶
Compile Yul source code into bytecode.
Source code in src/ethereum_test_tools/code/yul.py
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 |
|
DeploymentTestType
¶
Bases: Enum
Represents the type of deployment test.
Source code in src/ethereum_test_tools/utility/generators.py
17 18 19 20 21 |
|
generate_system_contract_deploy_test(*, fork, tx_json_path, expected_deploy_address, expected_system_contract_storage=None)
¶
Generate a test that verifies the correct deployment of a system contract.
Generates four test cases:
| before/after fork | has balance |
------------------------------------|-------------------|-------------|
deploy_before_fork-nonzero_balance
| before | True |
deploy_before_fork-zero_balance
| before | False |
deploy_after_fork-nonzero_balance
| after | True |
deploy_after_fork-zero_balance
| after | False |
where has balance
refers to whether the contract address has a non-zero balance before
deployment, or not.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fork |
Fork
|
The fork to test. |
required |
tx_json_path |
Path
|
Path to the JSON file with the transaction to deploy the system contract. Providing a JSON file is useful to copy-paste the transaction from the EIP. |
required |
expected_deploy_address |
Address
|
The expected address of the deployed contract. |
required |
expected_system_contract_storage |
Dict | None
|
The expected storage of the system contract. |
None
|
Source code in src/ethereum_test_tools/utility/generators.py
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 |
|
extend_with_defaults(defaults, cases, **parametrize_kwargs)
¶
Extend test cases with default parameter values.
This utility function extends test case parameters by adding default values
from the defaults
dictionary to each case in the cases
list. If a case
already specifies a value for a parameter, its default is ignored.
This function is particularly useful in scenarios where you want to define a common set of default values but allow individual test cases to override them as needed.
The function returns a dictionary that can be directly unpacked and passed
to the @pytest.mark.parametrize
decorator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
defaults |
Dict[str, Any]
|
A dictionary of default parameter names and their values. These values will be added to each case unless the case already defines a value for each parameter. |
required |
cases |
List[ParameterSet]
|
A list of |
required |
parametrize_kwargs |
Any
|
Additional keyword arguments to be passed to
|
{}
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: A dictionary with the following structure:
|
Example
@pytest.mark.parametrize(**extend_with_defaults(
defaults=dict(
min_value=0, # default minimum value is 0
max_value=100, # default maximum value is 100
average=50, # default average value is 50
),
cases=[
pytest.param(
dict(), # use default values
id='default_case',
),
pytest.param(
dict(min_value=10), # override with min_value=10
id='min_value_10',
),
pytest.param(
dict(max_value=200), # override with max_value=200
id='max_value_200',
),
pytest.param(
dict(min_value=-10, max_value=50), # override both min_value
# and max_value
id='min_-10_max_50',
),
pytest.param(
dict(min_value=20, max_value=80, average=50), # all defaults
# are overridden
id="min_20_max_80_avg_50",
),
pytest.param(
dict(min_value=100, max_value=0), # invalid range
id='invalid_range',
marks=pytest.mark.xfail(reason='invalid range'),
)
],
))
def test_range(min_value, max_value, average):
assert min_value <= max_value
assert min_value <= average <= max_value
The above test will execute with the following sets of parameters:
"default_case": {"min_value": 0, "max_value": 100, "average": 50}
"min_value_10": {"min_value": 10, "max_value": 100, "average": 50}
"max_value_200": {"min_value": 0, "max_value": 200, "average": 50}
"min_-10_max_50": {"min_value": -10, "max_value": 50, "average": 50}
"min_20_max_80_avg_50": {"min_value": 20, "max_value": 80, "average": 50}
"invalid_range": {"min_value": 100, "max_value": 0, "average": 50} # expected to fail
Notes
- Each case in
cases
must contain exactly one value, which is a dictionary of parameter values. - The function performs an in-place update of the
cases
list, so the originalcases
list is modified.
Source code in src/ethereum_test_tools/utility/pytest.py
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 |
|