Skip to content

Commit ef8e11a

Browse files
jonatackPiRK
authored andcommitted
test: add rpc_fundrawtransaction logging
Summary: > 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. This is a backport of Core [[bitcoin/bitcoin#17342 | PR17342]] [1/2] bitcoin/bitcoin@94fcc08 Test Plan: `ninja && test/functional/test_runner.py rpc_fundr*` While the test is running, in another terminal: `tail -f test/tmp/test_runner_₿₵_🏃_20201102_112740/rpc_fundrawtransaction_475/test_framework.log` Reviewers: O1 Bitcoin ABC, #bitcoin_abc, jasonbcox Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D8234
1 parent 70df496 commit ef8e11a

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

test/functional/rpc_fundrawtransaction.py

+53-7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def setup_network(self):
4444
connect_nodes(self.nodes[0], self.nodes[3])
4545

4646
def run_test(self):
47+
self.log.info("Connect nodes, set fees, generate blocks, and sync")
4748
self.min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee']
4849
# This test is not meant to test fee estimation and we'd like
4950
# to be sure all txs are sent at a consistent desired feerate
@@ -95,6 +96,7 @@ def run_test(self):
9596
def test_change_position(self):
9697
# ensure that setting changePosition in fundraw with an exact match is
9798
# handled properly
99+
self.log.info("Test fundrawtxn changePosition option")
98100
rawmatch = self.nodes[2].createrawtransaction(
99101
[], {self.nodes[2].getnewaddress(): 50})
100102
rawmatch = self.nodes[2].fundrawtransaction(
@@ -130,6 +132,7 @@ def test_simple(self):
130132
#
131133
# simple test #
132134
#
135+
self.log.info("Test fundrawtxn")
133136
inputs = []
134137
outputs = {self.nodes[0].getnewaddress(): 1.0}
135138
rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
@@ -143,6 +146,7 @@ def test_simple_two_coins(self):
143146
#
144147
# simple test with two coins #
145148
#
149+
self.log.info("Test fundrawtxn with 2 coins")
146150
inputs = []
147151
outputs = {self.nodes[0].getnewaddress(): 2.2}
148152
rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
@@ -158,6 +162,7 @@ def test_simple_two_outputs(self):
158162
#
159163
# simple test with two outputs #
160164
#
165+
self.log.info("Test fundrawtxn with 2 outputs")
161166
inputs = []
162167
outputs = {
163168
self.nodes[0].getnewaddress(): 2.6, self.nodes[1].getnewaddress(): 2.5}
@@ -177,6 +182,7 @@ def test_change(self):
177182
#
178183
# test a fundrawtransaction with a VIN greater than the required amount #
179184
#
185+
self.log.info("Test fundrawtxn with a vin > required amount")
180186
utx = get_unspent(self.nodes[2].listunspent(), 5)
181187

182188
inputs = [{'txid': utx['txid'], 'vout': utx['vout']}]
@@ -201,6 +207,7 @@ def test_no_change(self):
201207
#
202208
# test a fundrawtransaction with which will not get a change output #
203209
#
210+
self.log.info("Test fundrawtxn not having a change output")
204211
utx = get_unspent(self.nodes[2].listunspent(), 5)
205212

206213
inputs = [{'txid': utx['txid'], 'vout': utx['vout']}]
@@ -227,6 +234,7 @@ def test_invalid_option(self):
227234
#
228235
# test a fundrawtransaction with an invalid option #
229236
#
237+
self.log.info("Test fundrawtxn with an invalid option")
230238
utx = get_unspent(self.nodes[2].listunspent(), 5)
231239

232240
inputs = [{'txid': utx['txid'], 'vout': utx['vout']}]
@@ -247,6 +255,7 @@ def test_invalid_change_address(self):
247255
#
248256
# test a fundrawtransaction with an invalid change address #
249257
#
258+
self.log.info("Test fundrawtxn with an invalid change address")
250259
utx = get_unspent(self.nodes[2].listunspent(), 5)
251260

252261
inputs = [{'txid': utx['txid'], 'vout': utx['vout']}]
@@ -263,6 +272,7 @@ def test_valid_change_address(self):
263272
#
264273
# test a fundrawtransaction with a provided change address #
265274
#
275+
self.log.info("Test fundrawtxn with a provided change address")
266276
utx = get_unspent(self.nodes[2].listunspent(), 5)
267277

268278
inputs = [{'txid': utx['txid'], 'vout': utx['vout']}]
@@ -284,6 +294,7 @@ def test_coin_selection(self):
284294
#
285295
# test a fundrawtransaction with a VIN smaller than the required amount #
286296
#
297+
self.log.info("Test fundrawtxn with a vin < required amount")
287298
utx = get_unspent(self.nodes[2].listunspent(), 1)
288299

289300
inputs = [{'txid': utx['txid'], 'vout': utx['vout']}]
@@ -318,6 +329,7 @@ def test_two_vin(self):
318329
#
319330
# test a fundrawtransaction with two VINs #
320331
#
332+
self.log.info("Test fundrawtxn with 2 vins")
321333
utx = get_unspent(self.nodes[2].listunspent(), 1)
322334
utx2 = get_unspent(self.nodes[2].listunspent(), 5)
323335

@@ -353,6 +365,7 @@ def test_two_vin_two_vout(self):
353365
#
354366
# test a fundrawtransaction with two VINs and two vOUTs #
355367
#
368+
self.log.info("Test fundrawtxn with 2 vins and 2 vouts")
356369
utx = get_unspent(self.nodes[2].listunspent(), 1)
357370
utx2 = get_unspent(self.nodes[2].listunspent(), 5)
358371

@@ -380,7 +393,7 @@ def test_invalid_input(self):
380393
#
381394
# test a fundrawtransaction with invalid vin #
382395
#
383-
# invalid vin!
396+
self.log.info("Test fundrawtxn with an invalid vin")
384397
inputs = [
385398
{'txid': "1c7f966dab21119bac53213a2bc7532bff1fa844c124fd750a7d0b1332440bd1", 'vout': 0}]
386399
outputs = {self.nodes[0].getnewaddress(): 1.0}
@@ -393,6 +406,7 @@ def test_fee_p2pkh(self):
393406
#
394407
# compare fee of a standard pubkeyhash transaction
395408
#
409+
self.log.info("Test fundrawtxn p2pkh fee")
396410
inputs = []
397411
outputs = {self.nodes[1].getnewaddress(): 1.1}
398412
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
@@ -411,11 +425,18 @@ def test_fee_p2pkh_multi_out(self):
411425
# compare fee of a standard pubkeyhash transaction with multiple
412426
# outputs
413427
#
428+
self.log.info("Test fundrawtxn p2pkh fee with multiple outputs")
414429
inputs = []
415-
outputs = {self.nodes[1].getnewaddress(): 1.1, self.nodes[1].getnewaddress(): 1.2, self.nodes[1].getnewaddress(): 0.1, self.nodes[
416-
1].getnewaddress(): 1.3, self.nodes[1].getnewaddress(): 0.2, self.nodes[1].getnewaddress(): 0.3}
417-
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
418-
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
430+
outputs = {
431+
self.nodes[1].getnewaddress(): 1.1,
432+
self.nodes[1].getnewaddress(): 1.2,
433+
self.nodes[1].getnewaddress(): 0.1,
434+
self.nodes[1].getnewaddress(): 1.3,
435+
self.nodes[1].getnewaddress(): 0.2,
436+
self.nodes[1].getnewaddress(): 0.3,
437+
}
438+
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
439+
fundedTx = self.nodes[0].fundrawtransaction(rawtx)
419440
# create same transaction over sendtoaddress
420441
txId = self.nodes[0].sendmany("", outputs)
421442
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
@@ -456,6 +477,7 @@ def test_fee_4of5(self):
456477
#
457478
# compare fee of a standard pubkeyhash transaction
458479
#
480+
self.log.info("Test fundrawtxn fee with 4-of-5 addresses")
459481

460482
# create 4of5 addr
461483
addr1 = self.nodes[1].getnewaddress()
@@ -471,7 +493,15 @@ def test_fee_4of5(self):
471493
addr5Obj = self.nodes[1].getaddressinfo(addr5)
472494

473495
mSigObj = self.nodes[1].addmultisigaddress(
474-
4, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey'], addr4Obj['pubkey'], addr5Obj['pubkey']])['address']
496+
4,
497+
[
498+
addr1Obj['pubkey'],
499+
addr2Obj['pubkey'],
500+
addr3Obj['pubkey'],
501+
addr4Obj['pubkey'],
502+
addr5Obj['pubkey'],
503+
]
504+
)['address']
475505

476506
inputs = []
477507
outputs = {mSigObj: 1.1}
@@ -490,6 +520,7 @@ def test_spend_2of2(self):
490520
#
491521
# spend a 2of2 multisig transaction over fundraw
492522
#
523+
self.log.info("Test fundrawtxn spending 2-of-2 multisig")
493524

494525
# create 2of2 addr
495526
addr1 = self.nodes[2].getnewaddress()
@@ -499,7 +530,12 @@ def test_spend_2of2(self):
499530
addr2Obj = self.nodes[2].getaddressinfo(addr2)
500531

501532
mSigObj = self.nodes[2].addmultisigaddress(
502-
2, [addr1Obj['pubkey'], addr2Obj['pubkey']])['address']
533+
2,
534+
[
535+
addr1Obj['pubkey'],
536+
addr2Obj['pubkey'],
537+
]
538+
)['address']
503539

504540
# send 1.2 BCH to msig addr
505541
self.nodes[0].sendtoaddress(mSigObj, 1.2)
@@ -527,6 +563,8 @@ def test_locked_wallet(self):
527563
#
528564
# locked wallet test
529565
#
566+
self.log.info("Test fundrawtxn with locked wallet")
567+
530568
self.nodes[1].encryptwallet("test")
531569
self.stop_nodes()
532570

@@ -588,6 +626,7 @@ def test_many_inputs_fee(self):
588626
#
589627
# multiple (~19) inputs tx test | Compare fee #
590628
#
629+
self.log.info("Test fundrawtxn fee with many inputs")
591630

592631
# empty node1, send some small coins from node0 to node1
593632
self.nodes[1].sendtoaddress(
@@ -621,6 +660,7 @@ def test_many_inputs_send(self):
621660
#
622661
# multiple (~19) inputs tx test | sign/send #
623662
#
663+
self.log.info("Test fundrawtxn sign+send with many inputs")
624664

625665
# again, empty node1, send some small coins from node0 to node1
626666
self.nodes[1].sendtoaddress(
@@ -655,6 +695,7 @@ def test_op_return(self):
655695
#
656696
# test fundrawtransaction with OP_RETURN and no vin #
657697
#
698+
self.log.info("Test fundrawtxn with OP_RETURN and no vin")
658699

659700
rawTx = "0100000000010000000000000000066a047465737400000000"
660701
dec_tx = self.nodes[2].decoderawtransaction(rawTx)
@@ -674,6 +715,7 @@ def test_watchonly(self):
674715
#
675716
# test a fundrawtransaction using only watchonly #
676717
#
718+
self.log.info("Test fundrawtxn using only watchonly")
677719

678720
inputs = []
679721
outputs = {self.nodes[2].getnewaddress(): self.watchonly_amount / 2}
@@ -692,6 +734,7 @@ def test_all_watched_funds(self):
692734
#
693735
# test fundrawtransaction using the entirety of watched funds #
694736
#
737+
self.log.info("Test fundrawtxn using entirety of watched funds")
695738

696739
inputs = []
697740
outputs = {self.nodes[2].getnewaddress(): self.watchonly_amount}
@@ -721,6 +764,7 @@ def test_option_feerate(self):
721764
#
722765
# Test feeRate option #
723766
#
767+
self.log.info("Test fundrawtxn feeRate option")
724768

725769
# Make sure there is exactly one input so coin selection can't skew the
726770
# result
@@ -755,6 +799,7 @@ def test_address_reuse(self):
755799
#
756800
# Test no address reuse occurs #
757801
#
802+
self.log.info("Test fundrawtxn does not reuse addresses")
758803

759804
rawTx = self.nodes[3].createrawtransaction(
760805
inputs=[], outputs={self.nodes[3].getnewaddress(): 1})
@@ -773,6 +818,7 @@ def test_option_subtract_fee_from_outputs(self):
773818
#
774819
# Test subtractFeeFromOutputs option #
775820
#
821+
self.log.info("Test fundrawtxn subtractFeeFromOutputs option")
776822

777823
# Make sure there is exactly one input so coin selection can't skew the
778824
# result

0 commit comments

Comments
 (0)