def test_validation_2(): tx_in = TxIn(OutPoint("00" * 32, 0), Script()) tx_out = TxOut(10**10, Script()) tx_1 = Tx([tx_in], [tx_out]) header = BlockHeader() block = Block(header, [tx_1]) assert not block.is_valid() header.merkle_root = generate_merkle_root(block.transactions) header.previous_pow = "00" * 32 assert header.is_valid() assert block.is_valid() # has a coinbase tx
def test_validation_3(): tx_in = TxIn(OutPoint("ff" * 32, 256**2 - 1), Script()) tx_out = TxOut(10, Script()) tx_1 = Tx([tx_in], [tx_out]) tx_in_2 = TxIn(OutPoint("ff" * 32, 256**2 - 1), Script()) tx_out_2 = TxOut(10, Script()) tx_2 = Tx([tx_in_2], [tx_out_2]) header = BlockHeader() block = Block(header, [tx_1, tx_2]) header.merkle_root = generate_merkle_root(block.transactions) header.previous_pow = "00" * 32 assert header.is_valid() assert not block.is_valid() # two coinbases
def test_block_header_invalid_length(): header = BlockHeader() header.previous_pow = "00" * 32 assert not header.is_valid()