def test_insufficient_pow(self): with self.assertRaises(Exception): self.header["nonce"] = 42 Blockchain.verify_header(self.header, self.prev_hash, self.target)
def test_target_mismatch(self): with self.assertRaises(Exception): other_target = Blockchain.bits_to_target(0x1d00eeee) Blockchain.verify_header(self.header, self.prev_hash, other_target)
def test_expected_hash_mismatch(self): with self.assertRaises(Exception): Blockchain.verify_header(self.header, self.prev_hash, self.target, expected_header_hash="foo")
def test_prev_hash_mismatch(self): with self.assertRaises(Exception): Blockchain.verify_header(self.header, "foo", self.target)
def test_valid_header(self): Blockchain.verify_header(self.header, self.prev_hash, self.target)