Skip to content

Commit

Permalink
Create test_transaction.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored May 10, 2024
1 parent 6d1b096 commit 8013700
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/tests/unit_tests/test_transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import unittest
from transaction import Transaction

class TestTransaction(unittest.TestCase):
def test_create_transaction(self):
transaction = Transaction('sender', 'receiver', 100)
self.assertEqual(transaction.sender, 'sender')
self.assertEqual(transaction.receiver, 'receiver')
self.assertEqual(transaction.amount, 100)
self.assertEqual(transaction.hash, None)

def test_hash(self):
transaction = Transaction('sender', 'receiver', 100)
transaction.hash = None
transaction.mine_hash()
self.assertNotEqual(transaction.hash, None)

def test_mine_hash(self):
transaction = Transaction('sender', 'receiver', 100)
transaction.mine_hash(difficulty=2)
self.assertEqual(transaction.hash[0:2], '00')

if __name__ == '__main__':
unittest.main()

0 comments on commit 8013700

Please sign in to comment.