mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-03 17:30:25 +01:00
[tests] use TestNode p2p connection in tests
This commit is contained in:
@@ -181,7 +181,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
# mine count blocks and return the new tip
|
||||
def mine_blocks(self, count):
|
||||
# Clear out last block announcement from each p2p listener
|
||||
[ x.clear_last_announcement() for x in self.p2p_connections ]
|
||||
[x.clear_last_announcement() for x in self.nodes[0].p2ps]
|
||||
self.nodes[0].generate(count)
|
||||
return int(self.nodes[0].getbestblockhash(), 16)
|
||||
|
||||
@@ -193,7 +193,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
def mine_reorg(self, length):
|
||||
self.nodes[0].generate(length) # make sure all invalidated blocks are node0's
|
||||
sync_blocks(self.nodes, wait=0.1)
|
||||
for x in self.p2p_connections:
|
||||
for x in self.nodes[0].p2ps:
|
||||
x.wait_for_block_announcement(int(self.nodes[0].getbestblockhash(), 16))
|
||||
x.clear_last_announcement()
|
||||
|
||||
@@ -206,18 +206,10 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||
|
||||
def run_test(self):
|
||||
# Setup the p2p connections and start up the network thread.
|
||||
inv_node = TestNode()
|
||||
test_node = TestNode()
|
||||
|
||||
self.p2p_connections = [inv_node, test_node]
|
||||
|
||||
connections = []
|
||||
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], inv_node))
|
||||
inv_node = self.nodes[0].add_p2p_connection(TestNode())
|
||||
# Set nServices to 0 for test_node, so no block download will occur outside of
|
||||
# direct fetching
|
||||
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test_node, services=NODE_WITNESS))
|
||||
inv_node.add_connection(connections[0])
|
||||
test_node.add_connection(connections[1])
|
||||
test_node = self.nodes[0].add_p2p_connection(TestNode(), services=NODE_WITNESS)
|
||||
|
||||
NetworkThread().start() # Start up network handling in another thread
|
||||
|
||||
|
||||
Reference in New Issue
Block a user