예제 #1
0
 def test_integrity_modified_nonce(self):
     block = Block(timestamp, transaction, index, previous_hash)
     block.mine_block(2)
     block.nonce = -1    # Pray it doesnt it the correct nonce...
     self.assertNotEqual(block.currentHash, block.calculate_hash())
예제 #2
0
 def test_integrity_modified_previous_hash(self):
     block = Block(timestamp, transaction, index, previous_hash)
     block.mine_block(2)
     block.previousHash = "wrongHash"
     self.assertNotEqual(block.currentHash, block.calculate_hash())
예제 #3
0
 def test_integrity_modified_timestamp(self):
     block = Block(timestamp, transaction, index, previous_hash)
     block.mine_block(2)
     block.timestamp = datetime.now()
     self.assertNotEqual(block.currentHash, block.calculate_hash())
예제 #4
0
 def test_integrity_modified_transaction_list_null(self):
     block = Block(timestamp, [transaction, Transaction(from_address, to_address, amount, node_identifier)], index, previous_hash)
     block.mine_block(2)
     block.transactions = None
     self.assertNotEqual(block.currentHash, block.calculate_hash())
예제 #5
0
 def test_mining_correct_difficulty(self):
     block = Block(timestamp, transaction, index, previous_hash)
     block.mine_block(difficulty)
     self.assertEqual(block.currentHash[0:difficulty], "".join((["0"] * difficulty)))