mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-09 18:00:13 +02:00
[tests] 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.
This commit is contained in:
@ -470,8 +470,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Send 1.2 BTC to msig addr.
|
# Send 1.2 BTC to msig addr.
|
||||||
self.nodes[0].sendtoaddress(mSigObj, 1.2)
|
self.nodes[0].sendtoaddress(mSigObj, 1.2)
|
||||||
self.sync_all()
|
self.nodes[0].generate(1)
|
||||||
self.nodes[1].generate(1)
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
oldBalance = self.nodes[1].getbalance()
|
oldBalance = self.nodes[1].getbalance()
|
||||||
@ -482,8 +481,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
signedTx = self.nodes[2].signrawtransactionwithwallet(fundedTx['hex'])
|
signedTx = self.nodes[2].signrawtransactionwithwallet(fundedTx['hex'])
|
||||||
self.nodes[2].sendrawtransaction(signedTx['hex'])
|
self.nodes[2].sendrawtransaction(signedTx['hex'])
|
||||||
self.sync_all()
|
self.nodes[2].generate(1)
|
||||||
self.nodes[1].generate(1)
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
# Make sure funds are received at node1.
|
# Make sure funds are received at node1.
|
||||||
@ -550,8 +548,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Empty node1, send some small coins from node0 to node1.
|
# Empty node1, send some small coins from node0 to node1.
|
||||||
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
|
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
|
||||||
self.sync_all()
|
self.nodes[1].generate(1)
|
||||||
self.nodes[0].generate(1)
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
for i in range(0,20):
|
for i in range(0,20):
|
||||||
@ -579,8 +576,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Again, empty node1, send some small coins from node0 to node1.
|
# Again, empty node1, send some small coins from node0 to node1.
|
||||||
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
|
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
|
||||||
self.sync_all()
|
self.nodes[1].generate(1)
|
||||||
self.nodes[0].generate(1)
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
for i in range(0,20):
|
for i in range(0,20):
|
||||||
@ -597,8 +593,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
fundedTx = self.nodes[1].fundrawtransaction(rawtx)
|
fundedTx = self.nodes[1].fundrawtransaction(rawtx)
|
||||||
fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex'])
|
fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex'])
|
||||||
self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex'])
|
self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex'])
|
||||||
self.sync_all()
|
self.nodes[1].generate(1)
|
||||||
self.nodes[0].generate(1)
|
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward
|
assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user