mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Copied read/write from secio
This commit is contained in:
@ -3,7 +3,9 @@ import pytest
|
||||
from libp2p.security.noise.messages import NoiseHandshakePayload
|
||||
from libp2p.tools.factories import noise_conn_factory, noise_handshake_payload_factory
|
||||
|
||||
DATA = b"testing_123"
|
||||
DATA_0 = b"data_0"
|
||||
DATA_1 = b"1" * 1000
|
||||
DATA_2 = b"data_2"
|
||||
|
||||
|
||||
@pytest.mark.trio
|
||||
@ -16,9 +18,12 @@ async def test_noise_transport(nursery):
|
||||
async def test_noise_connection(nursery):
|
||||
async with noise_conn_factory(nursery) as conns:
|
||||
local_conn, remote_conn = conns
|
||||
await local_conn.write(DATA)
|
||||
read_data = await remote_conn.read(len(DATA))
|
||||
assert read_data == DATA
|
||||
await local_conn.write(DATA_0)
|
||||
await local_conn.write(DATA_1)
|
||||
assert DATA_0 == (await remote_conn.read(len(DATA_0)))
|
||||
assert DATA_1 == (await remote_conn.read(len(DATA_1)))
|
||||
await local_conn.write(DATA_2)
|
||||
assert DATA_2 == (await remote_conn.read(len(DATA_2)))
|
||||
|
||||
|
||||
def test_noise_handshake_payload():
|
||||
|
||||
Reference in New Issue
Block a user