Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_invalid_tx.py
Show All 28 Lines | |||||
class InvalidTxRequestTest(BitcoinTestFramework): | class InvalidTxRequestTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
def skip_test_if_missing_module(self): | |||||
self.skip_if_no_wallet() | |||||
def bootstrap_p2p(self, *, num_connections=1): | def bootstrap_p2p(self, *, num_connections=1): | ||||
"""Add a P2P connection to the node. | """Add a P2P connection to the node. | ||||
Helper to connect and wait for version handshake.""" | Helper to connect and wait for version handshake.""" | ||||
for _ in range(num_connections): | for _ in range(num_connections): | ||||
self.nodes[0].add_p2p_connection(P2PDataStore()) | self.nodes[0].add_p2p_connection(P2PDataStore()) | ||||
def reconnect_p2p(self, **kwargs): | def reconnect_p2p(self, **kwargs): | ||||
Show All 19 Lines | def run_test(self): | ||||
block = create_block(tip, create_coinbase(height), block_time) | block = create_block(tip, create_coinbase(height), block_time) | ||||
block.solve() | block.solve() | ||||
# Save the coinbase for later | # Save the coinbase for later | ||||
block1 = block | block1 = block | ||||
tip = block.sha256 | tip = block.sha256 | ||||
node.p2p.send_blocks_and_test([block], node, success=True) | node.p2p.send_blocks_and_test([block], node, success=True) | ||||
self.log.info("Mature the block.") | self.log.info("Mature the block.") | ||||
self.nodes[0].generate(100) | self.nodes[0].generatetoaddress( | ||||
100, self.nodes[0].get_deterministic_priv_key().address) | |||||
# b'\x64' is OP_NOTIF | # b'\x64' is OP_NOTIF | ||||
# Transaction will be rejected with code 16 (REJECT_INVALID) | # Transaction will be rejected with code 16 (REJECT_INVALID) | ||||
# and we get disconnected immediately | # and we get disconnected immediately | ||||
self.log.info('Test a transaction that is rejected') | self.log.info('Test a transaction that is rejected') | ||||
tx1 = create_tx_with_script( | tx1 = create_tx_with_script( | ||||
block1.vtx[0], 0, script_sig=b'\x64' * 35, amount=50 * COIN - 12000) | block1.vtx[0], 0, script_sig=b'\x64' * 35, amount=50 * COIN - 12000) | ||||
node.p2p.send_txs_and_test( | node.p2p.send_txs_and_test( | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |