Skip to content

Commit bb62ff0

Browse files
committed
added type hints like there is no tomorrow
1 parent b6d9942 commit bb62ff0

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

tests/prague/eip7685_general_purpose_el_requests/test_deposits_withdrawals_consolidations.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import pytest
1111

12+
from ethereum_test_base_types.base_types import Address
1213
from ethereum_test_forks import Fork
1314
from ethereum_test_tools import (
1415
Account,
@@ -27,6 +28,7 @@
2728
)
2829
from ethereum_test_tools import Opcodes as Op
2930
from ethereum_test_tools.utility.pytest import ParameterSet
31+
from ethereum_test_types.types import EOA
3032

3133
from ..eip6110_deposits.helpers import DepositContract, DepositRequest, DepositTransaction
3234
from ..eip6110_deposits.spec import Spec as Spec_EIP6110
@@ -44,10 +46,10 @@
4446
from ..eip7251_consolidations.spec import Spec as Spec_EIP7251
4547
from .spec import ref_spec_7685
4648

47-
REFERENCE_SPEC_GIT_PATH = ref_spec_7685.git_path
48-
REFERENCE_SPEC_VERSION = ref_spec_7685.version
49+
REFERENCE_SPEC_GIT_PATH: str = ref_spec_7685.git_path
50+
REFERENCE_SPEC_VERSION: str = ref_spec_7685.version
4951

50-
pytestmark = pytest.mark.valid_from("Prague")
52+
pytestmark: pytest.MarkDecorator = pytest.mark.valid_from("Prague")
5153

5254

5355
def single_deposit(i: int) -> DepositRequest: # noqa: D103
@@ -108,7 +110,7 @@ def get_permutations(
108110
None,
109111
]:
110112
"""Return possible permutations of the requests from an EOA."""
111-
requests = [
113+
requests: list = [
112114
(
113115
"deposit",
114116
single_deposit(0),
@@ -128,7 +130,7 @@ def get_permutations(
128130

129131
def get_eoa_permutations(n: int = 3) -> Generator[ParameterSet, None, None]:
130132
"""Return possible permutations of the requests from an EOA."""
131-
requests = [
133+
requests: list = [
132134
(
133135
"deposit_from_eoa",
134136
single_deposit_from_eoa(0),
@@ -148,7 +150,7 @@ def get_eoa_permutations(n: int = 3) -> Generator[ParameterSet, None, None]:
148150

149151
def get_contract_permutations(n: int = 3) -> Generator[ParameterSet, None, None]:
150152
"""Return possible permutations of the requests from a contract."""
151-
requests = [
153+
requests: list = [
152154
(
153155
"deposit_from_contract",
154156
single_deposit_from_contract(0),
@@ -377,23 +379,23 @@ def test_valid_deposit_withdrawal_consolidation_request_from_same_tx(
377379
Test making a deposit to the beacon chain deposit contract and a withdrawal in
378380
the same tx.
379381
"""
380-
withdrawal_request_fee = 1
381-
consolidation_request_fee = 1
382+
withdrawal_request_fee: int = 1
383+
consolidation_request_fee: int = 1
382384

383-
calldata = b""
384-
contract_code = Bytecode()
385-
total_value = 0
386-
storage = Storage()
385+
calldata: bytes = b""
386+
contract_code: Bytecode = Bytecode()
387+
total_value: int = 0
388+
storage: Storage = Storage()
387389

388390
for request in requests:
389-
calldata_start = len(calldata)
390-
current_calldata = request.calldata
391+
calldata_start: int = len(calldata)
392+
current_calldata: bytes = request.calldata
391393
calldata += current_calldata
392394

393395
contract_code += Op.CALLDATACOPY(0, calldata_start, len(current_calldata))
394396

395-
call_contract_address = 0
396-
value = 0
397+
call_contract_address: int = 0
398+
value: int = 0
397399
if isinstance(request, DepositRequest):
398400
call_contract_address = Spec_EIP6110.DEPOSIT_CONTRACT_ADDRESS
399401
value = request.value
@@ -416,12 +418,12 @@ def test_valid_deposit_withdrawal_consolidation_request_from_same_tx(
416418
),
417419
)
418420

419-
sender = pre.fund_eoa()
420-
contract_address = pre.deploy_contract(
421+
sender: EOA = pre.fund_eoa()
422+
contract_address: Address = pre.deploy_contract(
421423
code=contract_code,
422424
)
423425

424-
tx = Transaction(
426+
tx: Transaction = Transaction(
425427
gas_limit=10_000_000,
426428
to=contract_address,
427429
value=total_value,
@@ -486,15 +488,15 @@ def invalid_requests_block_combinations(fork: Fork) -> List[ParameterSet]:
486488
}
487489

488490
# - Empty requests list with invalid hash
489-
combinations = [
491+
combinations: List[ParameterSet] = [
490492
pytest.param(
491493
[],
492494
[
493495
bytes([i]) for i in range(fork.max_request_type() + 1)
494496
], # Using empty requests, calculate the hash using an invalid calculation method:
495-
# sha256(sha256(b"\0") ++ sha256(b"\1") ++ sha256(b"\2") ++ ...)
497+
# sha256(sha256(b'0x00') ++ sha256(b'0x01') ++ sha256(b'0x02') ++ ...)
496498
BlockException.INVALID_REQUESTS,
497-
id="no_requests_invalid_hash_calculation_method",
499+
id="no_requests_and_invalid_hash_calculation_method",
498500
),
499501
pytest.param(
500502
[],
@@ -503,7 +505,7 @@ def invalid_requests_block_combinations(fork: Fork) -> List[ParameterSet]:
503505
], # Using empty requests, calculate the hash using an invalid calculation method:
504506
# sha256(sha256(b"") ++ sha256(b"") ++ sha256(b"") ++ ...)
505507
BlockException.INVALID_REQUESTS,
506-
id="no_requests_invalid_hash_calculation_method_2",
508+
id="no_requests_and_invalid_hash_calculation_method_2",
507509
),
508510
]
509511

0 commit comments

Comments
 (0)