'A client\'s transport\'s C{getHost} and C{getPeer} return L{IPv4Address}
instances which have the dotted-quad string form of the resolved
address of the local and remote endpoints of the connection
respectively as their C{host} attribute, not the hostname originally
passed in to
L{connectTCP<twisted.internet.interfaces.IReactorTCP.connectTCP>}, if a
hostname was used.'

def test_addresses(self):

    (host, port) = findFreePort(self.interface, self.family)[:2]
    reactor = self.buildReactor()
    fakeDomain = self.fakeDomainName
    reactor.installResolver(FakeResolver({fakeDomain: self.interface}))
    server = reactor.listenTCP(0, ServerFactory.forProtocol(Protocol), interface=host)
    serverAddress = server.getHost()
    transportData = {'host': None, 'peer': None, 'instance': None}
    class CheckAddress(Protocol, ):
        def makeConnection(self, transport):
            transportData['host'] = transport.getHost()
            transportData['peer'] = transport.getPeer()
            transportData['instance'] = transport
            reactor.stop()
    clientFactory = Stop(reactor)
    clientFactory.protocol = CheckAddress
    def connectMe():
        reactor.connectTCP(fakeDomain, server.getHost().port, clientFactory, bindAddress=(self.interface, port))
    needsRunningReactor(reactor, connectMe)
    self.runReactor(reactor)
    if clientFactory.failReason:
        self.fail(clientFactory.failReason.getTraceback())
    transportRepr = ('<%s    to    %s    at    %x>' % (transportData['instance'].__class__, transportData['instance'].addr, id(transportData['instance'])))
    self.assertEqual(transportData['host'], self.addressClass('TCP', self.interface, port))
    self.assertEqual(transportData['peer'], self.addressClass('TCP', self.interface, serverAddress.port))
    self.assertEqual(repr(transportData['instance']), transportRepr)
