def test_block_valid(): """Test validation of a block""" block = Block(0, 'Test Data', timestamp=0) assert block.hash_satisfies_difficulty assert block.is_valid block.difficulty = 4 assert block.hash_satisfies_difficulty is False assert block.is_valid is False block.proof = 49 assert block.proof == 49 assert block.hash_satisfies_difficulty assert block.is_valid # Introduce a fake hash block.hash = '0f59bbd5a22a6484cc206b7ee9d4bc1744bed9c5649ff332f88a0eec461f58c8' assert block.hash == '0f59bbd5a22a6484cc206b7ee9d4bc1744bed9c5649ff332f88a0eec461f58c8' assert block.hash_satisfies_difficulty assert block.is_valid is False
def test_block_difficulty(): """Test proof-of-work validation""" block = Block(0, 'Test Data', timestamp=0) assert block.hash_satisfies_difficulty block.difficulty = 4 assert block.hash_satisfies_difficulty is False block.proof = 49 assert block.proof == 49 assert block.hash_satisfies_difficulty block.proof = 5 assert block.proof == 5 assert block.hash_satisfies_difficulty is False