22
22
23
23
def test_tx () -> None :
24
24
# default constructor
25
- tx = Tx ()
25
+ tx = Tx (check_validity = False )
26
26
assert not tx .is_segwit ()
27
27
assert not any (bool (w ) for w in tx .vwitness )
28
28
assert not any (bool (tx_in .script_witness ) for tx_in in tx .vin )
@@ -40,15 +40,22 @@ def test_tx() -> None:
40
40
assert tx .vsize == tx .size
41
41
assert tx .weight == tx .size * 4
42
42
43
- tx_2 = Tx .from_dict (tx .to_dict ())
43
+ with pytest .raises (BTClibValueError , match = "Missing inputs" ):
44
+ tx .assert_valid ()
45
+
46
+ tx_2 = Tx .from_dict (tx .to_dict (check_validity = False ), check_validity = False )
44
47
assert tx_2 .is_segwit () == tx .is_segwit ()
45
48
assert tx_2 == tx
46
49
47
- tx_2 = Tx .parse (tx .serialize (include_witness = True ))
50
+ tx_2 = Tx .parse (
51
+ tx .serialize (include_witness = True , check_validity = False ), check_validity = False
52
+ )
48
53
assert tx_2 .is_segwit () == tx .is_segwit ()
49
54
assert tx_2 == tx
50
55
51
- tx_2 = Tx .parse (tx .serialize (include_witness = False ))
56
+ tx_2 = Tx .parse (
57
+ tx .serialize (include_witness = False , check_validity = False ), check_validity = False
58
+ )
52
59
assert not tx_2 .is_segwit ()
53
60
assert tx_2 == tx
54
61
@@ -60,6 +67,10 @@ def test_tx() -> None:
60
67
sequence = 0xFFFFFFFF
61
68
tx_in = TxIn (prev_out , script_sig , sequence )
62
69
70
+ tx .vin = [tx_in ]
71
+ with pytest .raises (BTClibValueError , match = "Missing outputs" ):
72
+ tx .assert_valid ()
73
+
63
74
tx_out1 = TxOut (2500000 , "a914f987c321394968be164053d352fc49763b2be55c87" )
64
75
tx_out2 = TxOut (
65
76
6381891 , "0020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d"
0 commit comments