def run_test(self):
    self.node_test(self.nodes[0], [self.serv1, self.serv1, self.serv1, self.serv1], False)
    self.node_test(self.nodes[1], [self.serv1, self.serv1, self.serv2, self.serv1], False)
    rv = self.node_test(self.nodes[2], [self.serv2, self.serv2, self.serv2, self.serv2], True)
    credentials = set(((x.username, x.password) for x in rv))
    assert_equal(len(credentials), len(rv))
    if self.have_ipv6:
        self.node_test(self.nodes[3], [self.serv3, self.serv3, self.serv3, self.serv3], False, False)

    def networks_dict(d):
        r = {}
        for x in d['networks']:
            r[x['name']] = x
        return r
    n0 = networks_dict(self.nodes[0].getnetworkinfo())
    for net in ['ipv4', 'ipv6', 'onion']:
        assert_equal(n0[net]['proxy'], ('%s:%i' % self.conf1.addr))
        assert_equal(n0[net]['proxy_randomize_credentials'], True)
    assert_equal(n0['onion']['reachable'], True)
    n1 = networks_dict(self.nodes[1].getnetworkinfo())
    for net in ['ipv4', 'ipv6']:
        assert_equal(n1[net]['proxy'], ('%s:%i' % self.conf1.addr))
        assert_equal(n1[net]['proxy_randomize_credentials'], False)
    assert_equal(n1['onion']['proxy'], ('%s:%i' % self.conf2.addr))
    assert_equal(n1['onion']['proxy_randomize_credentials'], False)
    assert_equal(n1['onion']['reachable'], True)
    n2 = networks_dict(self.nodes[2].getnetworkinfo())
    for net in ['ipv4', 'ipv6', 'onion']:
        assert_equal(n2[net]['proxy'], ('%s:%i' % self.conf2.addr))
        assert_equal(n2[net]['proxy_randomize_credentials'], True)
    assert_equal(n2['onion']['reachable'], True)
    if self.have_ipv6:
        n3 = networks_dict(self.nodes[3].getnetworkinfo())
        for net in ['ipv4', 'ipv6']:
            assert_equal(n3[net]['proxy'], ('[%s]:%i' % self.conf3.addr))
            assert_equal(n3[net]['proxy_randomize_credentials'], False)
        assert_equal(n3['onion']['reachable'], False)
def run_test(self):
    self.node_test(self.nodes[0], [self.serv1, self.serv1, self.serv1, self.serv1], False)
    self.node_test(self.nodes[1], [self.serv1, self.serv1, self.serv2, self.serv1], False)
    rv = self.node_test(self.nodes[2], [self.serv2, self.serv2, self.serv2, self.serv2], True)
    credentials = set(((x.username, x.password) for x in rv))
    assert_equal(len(credentials), len(rv))
    if self.have_ipv6:
        self.node_test(self.nodes[3], [self.serv3, self.serv3, self.serv3, self.serv3], False, False)

    def networks_dict(d):
        r = {}
        for x in d['networks']:
            r[x['name']] = x
        return r
    n0 = networks_dict(self.nodes[0].getnetworkinfo())
    for net in ['ipv4', 'ipv6', 'onion']:
        assert_equal(n0[net]['proxy'], ('%s:%i' % self.conf1.addr))
        assert_equal(n0[net]['proxy_randomize_credentials'], True)
    assert_equal(n0['onion']['reachable'], True)
    n1 = networks_dict(self.nodes[1].getnetworkinfo())
    for net in ['ipv4', 'ipv6']:
        assert_equal(n1[net]['proxy'], ('%s:%i' % self.conf1.addr))
        assert_equal(n1[net]['proxy_randomize_credentials'], False)
    assert_equal(n1['onion']['proxy'], ('%s:%i' % self.conf2.addr))
    assert_equal(n1['onion']['proxy_randomize_credentials'], False)
    assert_equal(n1['onion']['reachable'], True)
    n2 = networks_dict(self.nodes[2].getnetworkinfo())
    for net in ['ipv4', 'ipv6', 'onion']:
        assert_equal(n2[net]['proxy'], ('%s:%i' % self.conf2.addr))
        assert_equal(n2[net]['proxy_randomize_credentials'], True)
    assert_equal(n2['onion']['reachable'], True)
    if self.have_ipv6:
        n3 = networks_dict(self.nodes[3].getnetworkinfo())
        for net in ['ipv4', 'ipv6']:
            assert_equal(n3[net]['proxy'], ('[%s]:%i' % self.conf3.addr))
            assert_equal(n3[net]['proxy_randomize_credentials'], False)
        assert_equal(n3['onion']['reachable'], False)