mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-28 16:36:04 +01:00
[tests] TestNode: separate add_node from start_node
Separates the act of creating a TestNode object from starting the node.
The test_framework now keeps track of its list of TestNodes, and test
writers can call start_node() and stop_node() without having to update
the self.nodes list.
Github-Pull: #11121
Rebased-From: 36b6268670
This commit is contained in:
@@ -20,10 +20,7 @@ class RPCBindTest(BitcoinTestFramework):
|
||||
self.num_nodes = 1
|
||||
|
||||
def setup_network(self):
|
||||
pass
|
||||
|
||||
def setup_nodes(self):
|
||||
pass
|
||||
self.add_nodes(self.num_nodes, self.options.tmpdir, None)
|
||||
|
||||
def run_bind_test(self, allow_ips, connect_to, addresses, expected):
|
||||
'''
|
||||
@@ -31,12 +28,14 @@ class RPCBindTest(BitcoinTestFramework):
|
||||
then try to connect, and check if the set of bound addresses
|
||||
matches the expected set.
|
||||
'''
|
||||
self.log.info("Bind test for %s" % str(addresses))
|
||||
expected = [(addr_to_hex(addr), port) for (addr, port) in expected]
|
||||
base_args = ['-disablewallet', '-nolisten']
|
||||
if allow_ips:
|
||||
base_args += ['-rpcallowip=' + x for x in allow_ips]
|
||||
binds = ['-rpcbind='+addr for addr in addresses]
|
||||
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir, [base_args + binds], connect_to)
|
||||
self.nodes[0].rpchost = connect_to
|
||||
self.start_node(0, base_args + binds)
|
||||
pid = self.nodes[0].process.pid
|
||||
assert_equal(set(get_bind_addrs(pid)), set(expected))
|
||||
self.stop_nodes()
|
||||
@@ -46,8 +45,10 @@ class RPCBindTest(BitcoinTestFramework):
|
||||
Start a node with rpcallow IP, and request getnetworkinfo
|
||||
at a non-localhost IP.
|
||||
'''
|
||||
self.log.info("Allow IP test for %s:%d" % (rpchost, rpcport))
|
||||
base_args = ['-disablewallet', '-nolisten'] + ['-rpcallowip='+x for x in allow_ips]
|
||||
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir, [base_args])
|
||||
self.nodes[0].rpchost = None
|
||||
self.start_nodes([base_args])
|
||||
# connect to node through non-loopback interface
|
||||
node = get_rpc_proxy(rpc_url(get_datadir_path(self.options.tmpdir, 0), 0, "%s:%d" % (rpchost, rpcport)), 0, coveragedir=self.options.coveragedir)
|
||||
node.getnetworkinfo()
|
||||
|
||||
Reference in New Issue
Block a user