-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new(tests): Add EIP-7702 folder, first test
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
""" | ||
Cross-client EIP-7702 Tests | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Defines EIP-7702 specification constants and functions. | ||
""" | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass(frozen=True) | ||
class ReferenceSpec: | ||
""" | ||
Defines the reference spec version and git path. | ||
""" | ||
|
||
git_path: str | ||
version: str | ||
|
||
|
||
ref_spec_7702 = ReferenceSpec("EIPS/eip-7702.md", "7357ff1f3f176aada6d350d6e42a292a3dec27f4") | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Spec: | ||
""" | ||
Parameters from the EIP-7702 specifications as defined at | ||
https://eips.ethereum.org/EIPS/eip-7702 | ||
""" | ||
|
||
SET_CODE_TX_TYPE = 0x04 | ||
MAGIC = 0x05 | ||
PER_AUTH_BASE_COST = 2500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
abstract: Tests use of set-code transactions from [EIP-7702: Set EOA account code for one transaction](https://eips.ethereum.org/EIPS/eip-7702) | ||
Tests use of set-code transactions from [EIP-7702: Set EOA account code for one transaction](https://eips.ethereum.org/EIPS/eip-7702). | ||
""" # noqa: E501 | ||
|
||
import pytest | ||
|
||
from ethereum_test_tools import Alloc, AuthorizationTuple, Environment | ||
from ethereum_test_tools import Opcodes as Op | ||
from ethereum_test_tools import StateTestFiller, Transaction | ||
|
||
from .spec import ref_spec_7702 | ||
|
||
REFERENCE_SPEC_GIT_PATH = ref_spec_7702.git_path | ||
REFERENCE_SPEC_VERSION = ref_spec_7702.version | ||
|
||
pytestmark = [ | ||
pytest.mark.valid_from("Prague"), | ||
] | ||
|
||
|
||
def test_set_code_to_self_destruct( | ||
state_test: StateTestFiller, | ||
pre: Alloc, | ||
): | ||
""" | ||
Test the executing self-destruct opcode in a set-code transaction. | ||
""" | ||
set_code_to_address = pre.deploy_contract(Op.SELFDESTRUCT(Op.ADDRESS)) | ||
|
||
signer = pre.fund_eoa(0) | ||
|
||
sender = pre.fund_eoa(10**18) | ||
|
||
tx = Transaction( | ||
gas_limit=1_000_000, | ||
to=sender, | ||
value=0, | ||
authorization_tuples=[ | ||
AuthorizationTuple( | ||
chain_id=1, | ||
address=set_code_to_address, | ||
nonce=0, | ||
signer=signer, | ||
), | ||
], | ||
sender=sender, | ||
) | ||
|
||
state_test( | ||
env=Environment(), | ||
pre=pre, | ||
tx=tx, | ||
post={}, | ||
) |