2019-11-07 07:18:53 +08:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from libp2p.identity.identify.pb.identify_pb2 import Identify
|
|
|
|
from libp2p.identity.identify.protocol import ID, _mk_identify_protobuf
|
2019-11-26 19:24:30 +08:00
|
|
|
from libp2p.tools.factories import host_pair_factory
|
2019-11-07 07:18:53 +08:00
|
|
|
|
|
|
|
|
2019-12-01 17:55:07 +08:00
|
|
|
@pytest.mark.trio
|
|
|
|
async def test_identify_protocol(is_host_secure):
|
|
|
|
async with host_pair_factory(is_host_secure) as (host_a, host_b):
|
2019-11-08 13:01:08 +08:00
|
|
|
stream = await host_b.new_stream(host_a.get_id(), (ID,))
|
|
|
|
response = await stream.read()
|
|
|
|
await stream.close()
|
2019-11-07 07:18:53 +08:00
|
|
|
|
2019-11-08 13:01:08 +08:00
|
|
|
identify_response = Identify()
|
|
|
|
identify_response.ParseFromString(response)
|
|
|
|
assert identify_response == _mk_identify_protobuf(host_a)
|