Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/comptool.py
Show All 13 Lines | TestNode behaves as follows: | ||||
on_headers: log the chain tip | on_headers: log the chain tip | ||||
on_pong: update ping response map (for synchronization) | on_pong: update ping response map (for synchronization) | ||||
on_getheaders: provide headers via BlockStore | on_getheaders: provide headers via BlockStore | ||||
on_getdata: provide blocks via BlockStore | on_getdata: provide blocks via BlockStore | ||||
""" | """ | ||||
from .mininode import * | from .mininode import * | ||||
from .blockstore import BlockStore, TxStore | from .blockstore import BlockStore, TxStore | ||||
from .util import p2p_port, wait_until | from .util import wait_until | ||||
import logging | import logging | ||||
logger = logging.getLogger("TestFramework.comptool") | logger = logging.getLogger("TestFramework.comptool") | ||||
global mininode_lock | global mininode_lock | ||||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | def __init__(self, testgen, datadir): | ||||
self.ping_counter = 1 | self.ping_counter = 1 | ||||
def add_all_connections(self, nodes): | def add_all_connections(self, nodes): | ||||
for i in range(len(nodes)): | for i in range(len(nodes)): | ||||
# Create a p2p connection to each node | # Create a p2p connection to each node | ||||
test_node = TestNode(self.block_store, self.tx_store) | test_node = TestNode(self.block_store, self.tx_store) | ||||
self.test_nodes.append(test_node) | self.test_nodes.append(test_node) | ||||
self.connections.append( | self.connections.append( | ||||
NodeConn('127.0.0.1', p2p_port(i), nodes[i], test_node)) | NodeConn('127.0.0.1', self.test_generator.p2p_port(i), nodes[i], test_node)) | ||||
# Make sure the TestNode (callback class) has a reference to its | # Make sure the TestNode (callback class) has a reference to its | ||||
# associated NodeConn | # associated NodeConn | ||||
test_node.add_connection(self.connections[-1]) | test_node.add_connection(self.connections[-1]) | ||||
def clear_all_connections(self): | def clear_all_connections(self): | ||||
self.connections = [] | self.connections = [] | ||||
self.test_nodes = [] | self.test_nodes = [] | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |