0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-04 13:55:23 -05:00

Merge #20112: test: Speed up wallet_resendwallettransactions with mockscheduler RPC

fa299ac273 test: Speed up wallet_resendwallettransactions test with mockscheduler RPC (MarcoFalke)

Pull request description:

  Also fixes #20143

ACKs for top commit:
  guggero:
    ACK fa299ac2

Tree-SHA512: 024ced4aa5f5c266e24fd0583d47b45b19c2a6ae25a06fabeacaa0ac996eec0c45f11cc34b2df17d01759b78ed31a991aa86978aafcc76cb0017382f601bf85a
This commit is contained in:
MarcoFalke 2020-10-22 14:11:47 +02:00
commit 88271184e8
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25

View file

@ -11,6 +11,7 @@ from test_framework.p2p import P2PTxInvStore
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal from test_framework.util import assert_equal
class ResendWalletTransactionsTest(BitcoinTestFramework): class ResendWalletTransactionsTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 1 self.num_nodes = 1
@ -27,10 +28,10 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
txid = node.sendtoaddress(node.getnewaddress(), 1) txid = node.sendtoaddress(node.getnewaddress(), 1)
# Wallet rebroadcast is first scheduled 1 sec after startup (see # Wallet rebroadcast is first scheduled 1 sec after startup (see
# nNextResend in ResendWalletTransactions()). Sleep for just over a # nNextResend in ResendWalletTransactions()). Tell scheduler to call
# second to be certain that it has been called before the first # MaybeResendWalletTxn now to initialize nNextResend before the first
# setmocktime call below. # setmocktime call below.
time.sleep(1.1) node.mockscheduler(1)
# Can take a few seconds due to transaction trickling # Can take a few seconds due to transaction trickling
peer_first.wait_for_broadcast([txid]) peer_first.wait_for_broadcast([txid])
@ -57,15 +58,16 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
twelve_hrs = 12 * 60 * 60 twelve_hrs = 12 * 60 * 60
two_min = 2 * 60 two_min = 2 * 60
node.setmocktime(now + twelve_hrs - two_min) 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) assert_equal(int(txid, 16) in peer_second.get_invs(), False)
self.log.info("Bump time & check that transaction is rebroadcast") self.log.info("Bump time & check that transaction is rebroadcast")
# Transaction should be rebroadcast approximately 24 hours in the future, # Transaction should be rebroadcast approximately 24 hours in the future,
# but can range from 12-36. So bump 36 hours to be sure. # but can range from 12-36. So bump 36 hours to be sure.
node.setmocktime(now + 36 * 60 * 60) with node.assert_debug_log(['ResendWalletTransactions: resubmit 1 unconfirmed transactions']):
# Tell scheduler to call MaybeResendWalletTxn now. node.setmocktime(now + 36 * 60 * 60)
node.mockscheduler(1) # Tell scheduler to call MaybeResendWalletTxn now.
node.mockscheduler(1)
# Give some time for trickle to occur # Give some time for trickle to occur
node.setmocktime(now + 36 * 60 * 60 + 600) node.setmocktime(now + 36 * 60 * 60 + 600)
peer_second.wait_for_broadcast([txid]) peer_second.wait_for_broadcast([txid])