Skip to content

Commit

Permalink
fix(tests): EIP-6110,7002,7251: more execute fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed Sep 12, 2024
1 parent baa3e62 commit d2b1f23
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 46 deletions.
11 changes: 6 additions & 5 deletions tests/prague/eip6110_deposits/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ class DepositInteractionBase:
Base class for all types of deposit transactions we want to test.
"""

sender_balance: int = 32_000_000_000_000_000_000 * 100
"""
Balance of the account that sends the transaction.
"""
sender_account: EOA | None = None
"""
Account that sends the transaction.
Expand All @@ -134,6 +130,11 @@ def valid_requests(self, current_minimum_fee: int) -> List[DepositRequest]:
class DepositTransaction(DepositInteractionBase):
"""Class used to describe a deposit originated from an externally owned account."""

sender_balance: int = 32_000_000_000_000_000_000 * 100
"""
Balance of the account that sends the transaction.
"""

def transactions(self) -> List[Transaction]:
"""Return a transaction for the deposit request."""
assert self.sender_account is not None, "Sender account not initialized"
Expand Down Expand Up @@ -232,7 +233,7 @@ def transactions(self) -> List[Transaction]:

def update_pre(self, pre: Alloc):
"""Return the pre-state of the account."""
self.sender_account = pre.fund_eoa(self.sender_balance)
self.sender_account = pre.fund_eoa()
self.contract_address = pre.deploy_contract(
code=self.contract_code, balance=self.contract_balance
)
Expand Down
64 changes: 33 additions & 31 deletions tests/prague/eip6110_deposits/test_deposits.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

pytestmark = pytest.mark.valid_from("Prague")

DEFAULT_DEPOSIT_GWEI_VALUE = 32_000_000_000


@pytest.mark.parametrize(
"requests",
Expand All @@ -35,7 +37,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
)
Expand Down Expand Up @@ -69,14 +71,14 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x1,
),
Expand Down Expand Up @@ -109,7 +111,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
)
Expand All @@ -120,7 +122,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x1,
)
Expand All @@ -143,7 +145,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
),
Expand All @@ -159,7 +161,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
),
Expand All @@ -182,7 +184,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
# From traces, gas used by the first tx is 82,718 so reduce by one here
Expand All @@ -192,7 +194,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
),
Expand All @@ -208,14 +210,14 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
),
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
# From traces, gas used by the second tx is 68,594, reduce by one here
Expand All @@ -234,7 +236,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
calldata_modifier=lambda _: b"",
Expand All @@ -252,7 +254,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
)
Expand All @@ -268,7 +270,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
),
Expand Down Expand Up @@ -430,7 +432,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
valid=False,
Expand All @@ -456,7 +458,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
valid=False,
Expand Down Expand Up @@ -502,7 +504,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
),
Expand All @@ -513,7 +515,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x1,
)
Expand All @@ -529,7 +531,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
)
Expand All @@ -540,7 +542,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x1,
),
Expand All @@ -556,7 +558,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
)
Expand All @@ -567,7 +569,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x1,
),
Expand All @@ -578,7 +580,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x2,
)
Expand All @@ -594,7 +596,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
),
Expand All @@ -605,7 +607,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x1,
)
Expand All @@ -616,7 +618,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x2,
),
Expand All @@ -632,7 +634,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
valid=False,
Expand All @@ -650,7 +652,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
valid=False,
Expand All @@ -668,7 +670,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
valid=False,
Expand All @@ -686,7 +688,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
)
Expand All @@ -703,7 +705,7 @@
DepositRequest(
pubkey=0x01,
withdrawal_credentials=0x02,
amount=32_000_000_000,
amount=DEFAULT_DEPOSIT_GWEI_VALUE,
signature=0x03,
index=0x0,
)
Expand Down
11 changes: 6 additions & 5 deletions tests/prague/eip7002_el_triggerable_withdrawals/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ class WithdrawalRequestInteractionBase:
Base class for all types of withdrawal transactions we want to test.
"""

sender_balance: int = 32_000_000_000_000_000_000 * 100
"""
Balance of the account that sends the transaction.
"""
sender_account: EOA | None = None
"""
Account that will send the transaction.
Expand All @@ -100,6 +96,11 @@ def valid_requests(self, current_minimum_fee: int) -> List[WithdrawalRequest]:
class WithdrawalRequestTransaction(WithdrawalRequestInteractionBase):
"""Class used to describe a withdrawal request originated from an externally owned account."""

sender_balance: int = 32_000_000_000_000_000_000 * 100
"""
Balance of the account that sends the transaction.
"""

def transactions(self) -> List[Transaction]:
"""Return a transaction for the withdrawal request."""
assert self.sender_account is not None, "Sender account not initialized"
Expand Down Expand Up @@ -200,7 +201,7 @@ def transactions(self) -> List[Transaction]:

def update_pre(self, pre: Alloc):
"""Return the pre-state of the account."""
self.sender_account = pre.fund_eoa(self.sender_balance)
self.sender_account = pre.fund_eoa()
self.contract_address = pre.deploy_contract(
code=self.contract_code, balance=self.contract_balance
)
Expand Down
11 changes: 6 additions & 5 deletions tests/prague/eip7251_consolidations/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class ConsolidationRequestInteractionBase:
Base class for all types of consolidation transactions we want to test.
"""

sender_balance: int = 32_000_000_000_000_000_000 * 100
"""
Balance of the account that sends the transaction.
"""
sender_account: EOA | None = None
"""
Account that will send the transaction.
Expand Down Expand Up @@ -100,6 +96,11 @@ class ConsolidationRequestTransaction(ConsolidationRequestInteractionBase):
Class used to describe a consolidation request originated from an externally owned account.
"""

sender_balance: int = 32_000_000_000_000_000_000 * 100
"""
Balance of the account that sends the transaction.
"""

def transactions(self) -> List[Transaction]:
"""Return a transaction for the consolidation request."""
assert self.sender_account is not None, "Sender account not initialized"
Expand Down Expand Up @@ -200,7 +201,7 @@ def transactions(self) -> List[Transaction]:

def update_pre(self, pre: Alloc):
"""Return the pre-state of the account."""
self.sender_account = pre.fund_eoa(self.sender_balance)
self.sender_account = pre.fund_eoa()
self.contract_address = pre.deploy_contract(
code=self.contract_code, balance=self.contract_balance
)
Expand Down

0 comments on commit d2b1f23

Please sign in to comment.