def test_invalid_tx_in2() -> None: transaction_input = tx_in.TxIn( prevout=tx_in.OutPoint("00" * 32, 0), scriptSig=[], scriptSigHex="", nSequence=1, txinwitness=[], ) with pytest.raises(ValueError): transaction_input.assert_valid()
def test_missing_tx_out() -> None: transaction_input = tx_in.TxIn( prevout=tx_in.OutPoint("ff" * 32, 0), scriptSig=[], scriptSigHex="", nSequence=1, txinwitness=[], ) transaction = tx.Tx(0, 0, [transaction_input], []) err_msg = "A transaction must have at least one output" with pytest.raises(ValueError, match=err_msg): transaction.assert_valid()
def test_invalid_outpoint() -> None: op = tx_in.OutPoint(b"\x01" * 31, 18) with pytest.raises(BTClibValueError, match="invalid OutPoint txid: "): op.assert_valid() op = tx_in.OutPoint(b"\x01" * 32, -1) with pytest.raises(BTClibValueError, match="negative OutPoint vout: "): op.assert_valid() op = tx_in.OutPoint(b"\x01" * 32, 0xFFFFFFFF + 1) with pytest.raises(BTClibValueError, match="OutPoint vout too high: "): op.assert_valid() op = tx_in.OutPoint(b"\x00" * 31 + b"\x01", 0xFFFFFFFF) with pytest.raises(BTClibValueError, match="invalid OutPoint"): op.assert_valid() op = tx_in.OutPoint(b"\x00" * 32, 0) with pytest.raises(BTClibValueError, match="invalid OutPoint"): op.assert_valid()
def test_invalid_tx() -> None: transaction_input = tx_in.TxIn( prevout=tx_in.OutPoint(b"\xff" * 32, 0), script_sig=b"", sequence=1, txinwitness=[], ) tx1 = tx.Tx(0, 0, [transaction_input], []) tx2 = tx.Tx(0, 0, [], []) err_msg = "A transaction must have at least one " for transaction in (tx1, tx2): with pytest.raises(BTClibValueError, match=err_msg): transaction.assert_valid()