mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-10 19:43:13 +02:00
test: Add various low-level p2p tests
This commit is contained in:
@@ -118,6 +118,7 @@ class InvalidTxRequestTest(BitcoinTestFramework):
|
||||
tx_orphan_2_invalid = CTransaction()
|
||||
tx_orphan_2_invalid.vin.append(CTxIn(outpoint=COutPoint(tx_orphan_1.sha256, 2)))
|
||||
tx_orphan_2_invalid.vout.append(CTxOut(nValue=11 * COIN, scriptPubKey=SCRIPT_PUB_KEY_OP_TRUE))
|
||||
tx_orphan_2_invalid.calc_sha256()
|
||||
|
||||
self.log.info('Send the orphans ... ')
|
||||
# Send valid orphan txs from p2ps[0]
|
||||
@@ -148,6 +149,22 @@ class InvalidTxRequestTest(BitcoinTestFramework):
|
||||
wait_until(lambda: 1 == len(node.getpeerinfo()), timeout=12) # p2ps[1] is no longer connected
|
||||
assert_equal(expected_mempool, set(node.getrawmempool()))
|
||||
|
||||
self.log.info('Test orphan pool overflow')
|
||||
orphan_tx_pool = [CTransaction() for _ in range(101)]
|
||||
for i in range(len(orphan_tx_pool)):
|
||||
orphan_tx_pool[i].vin.append(CTxIn(outpoint=COutPoint(i, 333)))
|
||||
orphan_tx_pool[i].vout.append(CTxOut(nValue=11 * COIN, scriptPubKey=SCRIPT_PUB_KEY_OP_TRUE))
|
||||
|
||||
with node.assert_debug_log(['mapOrphan overflow, removed 1 tx']):
|
||||
node.p2p.send_txs_and_test(orphan_tx_pool, node, success=False)
|
||||
|
||||
rejected_parent = CTransaction()
|
||||
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.rehash()
|
||||
with node.assert_debug_log(['not keeping orphan with rejected parents {}'.format(rejected_parent.hash)]):
|
||||
node.p2p.send_txs_and_test([rejected_parent], node, success=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
InvalidTxRequestTest().main()
|
||||
|
Reference in New Issue
Block a user