From ebda56dd90a752f6e21eda2e7cbd31bc91fb4184 Mon Sep 17 00:00:00 2001 From: Ivan FB <128452529+Ivansete-status@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:45:05 +0200 Subject: [PATCH] lightpush better feedback in case the lightpush service node does not have peers (#2951) --- tests/node/test_wakunode_lightpush.nim | 20 +++++++++++++++----- waku/waku_lightpush/callbacks.nim | 3 +++ waku/waku_lightpush/protocol.nim | 4 +++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/node/test_wakunode_lightpush.nim b/tests/node/test_wakunode_lightpush.nim index 0527c034e..fba46e212 100644 --- a/tests/node/test_wakunode_lightpush.nim +++ b/tests/node/test_wakunode_lightpush.nim @@ -1,7 +1,7 @@ {.used.} import - std/[options, tables, sequtils, tempfiles], + std/[options, tables, sequtils, tempfiles, strutils], stew/shims/net as stewNet, testutils/unittests, chronos, @@ -86,8 +86,13 @@ suite "Waku Lightpush - End To End": if not publishResponse.isOk(): echo "Publish failed: ", publishResponse.error() - # Then the message is relayed to the server - assertResultOk publishResponse + # Then the message is not relayed but not due to RLN + assert publishResponse.isErr(), "We expect an error response" + assert ( + publishResponse.error.contains( + "Lightpush request has not been published to any peers" + ) + ), "incorrect error response" suite "Waku LightPush Validation Tests": asyncTest "Validate message size exceeds limit": @@ -174,5 +179,10 @@ suite "RLN Proofs as a Lightpush Service": if not publishResponse.isOk(): echo "Publish failed: ", publishResponse.error() - # Then the message is relayed to the server - assertResultOk publishResponse + # Then the message is not relayed but not due to RLN + assert publishResponse.isErr(), "We expect an error response" + assert ( + publishResponse.error.contains( + "Lightpush request has not been published to any peers" + ) + ), "incorrect error response" diff --git a/waku/waku_lightpush/callbacks.nim b/waku/waku_lightpush/callbacks.nim index c71efad31..93128fd10 100644 --- a/waku/waku_lightpush/callbacks.nim +++ b/waku/waku_lightpush/callbacks.nim @@ -54,5 +54,8 @@ proc getRelayPushHandler*( ## Agreed change expected to the lightpush protocol to better handle such case. https://github.com/waku-org/pm/issues/93 let msgHash = computeMessageHash(pubsubTopic, message).to0xHex() notice "Lightpush request has not been published to any peers", msg_hash = msgHash + return err( + "Lightpush request has not been published to any peers. msg_hash: " & msgHash + ) return ok() diff --git a/waku/waku_lightpush/protocol.nim b/waku/waku_lightpush/protocol.nim index 4af2272b2..b646a1571 100644 --- a/waku/waku_lightpush/protocol.nim +++ b/waku/waku_lightpush/protocol.nim @@ -42,8 +42,10 @@ proc handleRequest*( pubSubTopic = request.get().pubSubTopic message = request.get().message + waku_lightpush_messages.inc(labelValues = ["PushRequest"]) - notice "lightpush request", + + notice "handling lightpush request", peer_id = peerId, requestId = requestId, pubsubTopic = pubsubTopic,