Skip to content

Commit 5c04978

Browse files
committed
test: Add test for erase orphan tx from peer
1 parent dd097c4 commit 5c04978

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/functional/p2p_invalid_tx.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def run_test(self):
6060
block.solve()
6161
# Save the coinbase for later
6262
block1 = block
63-
tip = block.sha256
6463
node.p2ps[0].send_blocks_and_test([block], node, success=True)
6564

6665
self.log.info("Mature the block.")
@@ -157,13 +156,18 @@ def run_test(self):
157156
with node.assert_debug_log(['orphanage overflow, removed 1 tx']):
158157
node.p2ps[0].send_txs_and_test(orphan_tx_pool, node, success=False)
159158

159+
self.log.info('Test orphan with rejected parents')
160160
rejected_parent = CTransaction()
161161
rejected_parent.vin.append(CTxIn(outpoint=COutPoint(tx_orphan_2_invalid.sha256, 0)))
162162
rejected_parent.vout.append(CTxOut(nValue=11 * COIN, scriptPubKey=SCRIPT_PUB_KEY_OP_TRUE))
163163
rejected_parent.rehash()
164164
with node.assert_debug_log(['not keeping orphan with rejected parents {}'.format(rejected_parent.hash)]):
165165
node.p2ps[0].send_txs_and_test([rejected_parent], node, success=False)
166166

167+
self.log.info('Test that a peer disconnection causes erase its transactions from the orphan pool')
168+
with node.assert_debug_log(['Erased 100 orphan tx from peer=25']):
169+
self.reconnect_p2p(num_connections=1)
170+
167171

168172
if __name__ == '__main__':
169173
InvalidTxRequestTest().main()

0 commit comments

Comments
 (0)