mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge #17340: Tests: speed up fundrawtransaction test
af7bae734089f6af0029b0887932ccd9a469e12e [tests] Don't stop-start unnecessarily in rpc_fundrawtransaction.py (John Newbery)
9a8505299ba392acbab4647963113b0c29495f1d [tests] Use -whitelist in rpc_fundrawtransaction.py (John Newbery)
646b593bbd0db113c6e45ab92177b8f5251e8710 [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 af7bae734089f6af0029b0887932ccd9a469e12e 🛴
Tree-SHA512: db3407d871bfdc99a02e7304b07239dd3585ac47f27f020f1a70608b7f6386b134343c01f3e4d1c246ce734676755897671999695068d6388602fb042d178780
This commit is contained in:
parent
97308cf855
commit
cb1a2f3d5e
@ -29,6 +29,9 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
self.num_nodes = 4
|
||||
self.setup_clean_chain = True
|
||||
self.extra_args = [['-usehd=0']] * self.num_nodes
|
||||
# This test isn't testing tx relay. Set whitelist on the peers for
|
||||
# instant tx relay.
|
||||
self.extra_args = [['-whitelist=127.0.0.1']] * self.num_nodes
|
||||
|
||||
def skip_test_if_missing_module(self):
|
||||
self.skip_if_no_wallet()
|
||||
@ -457,8 +460,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
|
||||
# send 12 DASH to msig addr
|
||||
self.nodes[0].sendtoaddress(mSigObj, 12)
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(1)
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
oldBalance = self.nodes[1].getbalance()
|
||||
@ -469,8 +471,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
|
||||
signedTx = self.nodes[2].signrawtransactionwithwallet(fundedTx['hex'])
|
||||
self.nodes[2].sendrawtransaction(signedTx['hex'])
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(1)
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Make sure funds are received at node1.
|
||||
@ -480,22 +481,6 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
self.log.info("Test fundrawtxn with locked wallet")
|
||||
|
||||
self.nodes[1].encryptwallet("test")
|
||||
self.stop_nodes()
|
||||
|
||||
self.start_nodes()
|
||||
# This test is not meant to test fee estimation and we'd like
|
||||
# to be sure all txns are sent at a consistent desired feerate.
|
||||
for node in self.nodes:
|
||||
node.settxfee(self.min_relay_tx_fee)
|
||||
|
||||
connect_nodes(self.nodes[0], 1)
|
||||
connect_nodes(self.nodes[1], 2)
|
||||
connect_nodes(self.nodes[0], 2)
|
||||
connect_nodes(self.nodes[0], 3)
|
||||
# Again lock the watchonly UTXO or nodes[0] may spend it, because
|
||||
# lockunspent is memory-only and thus lost on restart.
|
||||
self.nodes[0].lockunspent(False, [{"txid": self.watchonly_txid, "vout": self.watchonly_vout}])
|
||||
self.sync_all()
|
||||
|
||||
# Drain the keypool.
|
||||
self.nodes[1].getnewaddress()
|
||||
@ -535,8 +520,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
|
||||
# Empty node1, send some small coins from node0 to node1.
|
||||
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
for i in range(0,20):
|
||||
@ -564,8 +548,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
|
||||
# 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.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
for i in range(0,20):
|
||||
@ -582,8 +565,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
fundedTx = self.nodes[1].fundrawtransaction(rawtx)
|
||||
fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex'])
|
||||
self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex'])
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
assert_equal(oldBalance+Decimal('500.19000000'), self.nodes[0].getbalance()) #0.19+block reward
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user