user-1: Related question: Test that mempool reattempts delivery of locally submitted transaction
I tried running hidden RPC mockscheduler, I think it worked that day after relaunching nodes few times and trying different things. Today again I am not able to do the relay similar to unbroadcast test.

Start Node 1
Start Node 2 with Node 1 in addnode
Use sendtoaddress to send some bitcoin to own address in Node 2
Check transaction is in getrawmempool and 1 unbroadcast in getmempoolinfo
Node 1 doesn't have these transactions in getrawmempool
Restart nodes
Run this multiple times because its not doing anything: bitcoin-cli -regtest mockscheduler 900
Nothing changes in getrawmempool or getmempoolinfo

After reading lot of things I think the reason is Node 1 not sending getdata request based on:

With these changes, the mempool tracks locally submitted transactions & periodically reattempts initial broadcast. Transactions submitted via the wallet or RPC are added to an "unbroadcast" set & are removed when a peer sends a getdata request, or the transaction is removed from the mempool. Every 10-15 minutes, the node reattempts an initial broadcast.

https://github.com/bitcoin/bitcoin/pull/18038/
I checked the packets in Wireshark to see what's going on because debug=mempool and debug=net spams with so many things that are confusing. I found that Node 2 had sent getdata packet with 13 hashes:


getrawmempool returns txid and we see wtxid in Wireshark. I reversed one from Wireshark to get wtxid
INV: 9f5e3c78e1e6a4f7f12b1e876ba6dadfcf3df6812a3ac214dda2455284e0e079

WTXID: 79e0e0845245a2dd14c23a2a81f63dcfdfdaa66b871e2bf1f7a4e6e1783c5e9f

However getrawtransaction doesn't accept wtxid so I am not sure how to check if this transaction belongs to Node 1 or Node 2. I am guessing its Node 1's transaction.
I have no clue what's going wrong and why simple relay for a transaction is not working between these 2 nodes.

user48884: The steps that you have outlined don't make sense for what you are trying to achieve. You want to make sure that node 2 attempts to broadcast unbroadcasted transactions after 15 minutes. But node 2 and node 1 are connected when you do sendtoaddress, so the transaction that is not supposed to be broadcast is sent to node 1. That's not correct, and that's not what the test does.
To achieve the behavior that you want, you have to start node 2 without connecting it to node 1. They should be disconnected when you do the sendtoaddress. You should only be connecting the nodes after sendtoaddress completes. Then you should be able to observe the broadcast after 15 minutes behavior.

You are probably seeing node 1 doesn't have the transaction immediately after you do sendtoaddress because there is some delay between when the node processes the transaction and when it queues it to be broadcast to its peers. So if you are very fast on checking getrawmempool and getmempoolinfo`, then you will probably observe that the transaction is not broadcast yet. But this is a race condition, and it could be broadcast between your mempool checks and shutdown. This would then cause your later checks to fail.

-1: <p>Related question: <a href="https://bitcoin.stackexchange.com/questions/107830/test-that-mempool-reattempts-delivery-of-locally-submitted-transaction">Test that mempool reattempts delivery of locally submitted transaction</a></p>
<p>I tried running hidden RPC <code>mockscheduler</code>, I think it worked that day after relaunching nodes few times and trying different things. Today again I am not able to do the relay similar to unbroadcast test.</p>
<ol>
<li>Start Node 1</li>
<li>Start Node 2 with Node 1 in <code>addnode</code></li>
<li>Use <code>sendtoaddress</code> to send some bitcoin to own address in Node 2</li>
<li>Check transaction is in <code>getrawmempool</code> and 1 unbroadcast in <code>getmempoolinfo</code></li>
<li>Node 1 doesn't have these transactions in <code>getrawmempool</code></li>
<li>Restart nodes</li>
<li>Run this multiple times because its not doing anything: <code>bitcoin-cli -regtest mockscheduler 900</code></li>
<li>Nothing changes in <code>getrawmempool</code> or <code>getmempoolinfo</code></li>
</ol>
<p>After reading lot of things I think the reason is Node 1 not sending <code>getdata</code> request based on:</p>
<blockquote>
<p>With these changes, the mempool tracks locally submitted transactions &amp; periodically reattempts initial broadcast. Transactions submitted via the wallet or RPC are added to an &quot;unbroadcast&quot; set &amp; are removed when a peer sends a getdata request, or the transaction is removed from the mempool. Every 10-15 minutes, the node reattempts an initial broadcast.</p>
</blockquote>
<p><a href="https://github.com/bitcoin/bitcoin/pull/18038/" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/pull/18038/</a></p>
<p>I checked the packets in Wireshark to see what's going on because <code>debug=mempool</code> and <code>debug=net</code> spams with so many things that are confusing. I found that Node 2 had sent <code>getdata</code> packet with 13 hashes:</p>
<p><a href="https://i.stack.imgur.com/t7fFV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t7fFV.png" alt="wireshark-getdata" /></a></p>
<p><a href="https://i.stack.imgur.com/vRXdn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vRXdn.png" alt="wireshark-destination" /></a></p>
<p><code>getrawmempool</code> returns txid and we see <code>wtxid</code> in Wireshark. I reversed one from Wireshark to get <code>wtxid</code></p>
<pre><code>INV: 9f5e3c78e1e6a4f7f12b1e876ba6dadfcf3df6812a3ac214dda2455284e0e079

WTXID: 79e0e0845245a2dd14c23a2a81f63dcfdfdaa66b871e2bf1f7a4e6e1783c5e9f
</code></pre>
<p>However <code>getrawtransaction</code> doesn't accept wtxid so I am not sure how to check if this transaction belongs to Node 1 or Node 2. I am guessing its Node 1's transaction.</p>
<p>I have no clue what's going wrong and why simple relay for a transaction is not working between these 2 nodes.</p>
 48884: <p>The steps that you have outlined don't make sense for what you are trying to achieve. You want to make sure that node 2 attempts to broadcast unbroadcasted transactions after 15 minutes. But node 2 and node 1 are connected when you do <code>sendtoaddress</code>, so the transaction that is not supposed to be broadcast is sent to node 1. That's not correct, and that's not what the test does.</p>
<p>To achieve the behavior that you want, you have to start node 2 without connecting it to node 1. They should be disconnected when you do the <code>sendtoaddress</code>. You should only be connecting the nodes after <code>sendtoaddress</code> completes. Then you should be able to observe the broadcast after 15 minutes behavior.</p>
<hr />
<p>You are probably seeing node 1 doesn't have the transaction immediately after you do <code>sendtoaddress</code> because there is some delay between when the node processes the transaction and when it queues it to be broadcast to its peers. So if you are very fast on checking <code>getrawmempool</code> and getmempoolinfo`, then you will probably observe that the transaction is not broadcast yet. But this is a race condition, and it could be broadcast between your mempool checks and shutdown. This would then cause your later checks to fail.</p>
