Пример #1
0
 def test_no_request(self):
     protocol = BlobServerProtocol(self.loop, self.server_blob_manager,
                                   'bQEaw42GXsgCAGio1nxFncJSyRmnztSCjP')
     called = asyncio.Event()
     protocol.close = called.set
     protocol.data_received(b'{}')
     self.assertTrue(called.is_set())
Пример #2
0
 async def test_server_chunked_request(self):
     blob_hash = "7f5ab2def99f0ddd008da71db3a3772135f4002b19b7605840ed1034c8955431bd7079549e65e6b2a3b9c17c773073ed"
     server_protocol = BlobServerProtocol(self.loop, self.server_blob_manager, self.server.lbrycrd_address)
     transport = asyncio.Transport(extra={'peername': ('ip', 90)})
     received_data = BytesIO()
     transport.write = received_data.write
     server_protocol.connection_made(transport)
     blob_request = BlobRequest.make_request_for_blob_hash(blob_hash).serialize()
     for byte in blob_request:
         server_protocol.data_received(bytes([byte]))
     await asyncio.sleep(0.1)  # yield execution
     self.assertGreater(len(received_data.getvalue()), 0)