Skip to content

Commit

Permalink
Create test_blockchain.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Nov 26, 2024
1 parent cb7481f commit deb16f7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions QuantumNexusProtocol/tests/test_blockchain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import unittest
from src.core.blockchain import Blockchain

class TestBlockchain(unittest.TestCase):
def setUp(self):
self.blockchain = Blockchain()

def test_initial_block(self):
self.assertEqual(len(self.blockchain.chain), 1)
self.assertEqual(self.blockchain.chain[0]['index'], 1)

def test_add_block(self):
previous_length = len(self.blockchain.chain)
self.blockchain.add_block(data="Test Block")
self.assertEqual(len(self.blockchain.chain), previous_length + 1)

def test_chain_integrity(self):
self.blockchain.add_block(data="Block 1")
self.blockchain.add_block(data="Block 2")
self.assertTrue(self.blockchain.is_chain_valid())

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

0 comments on commit deb16f7

Please sign in to comment.