async def handle_unary_unary(unused_request: bytes, servicer_context: aio.ServicerContext): return pickle.dumps({ _ID: servicer_context.peer_identities(), _ID_KEY: servicer_context.peer_identity_key(), _AUTH_CTX: servicer_context.auth_context() })
async def test_handler(request: bytes, context: aio.ServicerContext): self.assertEqual(_REQUEST, request) def exception_raiser(unused_context): raise RuntimeError('A test RuntimeError') context.add_done_callback(exception_raiser) validation_future.set_result(inject_callbacks(context)) return _RESPONSE
async def check_peer_unary_unary(request: bytes, context: aio.ServicerContext): self.assertEqual(_REQUEST, request) # The peer address could be ipv4 or ipv6 self.assertIn('ip', context.peer()) return request