Skip to content

Commit fa21f39

Browse files
committed
chore(ruff): changes to tests/frontier/.
1 parent b677afb commit fa21f39

File tree

6 files changed

+24
-31
lines changed

6 files changed

+24
-31
lines changed

tests/frontier/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
"""
2-
Test cases for EVM functionality introduced in Frontier.
3-
"""
1+
"""Test cases for EVM functionality introduced in Frontier."""

tests/frontier/opcodes/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
"""
2-
Test for opcodes introduced in Frontier.
3-
"""
1+
"""Test for opcodes introduced in Frontier."""

tests/frontier/opcodes/test_all_opcodes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
StateTestFiller,
1818
Transaction,
1919
)
20-
from ethereum_test_tools.vm.opcode import Opcode
20+
from ethereum_test_tools.vm.opcode import Opcode, UndefinedOpcodes
2121
from ethereum_test_tools.vm.opcode import Opcodes as Op
22-
from ethereum_test_tools.vm.opcode import UndefinedOpcodes
2322

2423
REFERENCE_SPEC_GIT_PATH = "N/A"
2524
REFERENCE_SPEC_VERSION = "N/A"
2625

2726

2827
def prepare_stack(opcode: Opcode) -> Bytecode:
29-
"""Prepare valid stack for opcode"""
28+
"""Prepare valid stack for opcode."""
3029
if opcode == Op.CREATE:
3130
return Op.MSTORE(0, 0x6001600155) + Op.PUSH1(5) + Op.PUSH1(27) + Op.PUSH1(5)
3231
if opcode == Op.CREATE2:
@@ -39,7 +38,7 @@ def prepare_stack(opcode: Opcode) -> Bytecode:
3938

4039

4140
def prepare_suffix(opcode: Opcode) -> Bytecode:
42-
"""Prepare after opcode instructions"""
41+
"""Prepare after opcode instructions."""
4342
if opcode == Op.JUMPI or opcode == Op.JUMP:
4443
return Op.JUMPDEST
4544
return Op.STOP
@@ -95,7 +94,7 @@ def test_all_opcodes(state_test: StateTestFiller, pre: Alloc, fork: Fork):
9594

9695
@pytest.mark.valid_from("Cancun")
9796
def test_cover_revert(state_test: StateTestFiller, pre: Alloc):
98-
"""Cover state revert from original tests for the coverage script"""
97+
"""Cover state revert from original tests for the coverage script."""
9998
tx = Transaction(
10099
sender=pre.fund_eoa(),
101100
gas_limit=1_000_000,

tests/frontier/opcodes/test_call_and_callcode_gas_calculation.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,20 @@ def callee_code(callee_opcode: Op) -> Bytecode:
7070
PUSH1 0x01 <- for positive value transfer
7171
PUSH2 Contract.nonexistent
7272
GAS <- value doesn't matter
73-
CALL/CALLCODE
73+
CALL/CALLCODE.
7474
"""
7575
return callee_opcode(Op.GAS(), 0xFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, 1, 0, 0, 0, 0)
7676

7777

7878
@pytest.fixture
7979
def sender(pre: Alloc) -> EOA:
80-
"""
81-
Sender for all transactions.
82-
"""
80+
"""Sender for all transactions."""
8381
return pre.fund_eoa(0x0BA1A9CE)
8482

8583

8684
@pytest.fixture
8785
def callee_address(pre: Alloc, callee_code: Bytecode) -> Address:
88-
"""
89-
Address of the callee.
90-
"""
86+
"""Address of the callee."""
9187
return pre.deploy_contract(callee_code, balance=0x03)
9288

9389

@@ -100,7 +96,7 @@ def caller_code(caller_gas_limit: int, callee_address: Address) -> Bytecode:
10096
PUSH2 caller_gas <- gas limit set for CALL to callee contract
10197
CALL
10298
PUSH1 0x00
103-
SSTORE
99+
SSTORE.
104100
"""
105101
return Op.SSTORE(0, Op.CALL(caller_gas_limit, callee_address, 0, 0, 0, 0, 0))
106102

@@ -114,7 +110,7 @@ def caller_address(pre: Alloc, caller_code: Bytecode) -> Address:
114110
PUSH2 caller_gas <- gas limit set for CALL to callee contract
115111
CALL
116112
PUSH1 0x00
117-
SSTORE
113+
SSTORE.
118114
"""
119115
return pre.deploy_contract(caller_code, balance=0x03)
120116

@@ -156,7 +152,5 @@ def test_value_transfer_gas_calculation(
156152
caller_tx: Transaction,
157153
post: Dict[str, Account],
158154
):
159-
"""
160-
Tests the nested CALL/CALLCODE opcode gas consumption with a positive value transfer.
161-
"""
155+
"""Tests the nested CALL/CALLCODE opcode gas consumption with a positive value transfer."""
162156
state_test(env=Environment(), pre=pre, post=post, tx=caller_tx)

tests/frontier/opcodes/test_dup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
import pytest
88

99
from ethereum_test_forks import Frontier, Homestead
10-
from ethereum_test_tools import Account, Alloc, Environment
10+
from ethereum_test_tools import Account, Alloc, Environment, StateTestFiller, Storage, Transaction
1111
from ethereum_test_tools import Opcodes as Op
12-
from ethereum_test_tools import StateTestFiller, Storage, Transaction
1312

1413

1514
@pytest.mark.parametrize(
@@ -97,7 +96,7 @@ def test_dup(
9796
DUP1 copies the first element of the stack (0x10).
9897
DUP16 copies the 16th element of the stack (0x01).
9998
"""
100-
s: Storage.StorageDictType = dict(zip(range(1, 17), range(16, 0, -1)))
99+
s: Storage.StorageDictType = dict(zip(range(1, 17), range(16, 0, -1), strict=False))
101100
s[0] = 16 - (dup_opcode.int() - 0x80)
102101

103102
post[account] = Account(storage=s)

tests/frontier/opcodes/test_selfdestruct.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
"""
2-
Test the SELFDESTRUCT opcode.
3-
"""
1+
"""Test the SELFDESTRUCT opcode."""
42

53
import pytest
64

7-
from ethereum_test_tools import Account, Alloc, Block, BlockchainTestFiller, Environment, Initcode
5+
from ethereum_test_tools import (
6+
Account,
7+
Alloc,
8+
Block,
9+
BlockchainTestFiller,
10+
Environment,
11+
Initcode,
12+
Transaction,
13+
)
814
from ethereum_test_tools import Opcodes as Op
9-
from ethereum_test_tools import Transaction
1015

1116

1217
@pytest.mark.valid_from("Frontier")

0 commit comments

Comments
 (0)