Skip to content

Commit

Permalink
added msg dropping test
Browse files Browse the repository at this point in the history
  • Loading branch information
mystical-prog authored and pacrob committed Nov 15, 2024
1 parent 9ba04d0 commit a10b8fd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/core/pubsub/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ async def push_msg(msg_forwarder, msg):

@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],
Expand Down Expand Up @@ -571,6 +571,18 @@ async def router_publish(*args, **kwargs):
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(
Expand Down

0 comments on commit a10b8fd

Please sign in to comment.