Skip to content

Commit

Permalink
Merge 8827118 into merged_master (Bitcoin PR #20112)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Dec 1, 2020
2 parents b70be17 + 8827118 commit 58fc391
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/functional/wallet_resendwallettransactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal


class ResendWalletTransactionsTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
Expand All @@ -27,10 +28,10 @@ def run_test(self):
txid = node.sendtoaddress(node.getnewaddress(), 1)

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

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

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

0 comments on commit 58fc391

Please sign in to comment.