'L{IListeningPort.getHost} returns the same address as a client
connection\'s L{ITCPTransport.getPeer}.'

def test_hostAddress(self):

    serverFactory = MyServerFactory()
    serverFactory.protocolConnectionLost = defer.Deferred()
    serverConnectionLost = serverFactory.protocolConnectionLost
    port = reactor.listenTCP(0, serverFactory, interface='127.0.0.1')
    self.addCleanup(port.stopListening)
    n = port.getHost().port
    clientFactory = MyClientFactory()
    onConnection = clientFactory.protocolConnectionMade = defer.Deferred()
    connector = reactor.connectTCP('127.0.0.1', n, clientFactory)
    def check(ignored):
        self.assertEqual([port.getHost()], clientFactory.peerAddresses)
        self.assertEqual(port.getHost(), clientFactory.protocol.transport.getPeer())
    onConnection.addCallback(check)
    def cleanup(ignored):
        connector.disconnect()
        return serverConnectionLost
    onConnection.addCallback(cleanup)
    return onConnection
