mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-23 13:03:11 +00:00
Fix ResultDefect on success and stale test stubs in lightpush retry path
Two bugs left by a bad merge:
1. lightpush.nim: isRlnRelatedFailure was computed before firstResult.isOk()
was checked, accessing firstResult.error unconditionally. When publish
succeeds, this raises a ResultDefect. Reorder the guard so isOk()/isNone()
short-circuits before the error fields are touched.
2. test_wakunode_lightpush.nim: the 420-retry stubs used descriptions
("simulated stale merkle path", "still stale") that don't contain
RlnValidatorErrorMsg. The code gates 420 retries on that substring to
distinguish RLN rejections from unrelated INVALID_MESSAGE responses
(e.g. oversized messages). Update stubs to emit RlnValidatorErrorMsg so
the retry path fires as the tests expect.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
26b8d2fa6e
commit
43dff68f49
@ -335,13 +335,14 @@ proc lightpushPublish*(
|
||||
# also returned for non-RLN rejections (e.g. oversized messages), so require
|
||||
# the error description to contain RlnValidatorErrorMsg — matching the legacy
|
||||
# lightpush path — to avoid unbounded on-chain RPCs on non-RLN errors.
|
||||
if firstResult.isOk() or rln.isNone():
|
||||
return firstResult
|
||||
let isRlnRelatedFailure =
|
||||
firstResult.error.code == LightPushErrorCode.OUT_OF_RLN_PROOF or
|
||||
(
|
||||
firstResult.error.code == LightPushErrorCode.OUT_OF_RLN_PROOF or (
|
||||
firstResult.error.code == LightPushErrorCode.INVALID_MESSAGE and
|
||||
firstResult.error.desc.get("").contains(RlnValidatorErrorMsg)
|
||||
)
|
||||
if firstResult.isOk() or rln.isNone() or not isRlnRelatedFailure:
|
||||
if not isRlnRelatedFailure:
|
||||
return firstResult
|
||||
|
||||
info "lightpush send rejected; refreshing merkle proof and retrying once",
|
||||
|
||||
@ -231,7 +231,7 @@ suite "RLN Proofs as a Lightpush Service":
|
||||
inc callCount
|
||||
if callCount == 1:
|
||||
return lighpushErrorResult(
|
||||
LightPushErrorCode.INVALID_MESSAGE, "simulated stale merkle path"
|
||||
LightPushErrorCode.INVALID_MESSAGE, RlnValidatorErrorMsg
|
||||
)
|
||||
return lightpushSuccessResult(1)
|
||||
server.wakuLightPush.pushHandler = stub
|
||||
@ -287,7 +287,7 @@ suite "RLN Proofs as a Lightpush Service":
|
||||
pubsubTopic: PubsubTopic, message: WakuMessage
|
||||
): Future[WakuLightPushResult] {.async.} =
|
||||
inc callCount
|
||||
return lighpushErrorResult(LightPushErrorCode.INVALID_MESSAGE, "still stale")
|
||||
return lighpushErrorResult(LightPushErrorCode.INVALID_MESSAGE, RlnValidatorErrorMsg)
|
||||
server.wakuLightPush.pushHandler = stub
|
||||
|
||||
let response = await server.lightpushPublish(some(pubsubTopic), message)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user