def test_HTTPSDistributor_getBridges_ipv4_ipv6(self):
    'Asking for bridge addresses which are simultaneously IPv4 and IPv6\n        (in that order) should return IPv4 bridges.\n        '
    dist = distributor.HTTPSDistributor(1, self.key)
    [dist.insert(bridge) for bridge in self.bridges[:250]]
    bridgeRequest = self.randomClientRequest()
    bridgeRequest.withIPv4()
    bridgeRequest.filters.append(byIPv6)
    bridgeRequest.generateFilters()
    bridges = dist.getBridges(bridgeRequest, 1)
    self.assertEqual(len(bridges), 3)
    bridge = random.choice(bridges)
    bridgeLine = bridge.getBridgeLine(bridgeRequest)
    (addrport, fingerprint) = bridgeLine.split()
    (address, port) = addrport.rsplit(':', 1)
    address = address.strip('[]')
    self.assertIsInstance(ipaddr.IPAddress(address), ipaddr.IPv4Address)
    self.assertIsNotNone(byIPv4(random.choice(bridges)))
Asking for bridge addresses which are simultaneously IPv4 and IPv6
(in that order) should return IPv4 bridges.
def test_HTTPSDistributor_getBridges_ipv4_ipv6(self):
    'Asking for bridge addresses which are simultaneously IPv4 and IPv6\n        (in that order) should return IPv4 bridges.\n        '
    dist = distributor.HTTPSDistributor(1, self.key)
    [dist.insert(bridge) for bridge in self.bridges[:250]]
    bridgeRequest = self.randomClientRequest()
    bridgeRequest.withIPv4()
    bridgeRequest.filters.append(byIPv6)
    bridgeRequest.generateFilters()
    bridges = dist.getBridges(bridgeRequest, 1)
    self.assertEqual(len(bridges), 3)
    bridge = random.choice(bridges)
    bridgeLine = bridge.getBridgeLine(bridgeRequest)
    (addrport, fingerprint) = bridgeLine.split()
    (address, port) = addrport.rsplit(':', 1)
    address = address.strip('[]')
    self.assertIsInstance(ipaddr.IPAddress(address), ipaddr.IPv4Address)
    self.assertIsNotNone(byIPv4(random.choice(bridges)))