Skip to content

Commit e65b416

Browse files
author
MarcoFalke
committed
Merge #17340: Tests: speed up fundrawtransaction test
af7bae7 [tests] Don't stop-start unnecessarily in rpc_fundrawtransaction.py (John Newbery) 9a85052 [tests] Use -whitelist in rpc_fundrawtransaction.py (John Newbery) 646b593 [tests] Speed up rpc_fundrawtransaction.py (John Newbery) Pull request description: Speed up rpc_fundrawtransaction.py Most of the time in rpc_fundrawtransaction.py is spent waiting for unconfirmed transactions to propagate. Net processing adds a poisson random delay to the time it will INV transactions with a mean interval of 5 seconds. Calls like the following: ``` self.nodes[2].sendrawtransaction(signedTx['hex']) self.sync_all() self.nodes[1].generate(1) ```` will therefore introduce a delay waiting for the mempools to sync. Instead just generate the block on the node that sent the transaction: ``` self.nodes[2].sendrawtransaction(signedTx['hex']) self.nodes[2].generate(1) ``` rpc_fundrawtransaction.py is not intended to be a test for transaction relay, so it's ok to do this. ACKs for top commit: MarcoFalke: ACK af7bae7 🛴 Tree-SHA512: db3407d871bfdc99a02e7304b07239dd3585ac47f27f020f1a70608b7f6386b134343c01f3e4d1c246ce734676755897671999695068d6388602fb042d178780
2 parents 976cc76 + af7bae7 commit e65b416

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

test/functional/rpc_fundrawtransaction.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class RawTransactionsTest(BitcoinTestFramework):
2828
def set_test_params(self):
2929
self.num_nodes = 4
3030
self.setup_clean_chain = True
31+
# This test isn't testing tx relay. Set whitelist on the peers for
32+
# instant tx relay.
33+
self.extra_args = [['-whitelist=127.0.0.1']] * self.num_nodes
3134

3235
def skip_test_if_missing_module(self):
3336
self.skip_if_no_wallet()
@@ -470,8 +473,7 @@ def test_spend_2of2(self):
470473

471474
# Send 1.2 BTC to msig addr.
472475
self.nodes[0].sendtoaddress(mSigObj, 1.2)
473-
self.sync_all()
474-
self.nodes[1].generate(1)
476+
self.nodes[0].generate(1)
475477
self.sync_all()
476478

477479
oldBalance = self.nodes[1].getbalance()
@@ -482,8 +484,7 @@ def test_spend_2of2(self):
482484

483485
signedTx = self.nodes[2].signrawtransactionwithwallet(fundedTx['hex'])
484486
self.nodes[2].sendrawtransaction(signedTx['hex'])
485-
self.sync_all()
486-
self.nodes[1].generate(1)
487+
self.nodes[2].generate(1)
487488
self.sync_all()
488489

489490
# Make sure funds are received at node1.
@@ -493,22 +494,6 @@ def test_locked_wallet(self):
493494
self.log.info("Test fundrawtxn with locked wallet")
494495

495496
self.nodes[1].encryptwallet("test")
496-
self.stop_nodes()
497-
498-
self.start_nodes()
499-
# This test is not meant to test fee estimation and we'd like
500-
# to be sure all txns are sent at a consistent desired feerate.
501-
for node in self.nodes:
502-
node.settxfee(self.min_relay_tx_fee)
503-
504-
connect_nodes(self.nodes[0], 1)
505-
connect_nodes(self.nodes[1], 2)
506-
connect_nodes(self.nodes[0], 2)
507-
connect_nodes(self.nodes[0], 3)
508-
# Again lock the watchonly UTXO or nodes[0] may spend it, because
509-
# lockunspent is memory-only and thus lost on restart.
510-
self.nodes[0].lockunspent(False, [{"txid": self.watchonly_txid, "vout": self.watchonly_vout}])
511-
self.sync_all()
512497

513498
# Drain the keypool.
514499
self.nodes[1].getnewaddress()
@@ -550,8 +535,7 @@ def test_many_inputs_fee(self):
550535

551536
# Empty node1, send some small coins from node0 to node1.
552537
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
553-
self.sync_all()
554-
self.nodes[0].generate(1)
538+
self.nodes[1].generate(1)
555539
self.sync_all()
556540

557541
for i in range(0,20):
@@ -579,8 +563,7 @@ def test_many_inputs_send(self):
579563

580564
# Again, empty node1, send some small coins from node0 to node1.
581565
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
582-
self.sync_all()
583-
self.nodes[0].generate(1)
566+
self.nodes[1].generate(1)
584567
self.sync_all()
585568

586569
for i in range(0,20):
@@ -597,8 +580,7 @@ def test_many_inputs_send(self):
597580
fundedTx = self.nodes[1].fundrawtransaction(rawtx)
598581
fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex'])
599582
self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex'])
600-
self.sync_all()
601-
self.nodes[0].generate(1)
583+
self.nodes[1].generate(1)
602584
self.sync_all()
603585
assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward
604586

0 commit comments

Comments
 (0)