Skip to content

Commit 8827118

Browse files
author
MarcoFalke
committed
Merge bitcoin#20112: test: Speed up wallet_resendwallettransactions with mockscheduler RPC
fa299ac test: Speed up wallet_resendwallettransactions test with mockscheduler RPC (MarcoFalke) Pull request description: Also fixes bitcoin#20143 ACKs for top commit: guggero: ACK fa299ac Tree-SHA512: 024ced4aa5f5c266e24fd0583d47b45b19c2a6ae25a06fabeacaa0ac996eec0c45f11cc34b2df17d01759b78ed31a991aa86978aafcc76cb0017382f601bf85a
2 parents 7012db2 + fa299ac commit 8827118

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/functional/wallet_resendwallettransactions.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from test_framework.test_framework import BitcoinTestFramework
1212
from test_framework.util import assert_equal
1313

14+
1415
class ResendWalletTransactionsTest(BitcoinTestFramework):
1516
def set_test_params(self):
1617
self.num_nodes = 1
@@ -27,10 +28,10 @@ def run_test(self):
2728
txid = node.sendtoaddress(node.getnewaddress(), 1)
2829

2930
# Wallet rebroadcast is first scheduled 1 sec after startup (see
30-
# nNextResend in ResendWalletTransactions()). Sleep for just over a
31-
# second to be certain that it has been called before the first
31+
# nNextResend in ResendWalletTransactions()). Tell scheduler to call
32+
# MaybeResendWalletTxn now to initialize nNextResend before the first
3233
# setmocktime call below.
33-
time.sleep(1.1)
34+
node.mockscheduler(1)
3435

3536
# Can take a few seconds due to transaction trickling
3637
peer_first.wait_for_broadcast([txid])
@@ -57,15 +58,16 @@ def run_test(self):
5758
twelve_hrs = 12 * 60 * 60
5859
two_min = 2 * 60
5960
node.setmocktime(now + twelve_hrs - two_min)
60-
time.sleep(2) # ensure enough time has passed for rebroadcast attempt to occur
61+
node.mockscheduler(1) # Tell scheduler to call MaybeResendWalletTxn now
6162
assert_equal(int(txid, 16) in peer_second.get_invs(), False)
6263

6364
self.log.info("Bump time & check that transaction is rebroadcast")
6465
# Transaction should be rebroadcast approximately 24 hours in the future,
6566
# but can range from 12-36. So bump 36 hours to be sure.
66-
node.setmocktime(now + 36 * 60 * 60)
67-
# Tell scheduler to call MaybeResendWalletTxn now.
68-
node.mockscheduler(1)
67+
with node.assert_debug_log(['ResendWalletTransactions: resubmit 1 unconfirmed transactions']):
68+
node.setmocktime(now + 36 * 60 * 60)
69+
# Tell scheduler to call MaybeResendWalletTxn now.
70+
node.mockscheduler(1)
6971
# Give some time for trickle to occur
7072
node.setmocktime(now + 36 * 60 * 60 + 600)
7173
peer_second.wait_for_broadcast([txid])

0 commit comments

Comments
 (0)