Merge #12728: [tests] rename TestNode to TestP2PConn in tests
728667b771
scripted-diff: rename TestNode to TestP2PConn in tests (John Newbery)
Pull request description:
Several test scripts define a subclass of P2PInterface called TestNode.
This commit renames those to TestP2PConn since we already have a
TestNode class in the test framework.
Tree-SHA512: fc8472677312ad000560fa491b680a441d05c0fee5f8eea2d031d326d81e56d231c235930c0d09dd10afc98d7255fa9f9309d5e2ae6c252bc188a5951644a5b8
This commit is contained in:
commit
4ba3d4f439
6 changed files with 21 additions and 21 deletions
|
@ -17,7 +17,7 @@ from test_framework.mininode import *
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
|
||||||
class TestNode(P2PInterface):
|
class TestP2PConn(P2PInterface):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.block_receive_map = defaultdict(int)
|
self.block_receive_map = defaultdict(int)
|
||||||
|
@ -55,7 +55,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
p2p_conns = []
|
p2p_conns = []
|
||||||
|
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
p2p_conns.append(self.nodes[0].add_p2p_connection(TestNode()))
|
p2p_conns.append(self.nodes[0].add_p2p_connection(TestP2PConn()))
|
||||||
|
|
||||||
network_thread_start()
|
network_thread_start()
|
||||||
for p2pc in p2p_conns:
|
for p2pc in p2p_conns:
|
||||||
|
@ -147,7 +147,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
self.start_node(0, ["-whitelist=127.0.0.1", "-maxuploadtarget=1", "-blockmaxsize=999000"])
|
self.start_node(0, ["-whitelist=127.0.0.1", "-maxuploadtarget=1", "-blockmaxsize=999000"])
|
||||||
|
|
||||||
# Reconnect to self.nodes[0]
|
# Reconnect to self.nodes[0]
|
||||||
self.nodes[0].add_p2p_connection(TestNode())
|
self.nodes[0].add_p2p_connection(TestP2PConn())
|
||||||
|
|
||||||
network_thread_start()
|
network_thread_start()
|
||||||
self.nodes[0].p2p.wait_for_verack()
|
self.nodes[0].p2p.wait_for_verack()
|
||||||
|
|
|
@ -14,8 +14,8 @@ from test_framework.util import *
|
||||||
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
|
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
|
||||||
from test_framework.script import CScript, OP_TRUE
|
from test_framework.script import CScript, OP_TRUE
|
||||||
|
|
||||||
# TestNode: A peer we use to send messages to bitcoind, and store responses.
|
# TestP2PConn: A peer we use to send messages to bitcoind, and store responses.
|
||||||
class TestNode(P2PInterface):
|
class TestP2PConn(P2PInterface):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.last_sendcmpct = []
|
self.last_sendcmpct = []
|
||||||
|
@ -788,9 +788,9 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
# Setup the p2p connections and start up the network thread.
|
# Setup the p2p connections and start up the network thread.
|
||||||
self.test_node = self.nodes[0].add_p2p_connection(TestNode())
|
self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn())
|
||||||
self.segwit_node = self.nodes[1].add_p2p_connection(TestNode(), services=NODE_NETWORK|NODE_WITNESS)
|
self.segwit_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK|NODE_WITNESS)
|
||||||
self.old_node = self.nodes[1].add_p2p_connection(TestNode(), services=NODE_NETWORK)
|
self.old_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK)
|
||||||
|
|
||||||
network_thread_start()
|
network_thread_start()
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ def allInvsMatch(invsExpected, testnode):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
class TestNode(P2PInterface):
|
class TestP2PConn(P2PInterface):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.txinvs = []
|
self.txinvs = []
|
||||||
|
@ -48,7 +48,7 @@ class FeeFilterTest(BitcoinTestFramework):
|
||||||
sync_blocks(self.nodes)
|
sync_blocks(self.nodes)
|
||||||
|
|
||||||
# Setup the p2p connections and start up the network thread.
|
# Setup the p2p connections and start up the network thread.
|
||||||
self.nodes[0].add_p2p_connection(TestNode())
|
self.nodes[0].add_p2p_connection(TestP2PConn())
|
||||||
network_thread_start()
|
network_thread_start()
|
||||||
self.nodes[0].p2p.wait_for_verack()
|
self.nodes[0].p2p.wait_for_verack()
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ def test_witness_block(rpc, p2p, block, accepted, with_witness=True):
|
||||||
p2p.sync_with_ping()
|
p2p.sync_with_ping()
|
||||||
assert_equal(rpc.getbestblockhash() == block.hash, accepted)
|
assert_equal(rpc.getbestblockhash() == block.hash, accepted)
|
||||||
|
|
||||||
class TestNode(P2PInterface):
|
class TestP2PConn(P2PInterface):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.getdataset = set()
|
self.getdataset = set()
|
||||||
|
@ -1878,11 +1878,11 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
# Setup the p2p connections and start up the network thread.
|
# Setup the p2p connections and start up the network thread.
|
||||||
# self.test_node sets NODE_WITNESS|NODE_NETWORK
|
# self.test_node sets NODE_WITNESS|NODE_NETWORK
|
||||||
self.test_node = self.nodes[0].add_p2p_connection(TestNode(), services=NODE_NETWORK|NODE_WITNESS)
|
self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK|NODE_WITNESS)
|
||||||
# self.old_node sets only NODE_NETWORK
|
# self.old_node sets only NODE_NETWORK
|
||||||
self.old_node = self.nodes[0].add_p2p_connection(TestNode(), services=NODE_NETWORK)
|
self.old_node = self.nodes[0].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK)
|
||||||
# self.std_node is for testing node1 (fRequireStandard=true)
|
# self.std_node is for testing node1 (fRequireStandard=true)
|
||||||
self.std_node = self.nodes[1].add_p2p_connection(TestNode(), services=NODE_NETWORK|NODE_WITNESS)
|
self.std_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK|NODE_WITNESS)
|
||||||
|
|
||||||
network_thread_start()
|
network_thread_start()
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ from test_framework.mininode import *
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
|
||||||
class TestNode(P2PInterface):
|
class TestP2PConn(P2PInterface):
|
||||||
def on_version(self, message):
|
def on_version(self, message):
|
||||||
# Don't send a verack in response
|
# Don't send a verack in response
|
||||||
pass
|
pass
|
||||||
|
@ -39,9 +39,9 @@ class TimeoutsTest(BitcoinTestFramework):
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
# Setup the p2p connections and start up the network thread.
|
# Setup the p2p connections and start up the network thread.
|
||||||
no_verack_node = self.nodes[0].add_p2p_connection(TestNode())
|
no_verack_node = self.nodes[0].add_p2p_connection(TestP2PConn())
|
||||||
no_version_node = self.nodes[0].add_p2p_connection(TestNode(), send_version=False)
|
no_version_node = self.nodes[0].add_p2p_connection(TestP2PConn(), send_version=False)
|
||||||
no_send_node = self.nodes[0].add_p2p_connection(TestNode(), send_version=False)
|
no_send_node = self.nodes[0].add_p2p_connection(TestP2PConn(), send_version=False)
|
||||||
|
|
||||||
network_thread_start()
|
network_thread_start()
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ To use, create a class that implements get_tests(), and pass it in
|
||||||
as the test generator to TestManager. get_tests() should be a python
|
as the test generator to TestManager. get_tests() should be a python
|
||||||
generator that returns TestInstance objects. See below for definition.
|
generator that returns TestInstance objects. See below for definition.
|
||||||
|
|
||||||
TestNode behaves as follows:
|
TestP2PConn behaves as follows:
|
||||||
Configure with a BlockStore and TxStore
|
Configure with a BlockStore and TxStore
|
||||||
on_inv: log the message but don't request
|
on_inv: log the message but don't request
|
||||||
on_headers: log the chain tip
|
on_headers: log the chain tip
|
||||||
|
@ -39,7 +39,7 @@ class RejectResult():
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '%i:%s' % (self.code,self.reason or '*')
|
return '%i:%s' % (self.code,self.reason or '*')
|
||||||
|
|
||||||
class TestNode(P2PInterface):
|
class TestP2PConn(P2PInterface):
|
||||||
|
|
||||||
def __init__(self, block_store, tx_store):
|
def __init__(self, block_store, tx_store):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -170,7 +170,7 @@ class TestManager():
|
||||||
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
|
||||||
node = TestNode(self.block_store, self.tx_store)
|
node = TestP2PConn(self.block_store, self.tx_store)
|
||||||
node.peer_connect('127.0.0.1', p2p_port(i))
|
node.peer_connect('127.0.0.1', p2p_port(i))
|
||||||
self.p2p_connections.append(node)
|
self.p2p_connections.append(node)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue