Skip to content

Commit 73fe996

Browse files
authored
Remove replay protection tests from test_transaction_signing
Removed tests for replay protection and nonce handling.
1 parent 6eebf36 commit 73fe996

1 file changed

Lines changed: 0 additions & 54 deletions

File tree

tests/test_transaction_signing_karun.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -140,59 +140,5 @@ def test_unsigned_transaction_fails_verification(alice, bob):
140140
assert not tx.verify(), "An unsigned transaction must not verify."
141141

142142

143-
# ------------------------------------------------------------------
144-
# 4. Replay protection
145-
# ------------------------------------------------------------------
146-
147-
def test_replay_attack_same_nonce_rejected(alice, bob, funded_state):
148-
"""Replaying the same transaction must be rejected the second time."""
149-
alice_sk, alice_pk = alice
150-
_, bob_pk = bob
151-
152-
tx = Transaction(alice_pk, bob_pk, 10, nonce=0)
153-
tx.sign(alice_sk)
154-
155-
assert funded_state.apply_transaction(tx), "First submission must succeed."
156-
assert not funded_state.apply_transaction(tx), "Replayed transaction must be rejected."
157-
# Ensure the rejected replay did not mutate the ledger
158-
assert funded_state.get_account(alice_pk)["balance"] == 90, \
159-
"Alice's balance must not change after a rejected replay."
160-
assert funded_state.get_account(alice_pk)["nonce"] == 1, \
161-
"Alice's nonce must not advance after a rejected replay."
162-
163-
164-
def test_out_of_order_nonce_rejected(alice, bob, funded_state):
165-
"""A transaction with a skipped nonce must be rejected."""
166-
alice_sk, alice_pk = alice
167-
_, bob_pk = bob
168-
169-
tx = Transaction(alice_pk, bob_pk, 10, nonce=5)
170-
tx.sign(alice_sk)
171-
172-
assert not funded_state.apply_transaction(tx), "A transaction with a skipped nonce must be rejected."
173-
# Ensure the rejected transaction did not mutate the ledger
174-
assert funded_state.get_account(alice_pk)["balance"] == 100, \
175-
"Alice's balance must remain unchanged after a rejected transaction."
176-
assert funded_state.get_account(alice_pk)["nonce"] == 0, \
177-
"Alice's nonce must remain unchanged after a rejected transaction."
178-
179-
180-
def test_sequential_nonces_accepted(alice, bob, funded_state):
181-
"""Two transactions with consecutive nonces must both succeed."""
182-
alice_sk, alice_pk = alice
183-
_, bob_pk = bob
184-
185-
tx0 = Transaction(alice_pk, bob_pk, 10, nonce=0)
186-
tx0.sign(alice_sk)
187-
assert funded_state.apply_transaction(tx0)
188-
189-
tx1 = Transaction(alice_pk, bob_pk, 10, nonce=1)
190-
tx1.sign(alice_sk)
191-
assert funded_state.apply_transaction(tx1)
192143

193-
assert funded_state.get_account(alice_pk)["nonce"] == 2, \
194-
"Alice's nonce should advance to 2 after two accepted transactions."
195-
assert funded_state.get_account(alice_pk)["balance"] == 80, \
196-
"Alice's balance should be 80 after two 10-coin transfers."
197-
assert funded_state.get_account(bob_pk)["balance"] == 20, \
198144
"Bob's balance should be 20 after receiving two transfers."

0 commit comments

Comments
 (0)