mirror of https://github.com/waku-org/nwaku.git
chore: Revert lightpush error handling to allow zero peer publish again succeed (#2099)
* This reverts former change on lighpush error handling, now zero peer publish still succeed. This will allow js-waku use case to succeed. * Adjust lightpush rest-api test
This commit is contained in:
parent
c019016545
commit
f05528d4be
|
@ -171,24 +171,27 @@ suite "Waku v2 Rest API - lightpush":
|
||||||
|
|
||||||
await restLightPushTest.shutdown()
|
await restLightPushTest.shutdown()
|
||||||
|
|
||||||
asyncTest "Push message request service not available":
|
## TODO: Re-work this test when lightpush protocol change is done: https://github.com/waku-org/pm/issues/93
|
||||||
# Given
|
## This test is similar when no available peer exists for publish. Currently it is returning success,
|
||||||
let restLightPushTest = await RestLightPushTest.init()
|
## that makes this test not useful.
|
||||||
|
# asyncTest "Push message request service not available":
|
||||||
|
# # Given
|
||||||
|
# let restLightPushTest = await RestLightPushTest.init()
|
||||||
|
|
||||||
# When
|
# # When
|
||||||
let message : RelayWakuMessage = fakeWakuMessage(contentTopic = DefaultContentTopic,
|
# let message : RelayWakuMessage = fakeWakuMessage(contentTopic = DefaultContentTopic,
|
||||||
payload = toBytes("TEST-1")).toRelayWakuMessage()
|
# payload = toBytes("TEST-1")).toRelayWakuMessage()
|
||||||
|
|
||||||
let requestBody = PushRequest(pubsubTopic: some("NoExistTopic"),
|
# let requestBody = PushRequest(pubsubTopic: some("NoExistTopic"),
|
||||||
message: message)
|
# message: message)
|
||||||
let response = await restLightPushTest.client.sendPushRequest(requestBody)
|
# let response = await restLightPushTest.client.sendPushRequest(requestBody)
|
||||||
|
|
||||||
echo "response", $response
|
# echo "response", $response
|
||||||
|
|
||||||
# Then
|
# # Then
|
||||||
check:
|
# check:
|
||||||
response.status == 503
|
# response.status == 503
|
||||||
$response.contentType == $MIMETYPE_TEXT
|
# $response.contentType == $MIMETYPE_TEXT
|
||||||
response.data == "Failed to request a message push: Can not publish to any peers"
|
# response.data == "Failed to request a message push: Can not publish to any peers"
|
||||||
|
|
||||||
await restLightPushTest.shutdown()
|
# await restLightPushTest.shutdown()
|
||||||
|
|
|
@ -876,7 +876,8 @@ proc mountLightPush*(node: WakuNode) {.async.} =
|
||||||
let publishedCount = await node.wakuRelay.publish(pubsubTopic, message.encode().buffer)
|
let publishedCount = await node.wakuRelay.publish(pubsubTopic, message.encode().buffer)
|
||||||
|
|
||||||
if publishedCount == 0:
|
if publishedCount == 0:
|
||||||
return err("Can not publish to any peers")
|
## Agreed change expected to the lightpush protocol to better handle such case. https://github.com/waku-org/pm/issues/93
|
||||||
|
debug("Lightpush request has not been published to any peers")
|
||||||
|
|
||||||
return ok()
|
return ok()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue