0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

test: Add test for erase orphan tx from peer

This commit is contained in:
Hennadii Stepanov 2020-06-27 13:13:51 +03:00
parent dd097c42df
commit 5c049780c8
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -60,7 +60,6 @@ class InvalidTxRequestTest(BitcoinTestFramework):
block.solve() block.solve()
# Save the coinbase for later # Save the coinbase for later
block1 = block block1 = block
tip = block.sha256
node.p2ps[0].send_blocks_and_test([block], node, success=True) node.p2ps[0].send_blocks_and_test([block], node, success=True)
self.log.info("Mature the block.") self.log.info("Mature the block.")
@ -157,6 +156,7 @@ class InvalidTxRequestTest(BitcoinTestFramework):
with node.assert_debug_log(['orphanage overflow, removed 1 tx']): with node.assert_debug_log(['orphanage overflow, removed 1 tx']):
node.p2ps[0].send_txs_and_test(orphan_tx_pool, node, success=False) node.p2ps[0].send_txs_and_test(orphan_tx_pool, node, success=False)
self.log.info('Test orphan with rejected parents')
rejected_parent = CTransaction() rejected_parent = CTransaction()
rejected_parent.vin.append(CTxIn(outpoint=COutPoint(tx_orphan_2_invalid.sha256, 0))) rejected_parent.vin.append(CTxIn(outpoint=COutPoint(tx_orphan_2_invalid.sha256, 0)))
rejected_parent.vout.append(CTxOut(nValue=11 * COIN, scriptPubKey=SCRIPT_PUB_KEY_OP_TRUE)) rejected_parent.vout.append(CTxOut(nValue=11 * COIN, scriptPubKey=SCRIPT_PUB_KEY_OP_TRUE))
@ -164,6 +164,10 @@ class InvalidTxRequestTest(BitcoinTestFramework):
with node.assert_debug_log(['not keeping orphan with rejected parents {}'.format(rejected_parent.hash)]): with node.assert_debug_log(['not keeping orphan with rejected parents {}'.format(rejected_parent.hash)]):
node.p2ps[0].send_txs_and_test([rejected_parent], node, success=False) node.p2ps[0].send_txs_and_test([rejected_parent], node, success=False)
self.log.info('Test that a peer disconnection causes erase its transactions from the orphan pool')
with node.assert_debug_log(['Erased 100 orphan tx from peer=25']):
self.reconnect_p2p(num_connections=1)
if __name__ == '__main__': if __name__ == '__main__':
InvalidTxRequestTest().main() InvalidTxRequestTest().main()