11
11
from test_framework .test_framework import BitcoinTestFramework
12
12
from test_framework .util import assert_equal
13
13
14
+
14
15
class ResendWalletTransactionsTest (BitcoinTestFramework ):
15
16
def set_test_params (self ):
16
17
self .num_nodes = 1
@@ -27,10 +28,10 @@ def run_test(self):
27
28
txid = node .sendtoaddress (node .getnewaddress (), 1 )
28
29
29
30
# 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
32
33
# setmocktime call below.
33
- time . sleep ( 1. 1 )
34
+ node . mockscheduler ( 1 )
34
35
35
36
# Can take a few seconds due to transaction trickling
36
37
peer_first .wait_for_broadcast ([txid ])
@@ -57,15 +58,16 @@ def run_test(self):
57
58
twelve_hrs = 12 * 60 * 60
58
59
two_min = 2 * 60
59
60
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
61
62
assert_equal (int (txid , 16 ) in peer_second .get_invs (), False )
62
63
63
64
self .log .info ("Bump time & check that transaction is rebroadcast" )
64
65
# Transaction should be rebroadcast approximately 24 hours in the future,
65
66
# 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 )
69
71
# Give some time for trickle to occur
70
72
node .setmocktime (now + 36 * 60 * 60 + 600 )
71
73
peer_second .wait_for_broadcast ([txid ])
0 commit comments