'Test if IPv4 headers result in the correct host and peer data.'

def test_validIPv4HeaderResolves_getPeerHost(self):

    factory = HAProxyWrappingFactory(Factory.forProtocol(StaticProtocol))
    proto = factory.buildProtocol(address.IPv4Address('TCP', '127.0.0.1', 8080))
    transport = StringTransportWithDisconnection()
    proto.makeConnection(transport)
    proto.dataReceived('PROXY    TCP4    1.1.1.1    2.2.2.2    8080    8888\r\n')
    self.assertEqual(proto.getPeer().host, '1.1.1.1')
    self.assertEqual(proto.getPeer().port, 8080)
    self.assertEqual(proto.wrappedProtocol.transport.getPeer().host, '1.1.1.1')
    self.assertEqual(proto.wrappedProtocol.transport.getPeer().port, 8080)
    self.assertEqual(proto.getHost().host, '2.2.2.2')
    self.assertEqual(proto.getHost().port, 8888)
    self.assertEqual(proto.wrappedProtocol.transport.getHost().host, '2.2.2.2')
    self.assertEqual(proto.wrappedProtocol.transport.getHost().port, 8888)
