diff --git a/test/functional/abc-get-invalid-block.py b/test/functional/abc-get-invalid-block.py --- a/test/functional/abc-get-invalid-block.py +++ b/test/functional/abc-get-invalid-block.py @@ -23,7 +23,7 @@ def run_test(self): node = self.nodes[0] - node.add_p2p_connection(P2PInterface()) + peer = node.add_p2p_connection(P2PInterface()) chaintip = node.getbestblockhash() # Mine some blocks and invalidate them @@ -35,9 +35,9 @@ # Clear any old messages with p2p_lock: - node.p2p.last_message.pop("block", None) - node.p2p.last_message.pop("cmpctblock", None) - node.p2p.last_message.pop("headers", None) + peer.last_message.pop("block", None) + peer.last_message.pop("cmpctblock", None) + peer.last_message.pop("headers", None) # Requests for the invalidated block and it's decendants should fail. # Not doing so is a potential DoS vector. @@ -50,26 +50,26 @@ with node.assert_debug_log(expected_msgs=["getblocks -1 to"]): msg = msg_getblocks() msg.locator.vHave = [block_hash] - node.p2p.send_message(msg) - node.p2p.sync_with_ping() + peer.send_message(msg) + peer.sync_with_ping() with node.assert_debug_log(expected_msgs=["ignoring request from peer=0 for old block that isn't in the main chain"]): msg = msg_getdata() msg.inv.append(CInv(MSG_BLOCK, block_hash)) - node.p2p.send_message(msg) - node.p2p.sync_with_ping() + peer.send_message(msg) + peer.sync_with_ping() with node.assert_debug_log(expected_msgs=["ignoring request from peer=0 for old block that isn't in the main chain"]): msg = msg_getdata() msg.inv.append(CInv(MSG_CMPCT_BLOCK, block_hash)) - node.p2p.send_message(msg) - node.p2p.sync_with_ping() + peer.send_message(msg) + peer.sync_with_ping() with node.assert_debug_log(expected_msgs=["ignoring request from peer=0 for old block header that isn't in the main chain"]): msg = msg_getheaders() msg.hashstop = block_hash - node.p2p.send_message(msg) - node.p2p.sync_with_ping() + peer.send_message(msg) + peer.sync_with_ping() if __name__ == '__main__': diff --git a/test/functional/abc-invalid-chains.py b/test/functional/abc-invalid-chains.py --- a/test/functional/abc-invalid-chains.py +++ b/test/functional/abc-invalid-chains.py @@ -48,7 +48,7 @@ def run_test(self): node = self.nodes[0] - node.add_p2p_connection(P2PDataStore()) + peer = node.add_p2p_connection(P2PDataStore()) self.genesis_hash = int(node.getbestblockhash(), 16) self.block_heights[self.genesis_hash] = 0 @@ -67,7 +67,7 @@ # -- 15 - 16 - 17 - 18 # Generate some valid blocks - node.p2p.send_blocks_and_test([block(0), block(1), block(2)], node) + peer.send_blocks_and_test([block(0), block(1), block(2)], node) # Explicitly invalidate blocks 1 and 2 # See below for why we do this @@ -78,11 +78,11 @@ # Mining on top of blocks 1 or 2 is rejected self.set_tip(1) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [block(11)], node, success=False, force_send=True, reject_reason='bad-prevblk') self.set_tip(2) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [block(21)], node, success=False, force_send=True, reject_reason='bad-prevblk') # Reconsider block 2 to remove invalid status from *both* 1 and 2 @@ -94,16 +94,16 @@ # Mining on the block 1 chain should be accepted # (needs to mine two blocks because less-work chains are not processed) self.set_tip(1) - node.p2p.send_blocks_and_test([block(12), block(13)], node) + peer.send_blocks_and_test([block(12), block(13)], node) # Mining on the block 2 chain should still be accepted # (needs to mine two blocks because less-work chains are not processed) self.set_tip(2) - node.p2p.send_blocks_and_test([block(22), block(221)], node) + peer.send_blocks_and_test([block(22), block(221)], node) # Mine more blocks from block 22 to be longest chain self.set_tip(22) - node.p2p.send_blocks_and_test([block(23), block(24)], node) + peer.send_blocks_and_test([block(23), block(24)], node) # Sanity checks assert_equal(self.blocks[24].hash, node.getbestblockhash()) @@ -116,17 +116,17 @@ # Mining on the block 2 chain should be rejected self.set_tip(24) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [block(25)], node, success=False, force_send=True, reject_reason='bad-prevblk') # Continued mining on the block 1 chain is still ok self.set_tip(13) - node.p2p.send_blocks_and_test([block(14)], node) + peer.send_blocks_and_test([block(14)], node) # Mining on a once-valid chain forking from block 2's longest chain, # which is now invalid, should also be rejected. self.set_tip(221) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [block(222)], node, success=False, force_send=True, reject_reason='bad-prevblk') self.log.info( @@ -134,7 +134,7 @@ # Reorg out 14 with four blocks. self.set_tip(13) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [block(15), block(16), block(17), block(18)], node) # Invalidate 17 (so 18 now has failed parent) diff --git a/test/functional/abc-mempool-coherence-on-activations.py b/test/functional/abc-mempool-coherence-on-activations.py --- a/test/functional/abc-mempool-coherence-on-activations.py +++ b/test/functional/abc-mempool-coherence-on-activations.py @@ -156,7 +156,7 @@ def run_test(self): node = self.nodes[0] - node.add_p2p_connection(P2PDataStore()) + peer = node.add_p2p_connection(P2PDataStore()) node.setmocktime(ACTIVATION_TIME) self.genesis_hash = int(node.getbestblockhash(), 16) @@ -212,7 +212,7 @@ # Create a new block block(0) save_spendable_output() - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) # Now we need that block to mature so we can spend the coinbase. maturity_blocks = [] @@ -220,7 +220,7 @@ block(5000 + i) maturity_blocks.append(self.tip) save_spendable_output() - node.p2p.send_blocks_and_test(maturity_blocks, node) + peer.send_blocks_and_test(maturity_blocks, node) # collect spendable outputs now to avoid cluttering the code later on out = [] @@ -241,10 +241,10 @@ bfork = block(5555) bfork.nTime = ACTIVATION_TIME - 1 update_block(5555, [txfund0, txfund1, txfund2, txfund3]) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) for i in range(5): - node.p2p.send_blocks_and_test([block(5200 + i)], node) + peer.send_blocks_and_test([block(5200 + i)], node) # Check we are just before the activation time assert_equal( @@ -271,7 +271,7 @@ # pre-fork-only txn. block(5556) update_block(5556, [tx_chain0, tx_pre0]) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) forkblockid = node.getbestblockhash() # Check we just activated the fork @@ -296,7 +296,7 @@ # Mine the 2nd always-valid chained txn and a post-fork-only txn. block(5557) update_block(5557, [tx_chain1, tx_post0]) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) postforkblockid = node.getbestblockhash() # The mempool contains the 3rd chained txn and a post-fork-only txn. check_mempool_equal([tx_chain2, tx_post1]) @@ -355,7 +355,7 @@ reorg_blocks.append(block(5900 + i)) # Perform the reorg - node.p2p.send_blocks_and_test(reorg_blocks, node) + peer.send_blocks_and_test(reorg_blocks, node) # reorg finishes after the fork assert_equal( node.getblockchaininfo()['mediantime'], diff --git a/test/functional/abc-minimaldata.py b/test/functional/abc-minimaldata.py --- a/test/functional/abc-minimaldata.py +++ b/test/functional/abc-minimaldata.py @@ -47,20 +47,13 @@ self.block_heights = {} self.extra_args = [['-acceptnonstdtxn=1']] - def bootstrap_p2p(self, *, num_connections=1): - """Add a P2P connection to the node. - - Helper to connect and wait for version handshake.""" - for _ in range(num_connections): - self.nodes[0].add_p2p_connection(P2PDataStore()) - - def reconnect_p2p(self, **kwargs): + def reconnect_p2p(self): """Tear down and bootstrap the P2P connection to the node. The node gets disconnected several times in this test. This helper method reconnects the p2p and restarts the network thread.""" self.nodes[0].disconnect_p2ps() - self.bootstrap_p2p(**kwargs) + self.nodes[0].add_p2p_connection(P2PDataStore()) def getbestblock(self, node): """Get the best block. Register its height so we can use build_block.""" @@ -92,7 +85,7 @@ """Check we are disconnected when sending a txn that the node rejects. (Can't actually get banned, since bitcoind won't ban local peers.)""" - self.nodes[0].p2p.send_txs_and_test( + self.nodes[0].p2ps[0].send_txs_and_test( [tx], self.nodes[0], success=False, expect_disconnect=True, reject_reason=reject_reason) self.reconnect_p2p() @@ -100,14 +93,14 @@ """Check we are disconnected when sending a block that the node rejects. (Can't actually get banned, since bitcoind won't ban local peers.)""" - self.nodes[0].p2p.send_blocks_and_test( + self.nodes[0].p2ps[0].send_blocks_and_test( [block], self.nodes[0], success=False, reject_reason=reject_reason, expect_disconnect=True) self.reconnect_p2p() def run_test(self): node, = self.nodes - self.bootstrap_p2p() + self.nodes[0].add_p2p_connection(P2PDataStore()) tip = self.getbestblock(node) @@ -116,7 +109,7 @@ for _ in range(10): tip = self.build_block(tip) blocks.append(tip) - node.p2p.send_blocks_and_test(blocks, node, success=True) + node.p2ps[0].send_blocks_and_test(blocks, node, success=True) spendable_outputs = [block.vtx[0] for block in blocks] self.log.info("Mature the blocks and get out of IBD.") @@ -159,7 +152,7 @@ nonminimaltx = create_fund_and_spend_tx() tip = self.build_block(tip, fundings) - node.p2p.send_blocks_and_test([tip], node) + node.p2ps[0].send_blocks_and_test([tip], node) self.log.info("Trying to mine a minimaldata violation.") self.check_for_ban_on_rejected_block( @@ -173,7 +166,7 @@ self.log.info("Mine a normal block") tip = self.build_block(tip) - node.p2p.send_blocks_and_test([tip], node) + node.p2ps[0].send_blocks_and_test([tip], node) if __name__ == '__main__': diff --git a/test/functional/abc-replay-protection.py b/test/functional/abc-replay-protection.py --- a/test/functional/abc-replay-protection.py +++ b/test/functional/abc-replay-protection.py @@ -94,7 +94,7 @@ def run_test(self): node = self.nodes[0] - node.add_p2p_connection(P2PDataStore()) + peer = node.add_p2p_connection(P2PDataStore()) node.setmocktime(REPLAY_PROTECTION_START_TIME) self.genesis_hash = int(node.getbestblockhash(), 16) @@ -132,7 +132,7 @@ # Create a new block block(0) save_spendable_output() - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) # Now we need that block to mature so we can spend the coinbase. maturity_blocks = [] @@ -140,7 +140,7 @@ block(5000 + i) maturity_blocks.append(self.tip) save_spendable_output() - node.p2p.send_blocks_and_test(maturity_blocks, node) + peer.send_blocks_and_test(maturity_blocks, node) # collect spendable outputs now to avoid cluttering the code later on out = [] @@ -189,7 +189,7 @@ # And txns get mined in a block properly. block(1) update_block(1, txns) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) # Replay protected transactions are rejected. replay_txns = create_fund_and_spend_tx(out[1], 0xffdead) @@ -200,7 +200,7 @@ # And block containing them are rejected as well. block(2) update_block(2, replay_txns) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [self.tip], node, success=False, reject_reason='blk-bad-inputs') # Rewind bad block @@ -210,13 +210,13 @@ bfork = block(5555) bfork.nTime = REPLAY_PROTECTION_START_TIME - 1 update_block(5555, []) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) activation_blocks = [] for i in range(5): block(5100 + i) activation_blocks.append(self.tip) - node.p2p.send_blocks_and_test(activation_blocks, node) + peer.send_blocks_and_test(activation_blocks, node) # Check we are just before the activation time assert_equal( @@ -229,7 +229,7 @@ block(3) update_block(3, replay_txns) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [self.tip], node, success=False, reject_reason='blk-bad-inputs') # Rewind bad block @@ -243,7 +243,7 @@ # Activate the replay protection block(5556) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) # Check we just activated the replay protection assert_equal( @@ -262,7 +262,7 @@ # They also cannot be mined block(4) update_block(4, txns) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [self.tip], node, success=False, reject_reason='blk-bad-inputs') # Rewind bad block @@ -294,7 +294,7 @@ # They also can also be mined block(5) update_block(5, replay_txns) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) # Ok, now we check if a reorg work properly across the activation. postforkblockid = node.getbestblockhash() diff --git a/test/functional/abc-schnorr.py b/test/functional/abc-schnorr.py --- a/test/functional/abc-schnorr.py +++ b/test/functional/abc-schnorr.py @@ -66,20 +66,13 @@ self.extra_args = [[ "-acceptnonstdtxn=1"]] - def bootstrap_p2p(self, *, num_connections=1): - """Add a P2P connection to the node. - - Helper to connect and wait for version handshake.""" - for _ in range(num_connections): - self.nodes[0].add_p2p_connection(P2PDataStore()) - - def reconnect_p2p(self, **kwargs): + def reconnect_p2p(self): """Tear down and bootstrap the P2P connection to the node. The node gets disconnected several times in this test. This helper method reconnects the p2p and restarts the network thread.""" self.nodes[0].disconnect_p2ps() - self.bootstrap_p2p(**kwargs) + self.nodes[0].add_p2p_connection(P2PDataStore()) def getbestblock(self, node): """Get the best block. Register its height so we can use build_block.""" @@ -111,7 +104,7 @@ """Check we are disconnected when sending a txn that the node rejects. (Can't actually get banned, since bitcoind won't ban local peers.)""" - self.nodes[0].p2p.send_txs_and_test( + self.nodes[0].p2ps[0].send_txs_and_test( [tx], self.nodes[0], success=False, reject_reason=reject_reason, expect_disconnect=True) self.reconnect_p2p() @@ -119,14 +112,14 @@ """Check we are disconnected when sending a block that the node rejects. (Can't actually get banned, since bitcoind won't ban local peers.)""" - self.nodes[0].p2p.send_blocks_and_test( + self.nodes[0].p2ps[0].send_blocks_and_test( [block], self.nodes[0], success=False, reject_reason=reject_reason, expect_disconnect=True) self.reconnect_p2p() def run_test(self): node, = self.nodes - self.bootstrap_p2p() + self.nodes[0].add_p2p_connection(P2PDataStore()) tip = self.getbestblock(node) @@ -135,7 +128,7 @@ for _ in range(10): tip = self.build_block(tip) blocks.append(tip) - node.p2p.send_blocks_and_test(blocks, node, success=True) + node.p2ps[0].send_blocks_and_test(blocks, node, success=True) spendable_outputs = [block.vtx[0] for block in blocks] self.log.info("Mature the blocks and get out of IBD.") @@ -201,10 +194,11 @@ sig64multisigtx = create_fund_and_spend_tx(multi=True, sig=sig64) tip = self.build_block(tip, fundings) - node.p2p.send_blocks_and_test([tip], node) + node.p2ps[0].send_blocks_and_test([tip], node) self.log.info("Typical ECDSA and Schnorr CHECKSIG are valid.") - node.p2p.send_txs_and_test([schnorrchecksigtx, ecdsachecksigtx], node) + node.p2ps[0].send_txs_and_test( + [schnorrchecksigtx, ecdsachecksigtx], node) # They get mined as usual. node.generatetoaddress(1, node.get_deterministic_priv_key().address) tip = self.getbestblock(node) diff --git a/test/functional/abc-schnorrmultisig.py b/test/functional/abc-schnorrmultisig.py --- a/test/functional/abc-schnorrmultisig.py +++ b/test/functional/abc-schnorrmultisig.py @@ -68,20 +68,13 @@ self.block_heights = {} self.extra_args = [["-acceptnonstdtxn=1"]] - def bootstrap_p2p(self, *, num_connections=1): - """Add a P2P connection to the node. - - Helper to connect and wait for version handshake.""" - for _ in range(num_connections): - self.nodes[0].add_p2p_connection(P2PDataStore()) - - def reconnect_p2p(self, **kwargs): + def reconnect_p2p(self): """Tear down and bootstrap the P2P connection to the node. The node gets disconnected several times in this test. This helper method reconnects the p2p and restarts the network thread.""" self.nodes[0].disconnect_p2ps() - self.bootstrap_p2p(**kwargs) + self.nodes[0].add_p2p_connection(P2PDataStore()) def getbestblock(self, node): """Get the best block. Register its height so we can use build_block.""" @@ -113,7 +106,7 @@ """Check we are disconnected when sending a txn that the node rejects. (Can't actually get banned, since bitcoind won't ban local peers.)""" - self.nodes[0].p2p.send_txs_and_test( + self.nodes[0].p2ps[0].send_txs_and_test( [tx], self.nodes[0], success=False, expect_disconnect=True, reject_reason=reject_reason) self.reconnect_p2p() @@ -121,14 +114,14 @@ """Check we are disconnected when sending a block that the node rejects. (Can't actually get banned, since bitcoind won't ban local peers.)""" - self.nodes[0].p2p.send_blocks_and_test( + self.nodes[0].p2ps[0].send_blocks_and_test( [block], self.nodes[0], success=False, reject_reason=reject_reason, expect_disconnect=True) self.reconnect_p2p() def run_test(self): node, = self.nodes - self.bootstrap_p2p() + self.nodes[0].add_p2p_connection(P2PDataStore()) tip = self.getbestblock(node) @@ -137,7 +130,7 @@ for _ in range(10): tip = self.build_block(tip) blocks.append(tip) - node.p2p.send_blocks_and_test(blocks, node, success=True) + node.p2ps[0].send_blocks_and_test(blocks, node, success=True) spendable_outputs = [block.vtx[0] for block in blocks] self.log.info("Mature the blocks and get out of IBD.") @@ -201,10 +194,10 @@ schnorr1tx = create_fund_and_spend_tx(OP_1, 'schnorr') tip = self.build_block(tip, fundings) - node.p2p.send_blocks_and_test([tip], node) + node.p2ps[0].send_blocks_and_test([tip], node) self.log.info("Send a legacy ECDSA multisig into mempool.") - node.p2p.send_txs_and_test([ecdsa0tx], node) + node.p2ps[0].send_txs_and_test([ecdsa0tx], node) assert_equal(node.getrawmempool(), [ecdsa0tx.hash]) self.log.info("Trying to mine a non-null-dummy ECDSA.") @@ -219,17 +212,17 @@ self.log.info( "Submitting a Schnorr-multisig via net, and mining it in a block") - node.p2p.send_txs_and_test([schnorr1tx], node) + node.p2ps[0].send_txs_and_test([schnorr1tx], node) assert_equal(set(node.getrawmempool()), { ecdsa0tx.hash, schnorr1tx.hash}) tip = self.build_block(tip, [schnorr1tx]) - node.p2p.send_blocks_and_test([tip], node) + node.p2ps[0].send_blocks_and_test([tip], node) self.log.info( "That legacy ECDSA multisig is still in mempool, let's mine it") assert_equal(node.getrawmempool(), [ecdsa0tx.hash]) tip = self.build_block(tip, [ecdsa0tx]) - node.p2p.send_blocks_and_test([tip], node) + node.p2ps[0].send_blocks_and_test([tip], node) assert_equal(node.getrawmempool(), []) self.log.info( diff --git a/test/functional/abc-segwit-recovery.py b/test/functional/abc-segwit-recovery.py --- a/test/functional/abc-segwit-recovery.py +++ b/test/functional/abc-segwit-recovery.py @@ -98,25 +98,7 @@ self.blocks[number] = block return block - def bootstrap_p2p(self, *, num_connections=1): - """Add a P2P connection to the node. - - Helper to connect and wait for version handshake.""" - for node in self.nodes: - for _ in range(num_connections): - node.add_p2p_connection(P2PDataStore()) - - def reconnect_p2p(self, **kwargs): - """Tear down and bootstrap the P2P connection to the node. - - The node gets disconnected several times in this test. This helper - method reconnects the p2p and restarts the network thread.""" - for node in self.nodes: - node.disconnect_p2ps() - self.bootstrap_p2p(**kwargs) - def run_test(self): - self.bootstrap_p2p() self.genesis_hash = int(self.nodes[0].getbestblockhash(), 16) self.block_heights[self.genesis_hash] = 0 spendable_outputs = [] @@ -126,6 +108,9 @@ node_nonstd = self.nodes[0] node_std = self.nodes[1] + peer_nonstd = node_nonstd.add_p2p_connection(P2PDataStore()) + peer_std = node_std.add_p2p_connection(P2PDataStore()) + # save the current tip so it can be spent by a later block def save_spendable_output(): spendable_outputs.append(self.tip) @@ -134,10 +119,6 @@ def get_spendable_output(): return PreviousSpendableOutput(spendable_outputs.pop(0).vtx[0], 0) - # submit current tip and check it was accepted - def accepted(node): - node.p2p.send_blocks_and_test([self.tip], node) - # adds transactions to the block and updates state def update_block(block_number, new_transactions): block = self.blocks[block_number] @@ -202,15 +183,10 @@ return txfund, txspend - # Check we are not banned when sending a txn that is rejected. - def check_for_no_ban_on_rejected_tx(node, tx, reject_reason): - node.p2p.send_txs_and_test( - [tx], node, success=False, reject_reason=reject_reason) - # Create a new block block(0) save_spendable_output() - accepted(node_nonstd) + peer_nonstd.send_blocks_and_test([self.tip], node_nonstd) # Now we need that block to mature so we can spend the coinbase. matureblocks = [] @@ -218,7 +194,7 @@ block(5000 + i) matureblocks.append(self.tip) save_spendable_output() - node_nonstd.p2p.send_blocks_and_test(matureblocks, node_nonstd) + peer_nonstd.send_blocks_and_test(matureblocks, node_nonstd) # collect spendable outputs now to avoid cluttering the code later on out = [] @@ -234,21 +210,21 @@ # nonstandard. block(5555) update_block(5555, [txfund, txfund_case0]) - accepted(node_nonstd) + peer_nonstd.send_blocks_and_test([self.tip], node_nonstd) # Check both nodes are synchronized before continuing. self.sync_blocks() # Check that upgraded nodes checking for standardness are not banning # nodes sending segwit spending txns. - check_for_no_ban_on_rejected_tx( - node_nonstd, txspend, CLEANSTACK_ERROR) - check_for_no_ban_on_rejected_tx( - node_nonstd, txspend_case0, EVAL_FALSE_ERROR) - check_for_no_ban_on_rejected_tx( - node_std, txspend, CLEANSTACK_ERROR) - check_for_no_ban_on_rejected_tx( - node_std, txspend_case0, EVAL_FALSE_ERROR) + peer_nonstd.send_txs_and_test([txspend], node_nonstd, success=False, + reject_reason=CLEANSTACK_ERROR) + peer_nonstd.send_txs_and_test([txspend_case0], node_nonstd, success=False, + reject_reason=EVAL_FALSE_ERROR) + peer_std.send_txs_and_test([txspend], node_std, success=False, + reject_reason=CLEANSTACK_ERROR) + peer_std.send_txs_and_test([txspend_case0], node_std, success=False, + reject_reason=EVAL_FALSE_ERROR) # Segwit recovery txns are never accepted into the mempool, # as they are included in standard flags. @@ -264,7 +240,7 @@ # Blocks containing segwit spending txns are accepted in both nodes. block(5) update_block(5, [txspend, txspend_case0]) - accepted(node_nonstd) + peer_nonstd.send_blocks_and_test([self.tip], node_nonstd) self.sync_blocks() diff --git a/test/functional/abc-transaction-ordering.py b/test/functional/abc-transaction-ordering.py --- a/test/functional/abc-transaction-ordering.py +++ b/test/functional/abc-transaction-ordering.py @@ -123,7 +123,7 @@ def run_test(self): node = self.nodes[0] - node.add_p2p_connection(P2PDataStore()) + peer = node.add_p2p_connection(P2PDataStore()) self.genesis_hash = int(node.getbestblockhash(), 16) self.block_heights[self.genesis_hash] = 0 @@ -157,7 +157,7 @@ # Create a new block block(0) save_spendable_output() - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) # Now we need that block to mature so we can spend the coinbase. maturity_blocks = [] @@ -165,7 +165,7 @@ block(5000 + i) maturity_blocks.append(self.tip) save_spendable_output() - node.p2p.send_blocks_and_test(maturity_blocks, node) + peer.send_blocks_and_test(maturity_blocks, node) # collect spendable outputs now to avoid cluttering the code later on out = [] @@ -175,12 +175,12 @@ # Let's build some blocks and test them. for i in range(17): n = i + 1 - node.p2p.send_blocks_and_test([block(n)], node) + peer.send_blocks_and_test([block(n)], node) - node.p2p.send_blocks_and_test([block(5556)], node) + peer.send_blocks_and_test([block(5556)], node) # Block with regular ordering are now rejected. - node.p2p.send_blocks_and_test([block( + peer.send_blocks_and_test([block( 5557, out[17], tx_count=16)], node, success=False, reject_reason='tx-ordering') # Rewind bad block. @@ -194,8 +194,8 @@ return b # Now that the fork activated, we need to order transaction per txid. - node.p2p.send_blocks_and_test([ordered_block(4445, out[17])], node) - node.p2p.send_blocks_and_test([ordered_block(4446, out[18])], node) + peer.send_blocks_and_test([ordered_block(4445, out[17])], node) + peer.send_blocks_and_test([ordered_block(4446, out[18])], node) # Generate a block with a duplicated transaction. double_tx_block = ordered_block(4447, out[19]) @@ -203,7 +203,7 @@ double_tx_block.vtx = double_tx_block.vtx[:8] + \ [double_tx_block.vtx[8]] + double_tx_block.vtx[8:] update_block(4447) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [self.tip], node, success=False, reject_reason='bad-txns-duplicate') # Rewind bad block. @@ -211,7 +211,7 @@ # Check over two blocks. proper_block = ordered_block(4448, out[20]) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) replay_tx_block = ordered_block(4449, out[21]) assert_equal(len(replay_tx_block.vtx), 16) @@ -219,7 +219,7 @@ replay_tx_block.vtx = [replay_tx_block.vtx[0]] + \ sorted(replay_tx_block.vtx[1:], key=lambda tx: tx.get_id()) update_block(4449) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [self.tip], node, success=False, reject_reason='bad-txns-BIP30') diff --git a/test/functional/abc_p2p_fullblocktest.py b/test/functional/abc_p2p_fullblocktest.py --- a/test/functional/abc_p2p_fullblocktest.py +++ b/test/functional/abc_p2p_fullblocktest.py @@ -176,7 +176,7 @@ def run_test(self): node = self.nodes[0] - node.add_p2p_connection(P2PDataStore()) + peer = node.add_p2p_connection(P2PDataStore()) self.genesis_hash = int(node.getbestblockhash(), 16) self.block_heights[self.genesis_hash] = 0 @@ -213,7 +213,7 @@ # Create a new block block(0) save_spendable_output() - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) # Now we need that block to mature so we can spend the coinbase. maturity_blocks = [] @@ -221,7 +221,7 @@ block(5000 + i) maturity_blocks.append(self.tip) save_spendable_output() - node.p2p.send_blocks_and_test(maturity_blocks, node) + peer.send_blocks_and_test(maturity_blocks, node) # collect spendable outputs now to avoid cluttering the code later on out = [] @@ -232,15 +232,15 @@ for i in range(16): n = i + 1 block(n, spend=out[i], block_size=n * ONE_MEGABYTE) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) # block of maximal size block(17, spend=out[16], block_size=self.excessive_block_size) - node.p2p.send_blocks_and_test([self.tip], node) + peer.send_blocks_and_test([self.tip], node) # Reject oversized blocks with bad-blk-length error block(18, spend=out[17], block_size=self.excessive_block_size + 1) - node.p2p.send_blocks_and_test( + peer.send_blocks_and_test( [self.tip], node, success=False, reject_reason='bad-blk-length') # Rewind bad block.