def test_get_difficulty(self): tester_node = Node("Tester") blockchain = Blockchain(diff_threshold=10) self.assertEqual(1, blockchain.get_difficulty()) for i in range(105): tester_node.write_data(data=str(i), chain=blockchain, max_tries=15) # Expected failure if not all blocks could be mined: self.assertTrue(blockchain.get_difficulty() > 9)
def test_set_difficulty(self): blockchain = Blockchain() blockchain.set_difficulty(100) self.assertEqual(100, blockchain.get_difficulty())