Skip to content

Commit 94fcc08

Browse files
committed
test: add rpc_fundrawtransaction logging
test/functional/rpc_fundrawtransaction.py is fairly long to run and has no logging, so it can appear to be stalled. This commit adds info logging at each test to provide feedback on the test run.
1 parent 08e2947 commit 94fcc08

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

test/functional/rpc_fundrawtransaction.py

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def setup_network(self):
4141
connect_nodes(self.nodes[0], 3)
4242

4343
def run_test(self):
44+
self.log.info("Connect nodes, set fees, generate blocks, and sync")
4445
self.min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee']
4546
# This test is not meant to test fee estimation and we'd like
4647
# to be sure all txs are sent at a consistent desired feerate
@@ -91,6 +92,7 @@ def run_test(self):
9192

9293
def test_change_position(self):
9394
# ensure that setting changePosition in fundraw with an exact match is handled properly
95+
self.log.info("Test fundrawtxn changePosition option")
9496
rawmatch = self.nodes[2].createrawtransaction([], {self.nodes[2].getnewaddress():50})
9597
rawmatch = self.nodes[2].fundrawtransaction(rawmatch, {"changePosition":1, "subtractFeeFromOutputs":[0]})
9698
assert_equal(rawmatch["changepos"], -1)
@@ -118,6 +120,7 @@ def test_simple(self):
118120
###############
119121
# simple test #
120122
###############
123+
self.log.info("Test fundrawtxn")
121124
inputs = [ ]
122125
outputs = { self.nodes[0].getnewaddress() : 1.0 }
123126
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
@@ -130,6 +133,7 @@ def test_simple_two_coins(self):
130133
##############################
131134
# simple test with two coins #
132135
##############################
136+
self.log.info("Test fundrawtxn with 2 coins")
133137
inputs = [ ]
134138
outputs = { self.nodes[0].getnewaddress() : 2.2 }
135139
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
@@ -144,6 +148,8 @@ def test_simple_two_outputs(self):
144148
################################
145149
# simple test with two outputs #
146150
################################
151+
self.log.info("Test fundrawtxn with 2 outputs")
152+
147153
inputs = [ ]
148154
outputs = { self.nodes[0].getnewaddress() : 2.6, self.nodes[1].getnewaddress() : 2.5 }
149155
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
@@ -162,6 +168,7 @@ def test_change(self):
162168
#########################################################################
163169
# test a fundrawtransaction with a VIN greater than the required amount #
164170
#########################################################################
171+
self.log.info("Test fundrawtxn with a vin > required amount")
165172
utx = get_unspent(self.nodes[2].listunspent(), 5)
166173

167174
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']}]
@@ -184,6 +191,7 @@ def test_no_change(self):
184191
#####################################################################
185192
# test a fundrawtransaction with which will not get a change output #
186193
#####################################################################
194+
self.log.info("Test fundrawtxn not having a change output")
187195
utx = get_unspent(self.nodes[2].listunspent(), 5)
188196

189197
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']}]
@@ -206,6 +214,7 @@ def test_invalid_option(self):
206214
####################################################
207215
# test a fundrawtransaction with an invalid option #
208216
####################################################
217+
self.log.info("Test fundrawtxn with an invalid option")
209218
utx = get_unspent(self.nodes[2].listunspent(), 5)
210219

211220
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']} ]
@@ -223,6 +232,7 @@ def test_invalid_change_address(self):
223232
############################################################
224233
# test a fundrawtransaction with an invalid change address #
225234
############################################################
235+
self.log.info("Test fundrawtxn with an invalid change address")
226236
utx = get_unspent(self.nodes[2].listunspent(), 5)
227237

228238
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']} ]
@@ -237,6 +247,7 @@ def test_valid_change_address(self):
237247
############################################################
238248
# test a fundrawtransaction with a provided change address #
239249
############################################################
250+
self.log.info("Test fundrawtxn with a provided change address")
240251
utx = get_unspent(self.nodes[2].listunspent(), 5)
241252

242253
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']} ]
@@ -256,6 +267,7 @@ def test_change_type(self):
256267
#########################################################
257268
# test a fundrawtransaction with a provided change type #
258269
#########################################################
270+
self.log.info("Test fundrawtxn with a provided change type")
259271
utx = get_unspent(self.nodes[2].listunspent(), 5)
260272

261273
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']} ]
@@ -271,6 +283,7 @@ def test_coin_selection(self):
271283
#########################################################################
272284
# test a fundrawtransaction with a VIN smaller than the required amount #
273285
#########################################################################
286+
self.log.info("Test fundrawtxn with a vin < required amount")
274287
utx = get_unspent(self.nodes[2].listunspent(), 1)
275288

276289
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']}]
@@ -305,6 +318,7 @@ def test_two_vin(self):
305318
###########################################
306319
# test a fundrawtransaction with two VINs #
307320
###########################################
321+
self.log.info("Test fundrawtxn with 2 vins")
308322
utx = get_unspent(self.nodes[2].listunspent(), 1)
309323
utx2 = get_unspent(self.nodes[2].listunspent(), 5)
310324

@@ -338,6 +352,7 @@ def test_two_vin_two_vout(self):
338352
#########################################################
339353
# test a fundrawtransaction with two VINs and two vOUTs #
340354
#########################################################
355+
self.log.info("Test fundrawtxn with 2 vins and 2 vouts")
341356
utx = get_unspent(self.nodes[2].listunspent(), 1)
342357
utx2 = get_unspent(self.nodes[2].listunspent(), 5)
343358

@@ -363,6 +378,7 @@ def test_invalid_input(self):
363378
##############################################
364379
# test a fundrawtransaction with invalid vin #
365380
##############################################
381+
self.log.info("Test fundrawtxn with an invalid vin")
366382
inputs = [ {'txid' : "1c7f966dab21119bac53213a2bc7532bff1fa844c124fd750a7d0b1332440bd1", 'vout' : 0} ] #invalid vin!
367383
outputs = { self.nodes[0].getnewaddress() : 1.0}
368384
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
@@ -371,6 +387,7 @@ def test_invalid_input(self):
371387
def test_fee_p2pkh(self):
372388
############################################################
373389
#compare fee of a standard pubkeyhash transaction
390+
self.log.info("Test fundrawtxn p2pkh fee")
374391
inputs = []
375392
outputs = {self.nodes[1].getnewaddress():1.1}
376393
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
@@ -388,8 +405,16 @@ def test_fee_p2pkh(self):
388405
def test_fee_p2pkh_multi_out(self):
389406
############################################################
390407
#compare fee of a standard pubkeyhash transaction with multiple outputs
408+
self.log.info("Test fundrawtxn p2pkh fee with multiple outputs")
391409
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+
}
393418
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
394419
fundedTx = self.nodes[0].fundrawtransaction(rawtx)
395420
#create same transaction over sendtoaddress
@@ -431,6 +456,7 @@ def test_fee_p2sh(self):
431456
def test_fee_4of5(self):
432457
############################################################
433458
#compare fee of a standard pubkeyhash transaction
459+
self.log.info("Test fundrawtxn fee with 4-of-5 addresses")
434460

435461
# create 4of5 addr
436462
addr1 = self.nodes[1].getnewaddress()
@@ -445,7 +471,16 @@ def test_fee_4of5(self):
445471
addr4Obj = self.nodes[1].getaddressinfo(addr4)
446472
addr5Obj = self.nodes[1].getaddressinfo(addr5)
447473

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']
449484

450485
inputs = []
451486
outputs = {mSigObj:1.1}
@@ -464,6 +499,7 @@ def test_fee_4of5(self):
464499
def test_spend_2of2(self):
465500
############################################################
466501
# spend a 2of2 multisig transaction over fundraw
502+
self.log.info("Test fundrawtxn spending 2-of-2 multisig")
467503

468504
# create 2of2 addr
469505
addr1 = self.nodes[2].getnewaddress()
@@ -472,8 +508,13 @@ def test_spend_2of2(self):
472508
addr1Obj = self.nodes[2].getaddressinfo(addr1)
473509
addr2Obj = self.nodes[2].getaddressinfo(addr2)
474510

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']
477518

478519
# send 1.2 BTC to msig addr
479520
self.nodes[0].sendtoaddress(mSigObj, 1.2)
@@ -499,6 +540,8 @@ def test_spend_2of2(self):
499540
def test_locked_wallet(self):
500541
############################################################
501542
# locked wallet test
543+
self.log.info("Test fundrawtxn with locked wallet")
544+
502545
self.nodes[1].encryptwallet("test")
503546
self.stop_nodes()
504547

@@ -555,6 +598,7 @@ def test_many_inputs_fee(self):
555598
###############################################
556599
# multiple (~19) inputs tx test | Compare fee #
557600
###############################################
601+
self.log.info("Test fundrawtxn fee with many inputs")
558602

559603
#empty node1, send some small coins from node0 to node1
560604
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
@@ -585,6 +629,7 @@ def test_many_inputs_send(self):
585629
#############################################
586630
# multiple (~19) inputs tx test | sign/send #
587631
#############################################
632+
self.log.info("Test fundrawtxn sign+send with many inputs")
588633

589634
#again, empty node1, send some small coins from node0 to node1
590635
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
@@ -615,6 +660,7 @@ def test_op_return(self):
615660
#####################################################
616661
# test fundrawtransaction with OP_RETURN and no vin #
617662
#####################################################
663+
self.log.info("Test fundrawtxn with OP_RETURN and no vin")
618664

619665
rawtx = "0100000000010000000000000000066a047465737400000000"
620666
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
@@ -632,6 +678,7 @@ def test_watchonly(self):
632678
##################################################
633679
# test a fundrawtransaction using only watchonly #
634680
##################################################
681+
self.log.info("Test fundrawtxn using only watchonly")
635682

636683
inputs = []
637684
outputs = {self.nodes[2].getnewaddress(): self.watchonly_amount / 2}
@@ -649,6 +696,7 @@ def test_all_watched_funds(self):
649696
###############################################################
650697
# test fundrawtransaction using the entirety of watched funds #
651698
###############################################################
699+
self.log.info("Test fundrawtxn using entirety of watched funds")
652700

653701
inputs = []
654702
outputs = {self.nodes[2].getnewaddress(): self.watchonly_amount}
@@ -676,6 +724,7 @@ def test_option_feerate(self):
676724
#######################
677725
# Test feeRate option #
678726
#######################
727+
self.log.info("Test fundrawtxn feeRate option")
679728

680729
# Make sure there is exactly one input so coin selection can't skew the result
681730
assert_equal(len(self.nodes[3].listunspent(1)), 1)
@@ -695,6 +744,7 @@ def test_address_reuse(self):
695744
################################
696745
# Test no address reuse occurs #
697746
################################
747+
self.log.info("Test fundrawtxn does not reuse addresses")
698748

699749
rawtx = self.nodes[3].createrawtransaction(inputs=[], outputs={self.nodes[3].getnewaddress(): 1})
700750
result3 = self.nodes[3].fundrawtransaction(rawtx)
@@ -712,6 +762,7 @@ def test_option_subtract_fee_from_outputs(self):
712762
######################################
713763
# Test subtractFeeFromOutputs option #
714764
######################################
765+
self.log.info("Test fundrawtxn subtractFeeFromOutputs option")
715766

716767
# Make sure there is exactly one input so coin selection can't skew the result
717768
assert_equal(len(self.nodes[3].listunspent(1)), 1)

0 commit comments

Comments
 (0)