Skip to content

Commit 5673c67

Browse files
committed
fix(blockchain): spam transaction
1 parent 7131974 commit 5673c67

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

blockchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def submit_transaction(self, transaction):
7171
else:
7272
print("I'm sending a new Transaction", transaction)
7373

74-
if transaction == self.current_transactions:
74+
if transaction in self.current_transactions:
7575
print('I received an transaction, but I already know it, so I ignore it.')
7676
return False
7777

test_transaction.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from transaction import Transaction
2+
3+
def test_equality():
4+
sender = '@sender_addr'
5+
receiv = '@receiv_addr'
6+
val = 10
7+
8+
t1 = Transaction(sender, receiv, val)
9+
t2 = Transaction(sender, receiv, val)
10+
11+
transactions = [t1, t2]
12+
13+
print(t1, t2)
14+
t3 = Transaction(sender, receiv, 55)
15+
16+
assert t1 == t2
17+
assert t1 != t3
18+
19+
assert t1 in transactions
20+
assert not t3 in transactions

0 commit comments

Comments
 (0)