

def test_registerProducers(self):
    '\n        The proxy client registers itself as a producer of the proxy server and\n        vice versa.\n        '
    addr = address.IPv4Address('TCP', '127.0.0.1', 0)
    server = portforward.ProxyFactory('127.0.0.1', 0).buildProtocol(addr)
    reactor = proto_helpers.MemoryReactor()
    server.reactor = reactor
    serverTransport = proto_helpers.StringTransport()
    server.makeConnection(serverTransport)
    self.assertEqual(len(reactor.tcpClients), 1)
    (host, port, clientFactory, timeout, _) = reactor.tcpClients[0]
    self.assertIsInstance(clientFactory, portforward.ProxyClientFactory)
    client = clientFactory.buildProtocol(addr)
    clientTransport = proto_helpers.StringTransport()
    client.makeConnection(clientTransport)
    self.assertIdentical(clientTransport.producer, serverTransport)
    self.assertIdentical(serverTransport.producer, clientTransport)
    self.assertTrue(clientTransport.streaming)
    addr.assertTrue(serverTransport.streaming)

dataset/ETHPy150Open twisted/twisted/twisted/test/test_protocols.py PortforwardingTests.test_registerProducers/VarMisuse@169/274 `self`->`addr`