@@ -41,6 +41,7 @@ def setup_network(self):
41
41
connect_nodes (self .nodes [0 ], 3 )
42
42
43
43
def run_test (self ):
44
+ self .log .info ("Connect nodes, set fees, generate blocks, and sync" )
44
45
self .min_relay_tx_fee = self .nodes [0 ].getnetworkinfo ()['relayfee' ]
45
46
# This test is not meant to test fee estimation and we'd like
46
47
# to be sure all txs are sent at a consistent desired feerate
@@ -91,6 +92,7 @@ def run_test(self):
91
92
92
93
def test_change_position (self ):
93
94
# ensure that setting changePosition in fundraw with an exact match is handled properly
95
+ self .log .info ("Test fundrawtxn changePosition option" )
94
96
rawmatch = self .nodes [2 ].createrawtransaction ([], {self .nodes [2 ].getnewaddress ():50 })
95
97
rawmatch = self .nodes [2 ].fundrawtransaction (rawmatch , {"changePosition" :1 , "subtractFeeFromOutputs" :[0 ]})
96
98
assert_equal (rawmatch ["changepos" ], - 1 )
@@ -118,6 +120,7 @@ def test_simple(self):
118
120
###############
119
121
# simple test #
120
122
###############
123
+ self .log .info ("Test fundrawtxn" )
121
124
inputs = [ ]
122
125
outputs = { self .nodes [0 ].getnewaddress () : 1.0 }
123
126
rawtx = self .nodes [2 ].createrawtransaction (inputs , outputs )
@@ -130,6 +133,7 @@ def test_simple_two_coins(self):
130
133
##############################
131
134
# simple test with two coins #
132
135
##############################
136
+ self .log .info ("Test fundrawtxn with 2 coins" )
133
137
inputs = [ ]
134
138
outputs = { self .nodes [0 ].getnewaddress () : 2.2 }
135
139
rawtx = self .nodes [2 ].createrawtransaction (inputs , outputs )
@@ -144,6 +148,8 @@ def test_simple_two_outputs(self):
144
148
################################
145
149
# simple test with two outputs #
146
150
################################
151
+ self .log .info ("Test fundrawtxn with 2 outputs" )
152
+
147
153
inputs = [ ]
148
154
outputs = { self .nodes [0 ].getnewaddress () : 2.6 , self .nodes [1 ].getnewaddress () : 2.5 }
149
155
rawtx = self .nodes [2 ].createrawtransaction (inputs , outputs )
@@ -162,6 +168,7 @@ def test_change(self):
162
168
#########################################################################
163
169
# test a fundrawtransaction with a VIN greater than the required amount #
164
170
#########################################################################
171
+ self .log .info ("Test fundrawtxn with a vin > required amount" )
165
172
utx = get_unspent (self .nodes [2 ].listunspent (), 5 )
166
173
167
174
inputs = [ {'txid' : utx ['txid' ], 'vout' : utx ['vout' ]}]
@@ -184,6 +191,7 @@ def test_no_change(self):
184
191
#####################################################################
185
192
# test a fundrawtransaction with which will not get a change output #
186
193
#####################################################################
194
+ self .log .info ("Test fundrawtxn not having a change output" )
187
195
utx = get_unspent (self .nodes [2 ].listunspent (), 5 )
188
196
189
197
inputs = [ {'txid' : utx ['txid' ], 'vout' : utx ['vout' ]}]
@@ -206,6 +214,7 @@ def test_invalid_option(self):
206
214
####################################################
207
215
# test a fundrawtransaction with an invalid option #
208
216
####################################################
217
+ self .log .info ("Test fundrawtxn with an invalid option" )
209
218
utx = get_unspent (self .nodes [2 ].listunspent (), 5 )
210
219
211
220
inputs = [ {'txid' : utx ['txid' ], 'vout' : utx ['vout' ]} ]
@@ -223,6 +232,7 @@ def test_invalid_change_address(self):
223
232
############################################################
224
233
# test a fundrawtransaction with an invalid change address #
225
234
############################################################
235
+ self .log .info ("Test fundrawtxn with an invalid change address" )
226
236
utx = get_unspent (self .nodes [2 ].listunspent (), 5 )
227
237
228
238
inputs = [ {'txid' : utx ['txid' ], 'vout' : utx ['vout' ]} ]
@@ -237,6 +247,7 @@ def test_valid_change_address(self):
237
247
############################################################
238
248
# test a fundrawtransaction with a provided change address #
239
249
############################################################
250
+ self .log .info ("Test fundrawtxn with a provided change address" )
240
251
utx = get_unspent (self .nodes [2 ].listunspent (), 5 )
241
252
242
253
inputs = [ {'txid' : utx ['txid' ], 'vout' : utx ['vout' ]} ]
@@ -256,6 +267,7 @@ def test_change_type(self):
256
267
#########################################################
257
268
# test a fundrawtransaction with a provided change type #
258
269
#########################################################
270
+ self .log .info ("Test fundrawtxn with a provided change type" )
259
271
utx = get_unspent (self .nodes [2 ].listunspent (), 5 )
260
272
261
273
inputs = [ {'txid' : utx ['txid' ], 'vout' : utx ['vout' ]} ]
@@ -271,6 +283,7 @@ def test_coin_selection(self):
271
283
#########################################################################
272
284
# test a fundrawtransaction with a VIN smaller than the required amount #
273
285
#########################################################################
286
+ self .log .info ("Test fundrawtxn with a vin < required amount" )
274
287
utx = get_unspent (self .nodes [2 ].listunspent (), 1 )
275
288
276
289
inputs = [ {'txid' : utx ['txid' ], 'vout' : utx ['vout' ]}]
@@ -305,6 +318,7 @@ def test_two_vin(self):
305
318
###########################################
306
319
# test a fundrawtransaction with two VINs #
307
320
###########################################
321
+ self .log .info ("Test fundrawtxn with 2 vins" )
308
322
utx = get_unspent (self .nodes [2 ].listunspent (), 1 )
309
323
utx2 = get_unspent (self .nodes [2 ].listunspent (), 5 )
310
324
@@ -338,6 +352,7 @@ def test_two_vin_two_vout(self):
338
352
#########################################################
339
353
# test a fundrawtransaction with two VINs and two vOUTs #
340
354
#########################################################
355
+ self .log .info ("Test fundrawtxn with 2 vins and 2 vouts" )
341
356
utx = get_unspent (self .nodes [2 ].listunspent (), 1 )
342
357
utx2 = get_unspent (self .nodes [2 ].listunspent (), 5 )
343
358
@@ -363,6 +378,7 @@ def test_invalid_input(self):
363
378
##############################################
364
379
# test a fundrawtransaction with invalid vin #
365
380
##############################################
381
+ self .log .info ("Test fundrawtxn with an invalid vin" )
366
382
inputs = [ {'txid' : "1c7f966dab21119bac53213a2bc7532bff1fa844c124fd750a7d0b1332440bd1" , 'vout' : 0 } ] #invalid vin!
367
383
outputs = { self .nodes [0 ].getnewaddress () : 1.0 }
368
384
rawtx = self .nodes [2 ].createrawtransaction (inputs , outputs )
@@ -371,6 +387,7 @@ def test_invalid_input(self):
371
387
def test_fee_p2pkh (self ):
372
388
############################################################
373
389
#compare fee of a standard pubkeyhash transaction
390
+ self .log .info ("Test fundrawtxn p2pkh fee" )
374
391
inputs = []
375
392
outputs = {self .nodes [1 ].getnewaddress ():1.1 }
376
393
rawtx = self .nodes [0 ].createrawtransaction (inputs , outputs )
@@ -388,8 +405,16 @@ def test_fee_p2pkh(self):
388
405
def test_fee_p2pkh_multi_out (self ):
389
406
############################################################
390
407
#compare fee of a standard pubkeyhash transaction with multiple outputs
408
+ self .log .info ("Test fundrawtxn p2pkh fee with multiple outputs" )
391
409
inputs = []
392
- outputs = {self .nodes [1 ].getnewaddress ():1.1 ,self .nodes [1 ].getnewaddress ():1.2 ,self .nodes [1 ].getnewaddress ():0.1 ,self .nodes [1 ].getnewaddress ():1.3 ,self .nodes [1 ].getnewaddress ():0.2 ,self .nodes [1 ].getnewaddress ():0.3 }
410
+ outputs = {
411
+ self .nodes [1 ].getnewaddress ():1.1 ,
412
+ self .nodes [1 ].getnewaddress ():1.2 ,
413
+ self .nodes [1 ].getnewaddress ():0.1 ,
414
+ self .nodes [1 ].getnewaddress ():1.3 ,
415
+ self .nodes [1 ].getnewaddress ():0.2 ,
416
+ self .nodes [1 ].getnewaddress ():0.3 ,
417
+ }
393
418
rawtx = self .nodes [0 ].createrawtransaction (inputs , outputs )
394
419
fundedTx = self .nodes [0 ].fundrawtransaction (rawtx )
395
420
#create same transaction over sendtoaddress
@@ -431,6 +456,7 @@ def test_fee_p2sh(self):
431
456
def test_fee_4of5 (self ):
432
457
############################################################
433
458
#compare fee of a standard pubkeyhash transaction
459
+ self .log .info ("Test fundrawtxn fee with 4-of-5 addresses" )
434
460
435
461
# create 4of5 addr
436
462
addr1 = self .nodes [1 ].getnewaddress ()
@@ -445,7 +471,16 @@ def test_fee_4of5(self):
445
471
addr4Obj = self .nodes [1 ].getaddressinfo (addr4 )
446
472
addr5Obj = self .nodes [1 ].getaddressinfo (addr5 )
447
473
448
- mSigObj = self .nodes [1 ].addmultisigaddress (4 , [addr1Obj ['pubkey' ], addr2Obj ['pubkey' ], addr3Obj ['pubkey' ], addr4Obj ['pubkey' ], addr5Obj ['pubkey' ]])['address' ]
474
+ mSigObj = self .nodes [1 ].addmultisigaddress (
475
+ 4 ,
476
+ [
477
+ addr1Obj ['pubkey' ],
478
+ addr2Obj ['pubkey' ],
479
+ addr3Obj ['pubkey' ],
480
+ addr4Obj ['pubkey' ],
481
+ addr5Obj ['pubkey' ],
482
+ ]
483
+ )['address' ]
449
484
450
485
inputs = []
451
486
outputs = {mSigObj :1.1 }
@@ -464,6 +499,7 @@ def test_fee_4of5(self):
464
499
def test_spend_2of2 (self ):
465
500
############################################################
466
501
# spend a 2of2 multisig transaction over fundraw
502
+ self .log .info ("Test fundrawtxn spending 2-of-2 multisig" )
467
503
468
504
# create 2of2 addr
469
505
addr1 = self .nodes [2 ].getnewaddress ()
@@ -472,8 +508,13 @@ def test_spend_2of2(self):
472
508
addr1Obj = self .nodes [2 ].getaddressinfo (addr1 )
473
509
addr2Obj = self .nodes [2 ].getaddressinfo (addr2 )
474
510
475
- mSigObj = self .nodes [2 ].addmultisigaddress (2 , [addr1Obj ['pubkey' ], addr2Obj ['pubkey' ]])['address' ]
476
-
511
+ mSigObj = self .nodes [2 ].addmultisigaddress (
512
+ 2 ,
513
+ [
514
+ addr1Obj ['pubkey' ],
515
+ addr2Obj ['pubkey' ],
516
+ ]
517
+ )['address' ]
477
518
478
519
# send 1.2 BTC to msig addr
479
520
self .nodes [0 ].sendtoaddress (mSigObj , 1.2 )
@@ -499,6 +540,8 @@ def test_spend_2of2(self):
499
540
def test_locked_wallet (self ):
500
541
############################################################
501
542
# locked wallet test
543
+ self .log .info ("Test fundrawtxn with locked wallet" )
544
+
502
545
self .nodes [1 ].encryptwallet ("test" )
503
546
self .stop_nodes ()
504
547
@@ -555,6 +598,7 @@ def test_many_inputs_fee(self):
555
598
###############################################
556
599
# multiple (~19) inputs tx test | Compare fee #
557
600
###############################################
601
+ self .log .info ("Test fundrawtxn fee with many inputs" )
558
602
559
603
#empty node1, send some small coins from node0 to node1
560
604
self .nodes [1 ].sendtoaddress (self .nodes [0 ].getnewaddress (), self .nodes [1 ].getbalance (), "" , "" , True )
@@ -585,6 +629,7 @@ def test_many_inputs_send(self):
585
629
#############################################
586
630
# multiple (~19) inputs tx test | sign/send #
587
631
#############################################
632
+ self .log .info ("Test fundrawtxn sign+send with many inputs" )
588
633
589
634
#again, empty node1, send some small coins from node0 to node1
590
635
self .nodes [1 ].sendtoaddress (self .nodes [0 ].getnewaddress (), self .nodes [1 ].getbalance (), "" , "" , True )
@@ -615,6 +660,7 @@ def test_op_return(self):
615
660
#####################################################
616
661
# test fundrawtransaction with OP_RETURN and no vin #
617
662
#####################################################
663
+ self .log .info ("Test fundrawtxn with OP_RETURN and no vin" )
618
664
619
665
rawtx = "0100000000010000000000000000066a047465737400000000"
620
666
dec_tx = self .nodes [2 ].decoderawtransaction (rawtx )
@@ -632,6 +678,7 @@ def test_watchonly(self):
632
678
##################################################
633
679
# test a fundrawtransaction using only watchonly #
634
680
##################################################
681
+ self .log .info ("Test fundrawtxn using only watchonly" )
635
682
636
683
inputs = []
637
684
outputs = {self .nodes [2 ].getnewaddress (): self .watchonly_amount / 2 }
@@ -649,6 +696,7 @@ def test_all_watched_funds(self):
649
696
###############################################################
650
697
# test fundrawtransaction using the entirety of watched funds #
651
698
###############################################################
699
+ self .log .info ("Test fundrawtxn using entirety of watched funds" )
652
700
653
701
inputs = []
654
702
outputs = {self .nodes [2 ].getnewaddress (): self .watchonly_amount }
@@ -676,6 +724,7 @@ def test_option_feerate(self):
676
724
#######################
677
725
# Test feeRate option #
678
726
#######################
727
+ self .log .info ("Test fundrawtxn feeRate option" )
679
728
680
729
# Make sure there is exactly one input so coin selection can't skew the result
681
730
assert_equal (len (self .nodes [3 ].listunspent (1 )), 1 )
@@ -695,6 +744,7 @@ def test_address_reuse(self):
695
744
################################
696
745
# Test no address reuse occurs #
697
746
################################
747
+ self .log .info ("Test fundrawtxn does not reuse addresses" )
698
748
699
749
rawtx = self .nodes [3 ].createrawtransaction (inputs = [], outputs = {self .nodes [3 ].getnewaddress (): 1 })
700
750
result3 = self .nodes [3 ].fundrawtransaction (rawtx )
@@ -712,6 +762,7 @@ def test_option_subtract_fee_from_outputs(self):
712
762
######################################
713
763
# Test subtractFeeFromOutputs option #
714
764
######################################
765
+ self .log .info ("Test fundrawtxn subtractFeeFromOutputs option" )
715
766
716
767
# Make sure there is exactly one input so coin selection can't skew the result
717
768
assert_equal (len (self .nodes [3 ].listunspent (1 )), 1 )
0 commit comments