Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: lightpush better feedback if lightpush service node without peers #2951

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions tests/node/test_wakunode_lightpush.nim
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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"
3 changes: 3 additions & 0 deletions waku/waku_lightpush/callbacks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 3 additions & 1 deletion waku/waku_lightpush/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading