コード例 #1
0
ファイル: test_packer.py プロジェクト: simulationcoin/trinity
async def test_peer_packer_sends_who_are_you(peer_packer,
                                             incoming_packet_channels,
                                             outgoing_packet_channels,
                                             nursery):
    incoming_packet = IncomingPacket(
        AuthTagPacketFactory(),
        EndpointFactory(),
    )

    incoming_packet_channels[0].send_nowait(incoming_packet)
    with trio.fail_after(0.5):
        outgoing_packet = await outgoing_packet_channels[1].receive()

    assert peer_packer.is_during_handshake
    assert outgoing_packet.receiver_endpoint == incoming_packet.sender_endpoint
    assert isinstance(outgoing_packet.packet, WhoAreYouPacket)
    assert outgoing_packet.packet.token == incoming_packet.packet.auth_tag