test: add test for rebroadcast of transaction received via p2p #34359
pull mzumsande wants to merge 1 commits into bitcoin:master from mzumsande:202601_test_rebroadcast changing 1 files +50 −4-
mzumsande commented at 2:42 am on January 21, 2026: contributorThe wallet doesn’t only rebroadcast transactions it created, but also relevant transactions received via p2p. Since this is not self-evident, add test coverage for it.
-
DrahtBot added the label Tests on Jan 21, 2026
-
DrahtBot commented at 2:42 am on January 21, 2026: contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34359.
Reviews
See the guideline for information on the review process.
Type Reviewers ACK vasild If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #34581 (test: Set assert_debug_log timeout to 0 by maflcko)
- #34533 (wallet: resubmit transactions with private broadcast if enabled by vasild)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
-
mzumsande force-pushed on Jan 21, 2026
-
DrahtBot added the label CI failed on Jan 21, 2026
-
vasild commented at 11:30 am on January 22, 2026: contributor
2026-01-21T03:34:27.4304152Z [0;36m test 2026-01-21T03:34:27.140268Z TestFramework (INFO): node0 sends a tx to node1 and disconnects [0m … 2026-01-21T03:34:27.4319719Z [0;34m node0 2026-01-21T03:34:27.149584Z (mocktime: 2026-02-07T03:50:31Z) [httpworker.1] [wallet/wallet.h:938] [WalletLogPrintf] [default_wallet] Submitting wtx c255f5b61919a60877d4e91eb81f656f85e743513119f5ddcc9cffc4ffb62b45 to mempool and for broadcast to peers [0m … 2026-01-21T03:34:27.4320508Z [0;34m node0 2026-01-21T03:34:27.149947Z (mocktime: 2026-02-07T03:50:31Z) [httpworker.1] [wallet/wallet.h:938] [WalletLogPrintf] [default_wallet] CommitTransaction(): Transaction cannot be broadcast immediately, bad-txns-inputs-missingorspent [0m
So,
node0did not like the transaction it generated and failed to broadcast it tonode1:bad-txns-inputs-missingorspent. Happens only sometimes. -
mzumsande commented at 12:03 pm on January 22, 2026: contributoryes - because of the wallet bug, the wallet creates an invalid transaction, trying to double-spend an utxo that was already used in a block. The node then rejects that tx obviously, and the rpc querying for the tx fails. I’ll rebase on #34358 with the next push. [Edit:done now]
-
mzumsande force-pushed on Jan 26, 2026
-
DrahtBot removed the label CI failed on Jan 26, 2026
-
mzumsande force-pushed on Jan 29, 2026
-
mzumsande marked this as ready for review on Jan 29, 2026
-
in test/functional/wallet_resendwallettransactions.py:156 in 5c9dedf1ef
147@@ -144,6 +148,44 @@ def run_test(self): 148 node.getmempoolentry(txid) 149 node.getmempoolentry(child_txid) 150 151+ self.log.info("Test rebroadcast of transactions received by others") 152+ # clear mempool 153+ self.generate(node, 1, sync_fun=self.no_op) 154+ # Sync node1's mocktime to node0's before connecting so it accepts node0's blocks 155+ node1 = self.nodes[1] 156+ node1.setmocktime(evict_time + 36 * 60 * 60)
vasild commented at 1:24 pm on February 4, 2026:evict_time + 36 * 60 * 60is used above, on line 146, to set the time onnodes[0]. Then repeated here. Maybe put that expression in a variable and use the variable in both places to make it obvious that both should be the same. Will be less fragile as well.
mzumsande commented at 10:22 am on February 9, 2026:I decided to just put36 * 60 * 60into a constant, because that is used all over the test.in test/functional/wallet_resendwallettransactions.py:183 in 5c9dedf1ef
178+ self.log.info("Connect p2p who hasn't seen the tx") 179+ peer = node1.add_p2p_connection(P2PTxInvStore()) 180+ 181+ self.log.info("Check that rebroadcast happens after 36 hours") 182+ with node1.assert_debug_log(['resubmit 1 unconfirmed transactions']): 183+ node1.bumpmocktime(36 * 60 * 60)
vasild commented at 2:01 pm on February 4, 2026:Maybe refer to
CWallet::SetNextResend()to make it easier to get to know where these 36 hours come from. E.g.:0 node1.bumpmocktime(36 * 60 * 60) # see CWallet::SetNextResend()
mzumsande commented at 10:23 am on February 9, 2026:put36 * 60 * 60into a constant and added an explanation there.in test/functional/wallet_resendwallettransactions.py:172 in 5c9dedf1ef outdated
167+ assert_equal(wallet_tx["confirmations"], 0) 168+ recv_wtxid = node1.getmempoolentry(recv_txid)["wtxid"] 169+ self.disconnect_nodes(0, 1) 170+ 171+ self.log.info("Create a block without the transaction") 172+ node1.bumpmocktime(6 * 60)
vasild commented at 2:09 pm on February 4, 2026:0+ # The transaction must be at least 5 minutes older than the latest block, 1+ # see CWallet::ResubmitWalletTransactions() 2 node1.bumpmocktime(6 * 60)
mzumsande commented at 10:24 am on February 9, 2026:done (a bit shorter because it is already explained in the first part in more detail).vasild approvedvasild commented at 2:15 pm on February 4, 2026: contributorACK 5c9dedf1efbc8810758f0e0fad7c97860f8da703b2c9eac583test: add test for rebroadcast of transaction received via p2p
The wallet doesn't only rebroadcast transactions it created, but also relevant transactions received via p2p. Since this is not self-evident, add test coverage for it.
mzumsande force-pushed on Feb 9, 2026vasild approvedvasild commented at 9:55 am on February 13, 2026: contributorACK b2c9eac583c6d3e25854c82e207d61e296891fd7DrahtBot added the label Needs rebase on Feb 18, 2026DrahtBot commented at 5:05 pm on February 18, 2026: contributor🐙 This pull request conflicts with the target branch and needs rebase.Labels
Tests Needs rebase
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-20 18:13 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me