7
7
from decimal import Decimal
8
8
import time
9
9
10
- from test_framework .blocktools import COINBASE_MATURITY
11
- from test_framework .messages import COIN , MAX_BLOCK_WEIGHT
10
+ from test_framework .messages import (
11
+ COIN ,
12
+ MAX_BLOCK_WEIGHT ,
13
+ )
12
14
from test_framework .test_framework import BitcoinTestFramework
13
- from test_framework .util import assert_equal , assert_raises_rpc_error , create_confirmed_utxos , create_lots_of_big_transactions , gen_return_txouts
15
+ from test_framework .util import (
16
+ assert_equal ,
17
+ assert_raises_rpc_error ,
18
+ create_lots_of_big_transactions ,
19
+ gen_return_txouts ,
20
+ )
14
21
from test_framework .wallet import MiniWallet
15
22
16
23
17
24
class PrioritiseTransactionTest (BitcoinTestFramework ):
18
25
def set_test_params (self ):
19
- self .setup_clean_chain = True
20
26
self .num_nodes = 1
21
27
self .extra_args = [[
22
28
"-printpriority=1" ,
23
29
"-acceptnonstdtxn=1" ,
24
30
]] * self .num_nodes
25
31
self .supports_cli = False
26
32
27
- def skip_test_if_missing_module (self ):
28
- self .skip_if_no_wallet ()
29
-
30
33
def test_diamond (self ):
31
34
self .log .info ("Test diamond-shape package with priority" )
32
- self .generate (self .wallet , COINBASE_MATURITY + 1 )
33
35
mock_time = int (time .time ())
34
36
self .nodes [0 ].setmocktime (mock_time )
35
37
@@ -104,6 +106,7 @@ def test_diamond(self):
104
106
105
107
def run_test (self ):
106
108
self .wallet = MiniWallet (self .nodes [0 ])
109
+ self .wallet .rescan_utxos ()
107
110
108
111
# Test `prioritisetransaction` required parameters
109
112
assert_raises_rpc_error (- 1 , "prioritisetransaction" , self .nodes [0 ].prioritisetransaction )
@@ -131,7 +134,10 @@ def run_test(self):
131
134
self .relayfee = self .nodes [0 ].getnetworkinfo ()['relayfee' ]
132
135
133
136
utxo_count = 90
134
- utxos = create_confirmed_utxos (self , self .relayfee , self .nodes [0 ], utxo_count )
137
+ utxos = self .wallet .send_self_transfer_multi (from_node = self .nodes [0 ], num_outputs = utxo_count )['new_utxos' ]
138
+ self .generate (self .wallet , 1 )
139
+ assert_equal (len (self .nodes [0 ].getrawmempool ()), 0 )
140
+
135
141
base_fee = self .relayfee * 100 # our transactions are smaller than 100kb
136
142
txids = []
137
143
@@ -141,7 +147,13 @@ def run_test(self):
141
147
txids .append ([])
142
148
start_range = i * range_size
143
149
end_range = start_range + range_size
144
- txids [i ] = create_lots_of_big_transactions (self .nodes [0 ], self .txouts , utxos [start_range :end_range ], end_range - start_range , (i + 1 )* base_fee )
150
+ txids [i ] = create_lots_of_big_transactions (
151
+ self .wallet ,
152
+ self .nodes [0 ],
153
+ (i + 1 ) * base_fee ,
154
+ end_range - start_range ,
155
+ self .txouts ,
156
+ utxos [start_range :end_range ])
145
157
146
158
# Make sure that the size of each group of transactions exceeds
147
159
# MAX_BLOCK_WEIGHT // 4 -- otherwise the test needs to be revised to
@@ -200,17 +212,9 @@ def run_test(self):
200
212
assert x not in mempool
201
213
202
214
# Create a free transaction. Should be rejected.
203
- utxo_list = self .nodes [0 ].listunspent ()
204
- assert len (utxo_list ) > 0
205
- utxo = utxo_list [0 ]
206
-
207
- inputs = []
208
- outputs = {}
209
- inputs .append ({"txid" : utxo ["txid" ], "vout" : utxo ["vout" ]})
210
- outputs [self .nodes [0 ].getnewaddress ()] = utxo ["amount" ]
211
- raw_tx = self .nodes [0 ].createrawtransaction (inputs , outputs )
212
- tx_hex = self .nodes [0 ].signrawtransactionwithwallet (raw_tx )["hex" ]
213
- tx_id = self .nodes [0 ].decoderawtransaction (tx_hex )["txid" ]
215
+ tx_res = self .wallet .create_self_transfer (from_node = self .nodes [0 ], fee_rate = 0 , mempool_valid = False )
216
+ tx_hex = tx_res ['hex' ]
217
+ tx_id = tx_res ['txid' ]
214
218
215
219
# This will raise an exception due to min relay fee not being met
216
220
assert_raises_rpc_error (- 26 , "min relay fee not met" , self .nodes [0 ].sendrawtransaction , tx_hex )
0 commit comments