File tree Expand file tree Collapse file tree 3 files changed +87
-0
lines changed
tests/prague/eip7702_eoa_code_tx Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Cross-client EIP-7702 Tests
3+ """
Original file line number Diff line number Diff line change 1+ """
2+ Defines EIP-7702 specification constants and functions.
3+ """
4+ from dataclasses import dataclass
5+
6+
7+ @dataclass (frozen = True )
8+ class ReferenceSpec :
9+ """
10+ Defines the reference spec version and git path.
11+ """
12+
13+ git_path : str
14+ version : str
15+
16+
17+ ref_spec_7702 = ReferenceSpec ("EIPS/eip-7702.md" , "7357ff1f3f176aada6d350d6e42a292a3dec27f4" )
18+
19+
20+ @dataclass (frozen = True )
21+ class Spec :
22+ """
23+ Parameters from the EIP-7702 specifications as defined at
24+ https://eips.ethereum.org/EIPS/eip-7702
25+ """
26+
27+ SET_CODE_TX_TYPE = 0x04
28+ MAGIC = 0x05
29+ PER_AUTH_BASE_COST = 2500
Original file line number Diff line number Diff line change 1+ """
2+ abstract: Tests use of set-code transactions from [EIP-7702: Set EOA account code for one transaction](https://eips.ethereum.org/EIPS/eip-7702)
3+ Tests use of set-code transactions from [EIP-7702: Set EOA account code for one transaction](https://eips.ethereum.org/EIPS/eip-7702).
4+ """ # noqa: E501
5+
6+ import pytest
7+
8+ from ethereum_test_tools import Alloc , AuthorizationTuple , Environment
9+ from ethereum_test_tools import Opcodes as Op
10+ from ethereum_test_tools import StateTestFiller , Transaction
11+
12+ from .spec import ref_spec_7702
13+
14+ REFERENCE_SPEC_GIT_PATH = ref_spec_7702 .git_path
15+ REFERENCE_SPEC_VERSION = ref_spec_7702 .version
16+
17+ pytestmark = [
18+ pytest .mark .valid_from ("Prague" ),
19+ ]
20+
21+
22+ def test_set_code_to_self_destruct (
23+ state_test : StateTestFiller ,
24+ pre : Alloc ,
25+ ):
26+ """
27+ Test the executing self-destruct opcode in a set-code transaction.
28+ """
29+ set_code_to_address = pre .deploy_contract (Op .SELFDESTRUCT (Op .ADDRESS ))
30+
31+ signer = pre .fund_eoa (0 )
32+
33+ sender = pre .fund_eoa (10 ** 18 )
34+
35+ tx = Transaction (
36+ gas_limit = 1_000_000 ,
37+ to = sender ,
38+ value = 0 ,
39+ authorization_tuples = [
40+ AuthorizationTuple (
41+ chain_id = 1 ,
42+ address = set_code_to_address ,
43+ nonce = 0 ,
44+ signer = signer ,
45+ ),
46+ ],
47+ sender = sender ,
48+ )
49+
50+ state_test (
51+ env = Environment (),
52+ pre = pre ,
53+ tx = tx ,
54+ post = {},
55+ )
You can’t perform that action at this time.
0 commit comments