mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-06-19 20:34:14 -04:00
fixes
This commit is contained in:
parent
b2bd4bcbbd
commit
bc6421acf7
5 changed files with 77 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
# Routing context veilid tests
|
||||
|
||||
import asyncio
|
||||
import random
|
||||
|
||||
import pytest
|
||||
import veilid
|
||||
|
@ -109,3 +110,46 @@ async def test_routing_context_app_call_loopback():
|
|||
# now we should get the reply from the call
|
||||
result = await app_call_task
|
||||
assert result == reply
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_routing_context_app_message_loopback_big_packets():
|
||||
|
||||
app_message_queue: asyncio.Queue = asyncio.Queue()
|
||||
|
||||
async def app_message_queue_update_callback(update: veilid.VeilidUpdate):
|
||||
if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE:
|
||||
await app_message_queue.put(update)
|
||||
|
||||
hostname, port = server_info()
|
||||
api = await veilid.json_api_connect(
|
||||
hostname, port, app_message_queue_update_callback
|
||||
)
|
||||
async with api:
|
||||
# purge routes to ensure we start fresh
|
||||
await api.debug("purge routes")
|
||||
|
||||
# make a routing context that uses a safety route
|
||||
rc = await (await api.new_routing_context()).with_privacy()
|
||||
async with rc:
|
||||
|
||||
# make a new local private route
|
||||
prl, blob = await api.new_private_route()
|
||||
|
||||
# import it as a remote route as well so we can send to it
|
||||
prr = await api.import_remote_private_route(blob)
|
||||
|
||||
# do this test 10 times
|
||||
for _ in range(10):
|
||||
|
||||
# send a random sized random app message to our own private route
|
||||
message = random.randbytes(random.randint(0,32768))
|
||||
await rc.app_message(prr, message)
|
||||
|
||||
# we should get the same message back
|
||||
update: veilid.VeilidUpdate = await asyncio.wait_for(
|
||||
app_message_queue.get(), timeout=10
|
||||
)
|
||||
|
||||
assert isinstance(update.detail, veilid.VeilidAppMessage)
|
||||
assert update.detail.message == message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue