mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
added msg dropping test
This commit is contained in:
committed by
Paul Robinson
parent
9ba04d0b15
commit
a10b8fdb91
@ -535,7 +535,7 @@ async def test_publish_push_msg_is_called(monkeypatch):
|
||||
|
||||
@pytest.mark.trio
|
||||
async def test_push_msg(monkeypatch):
|
||||
async with PubsubFactory.create_batch_with_floodsub(1) as pubsubs_fsub:
|
||||
async with PubsubFactory.create_batch_with_floodsub(2) as pubsubs_fsub:
|
||||
msg_0 = make_pubsub_msg(
|
||||
origin_id=pubsubs_fsub[0].my_id,
|
||||
topic_ids=[TESTING_TOPIC],
|
||||
@ -571,6 +571,18 @@ async def test_push_msg(monkeypatch):
|
||||
await trio.sleep(0.01)
|
||||
assert not event.is_set()
|
||||
|
||||
# Test: `push_msg` a new msg but forwarder as not self, it will be reject.
|
||||
# `router_publish` is not called then.
|
||||
msg_0A = make_pubsub_msg(
|
||||
origin_id=pubsubs_fsub[0].my_id,
|
||||
topic_ids=[TESTING_TOPIC],
|
||||
data=TESTING_DATA,
|
||||
seqno=b"\x33" * 8,
|
||||
)
|
||||
await pubsubs_fsub[0].push_msg(pubsubs_fsub[1].my_id, msg_0A)
|
||||
await trio.sleep(0.01)
|
||||
assert not event.is_set()
|
||||
|
||||
sub = await pubsubs_fsub[0].subscribe(TESTING_TOPIC)
|
||||
# Test: `push_msg` succeeds with another unseen msg.
|
||||
msg_1 = make_pubsub_msg(
|
||||
|
||||
Reference in New Issue
Block a user