Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_invalid_tx.py
| Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
| for BadTxTemplate in invalid_txs.iter_all_templates(): | for BadTxTemplate in invalid_txs.iter_all_templates(): | ||||
| self.log.info("Testing invalid transaction: %s", BadTxTemplate.__name__) | self.log.info("Testing invalid transaction: %s", BadTxTemplate.__name__) | ||||
| template = BadTxTemplate(spend_block=block1) | template = BadTxTemplate(spend_block=block1) | ||||
| tx = template.get_tx() | tx = template.get_tx() | ||||
| node.p2ps[0].send_txs_and_test( | node.p2ps[0].send_txs_and_test( | ||||
| [tx], | [tx], | ||||
| node, | node, | ||||
| success=False, | success=False, | ||||
| expect_disconnect=template.expect_disconnect, | |||||
| reject_reason=template.reject_reason, | reject_reason=template.reject_reason, | ||||
| ) | ) | ||||
| if template.expect_disconnect: | |||||
| self.log.info("Reconnecting to peer") | |||||
| self.reconnect_p2p() | |||||
| # Make two p2p connections to provide the node with orphans | # Make two p2p connections to provide the node with orphans | ||||
| # * p2ps[0] will send valid orphan txs (one with low fee) | # * p2ps[0] will send valid orphan txs (one with low fee) | ||||
| # * p2ps[1] will send an invalid orphan tx (and is later disconnected for that) | # * p2ps[1] will send an invalid orphan tx (and is later disconnected for that) | ||||
| self.reconnect_p2p(num_connections=2) | self.reconnect_p2p(num_connections=2) | ||||
| self.log.info("Test orphan transaction handling ... ") | self.log.info("Test orphan transaction handling ... ") | ||||
| # Create a root transaction that we withold until all dependend transactions | # Create a root transaction that we withold until all dependend transactions | ||||
| # are sent out and in the orphan cache | # are sent out and in the orphan cache | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
| tx_orphan_2_valid, | tx_orphan_2_valid, | ||||
| ] | ] | ||||
| } | } | ||||
| # Transactions that do not end up in the mempool | # Transactions that do not end up in the mempool | ||||
| # tx_orphan_no_fee, because it has too low fee (p2ps[0] is not disconnected for relaying that tx) | # tx_orphan_no_fee, because it has too low fee (p2ps[0] is not disconnected for relaying that tx) | ||||
| # tx_orphan_invaid, because it has negative fee (p2ps[1] is | # tx_orphan_invaid, because it has negative fee (p2ps[1] is | ||||
| # disconnected for relaying that tx) | # disconnected for relaying that tx) | ||||
| # p2ps[1] is no longer connected | |||||
| self.wait_until(lambda: 1 == len(node.getpeerinfo()), timeout=12) | |||||
| assert_equal(expected_mempool, set(node.getrawmempool())) | assert_equal(expected_mempool, set(node.getrawmempool())) | ||||
| self.log.info("Test orphan pool overflow") | self.log.info("Test orphan pool overflow") | ||||
| orphan_tx_pool = [CTransaction() for _ in range(101)] | orphan_tx_pool = [CTransaction() for _ in range(101)] | ||||
| for i in range(len(orphan_tx_pool)): | for i in range(len(orphan_tx_pool)): | ||||
| orphan_tx_pool[i].vin.append(CTxIn(outpoint=COutPoint(i, 333))) | orphan_tx_pool[i].vin.append(CTxIn(outpoint=COutPoint(i, 333))) | ||||
| orphan_tx_pool[i].vout.append( | orphan_tx_pool[i].vout.append( | ||||
| CTxOut(nValue=11 * COIN, scriptPubKey=SCRIPT_PUB_KEY_OP_TRUE) | CTxOut(nValue=11 * COIN, scriptPubKey=SCRIPT_PUB_KEY_OP_TRUE) | ||||
| ▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines | |||||