Example #1
0
 def run_bind_test(self, allow_ips, connect_to, addresses, expected):
     '''
     Start a node with requested rpcallowip and rpcbind parameters,
     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[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()
 def run_bind_test(self, allow_ips, connect_to, addresses, expected):
     '''
     Start a node with requested rpcallowip and rpcbind parameters,
     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[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()
Example #3
0
 def run_test(self):
     for i in range(len(self.expected)):
         self.log.info(f"Starting node {i} with {self.expected[i][0]}")
         self.start_node(i)
         pid = self.nodes[i].process.pid
         binds = set(get_bind_addrs(pid))
         # Remove IPv6 addresses because on some CI environments "::1" is not configured
         # on the system (so our test_ipv6_local() would return False), but it is
         # possible to bind on "::". This makes it unpredictable whether to expect
         # that syscoind has bound on "::1" (for RPC) and "::" (for P2P).
         ipv6_addr_len_bytes = 32
         binds = set(filter(lambda e: len(e[0]) != ipv6_addr_len_bytes, binds))
         # Remove RPC ports. They are not relevant for this test.
         binds = set(filter(lambda e: e[1] != rpc_port(i), binds))
         assert_equal(binds, set(self.expected[i][1]))
         self.stop_node(i)
         self.log.info(f"Stopped node {i}")
Example #4
0
def run_bind_test(tmpdir, allow_ips, connect_to, addresses, expected):
    '''
    Start a node with requested rpcallowip and rpcbind parameters,
    then try to connect, and check if the set of bound addresses
    matches the expected set.
    '''
    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]
    nodes = start_nodes(1, tmpdir, [base_args + binds], connect_to)
    try:
        pid = bitcoind_processes[0].pid
        assert_equal(set(get_bind_addrs(pid)), set(expected))
    finally:
        stop_nodes(nodes)
        wait_bitcoinds()
Example #5
0
def run_bind_test(tmpdir, allow_ips, connect_to, addresses, expected):
    '''
    Start a node with requested rpcallowip and rpcbind parameters,
    then try to connect, and check if the set of bound addresses
    matches the expected set.
    '''
    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]
    nodes = start_nodes(1, tmpdir, [base_args + binds], connect_to)
    try:
        pid = bitcoind_processes[0].pid
        assert_equal(set(get_bind_addrs(pid)), set(expected))
    finally:
        stop_nodes(nodes)
        wait_bitcoinds()