From a10b8fdb91808f1ef7edbda7103716d77bee9f49 Mon Sep 17 00:00:00 2001 From: mystical-prog Date: Fri, 8 Nov 2024 19:55:58 +0530 Subject: [PATCH] added msg dropping test --- tests/core/pubsub/test_pubsub.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/core/pubsub/test_pubsub.py b/tests/core/pubsub/test_pubsub.py index 26f725ce..c7fba1af 100644 --- a/tests/core/pubsub/test_pubsub.py +++ b/tests/core/pubsub/test_pubsub.py @@ -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(