test: assert 404 via raw string client in messaging REST test

presto's typed REST client raises RestDecodingError when it cannot decode
a non-2xx text error body into the response type. Add a RestResponse[string]
stub (messagingGetSendEventsByIdRawV1) and point the "already-polled id ->
404" assertion at it, matching the relay REST test pattern.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
NagyZoltanPeter 2026-07-03 12:25:09 +02:00
parent 5e54ed8007
commit d194b6605f
No known key found for this signature in database
GPG Key ID: 3E1F97CF4A7B6F42
2 changed files with 13 additions and 4 deletions

View File

@ -50,6 +50,14 @@ proc messagingGetSendEventsByIdV1*(
rest, endpoint: "/messaging/v1/events/send/{requestId}", meth: HttpMethod.MethodGet
.}
# Raw variant: the typed client above cannot decode a non-2xx text error body,
# so status-code assertions (e.g. 404) use this string form.
proc messagingGetSendEventsByIdRawV1*(
requestId: string
): RestResponse[string] {.
rest, endpoint: "/messaging/v1/events/send/{requestId}", meth: HttpMethod.MethodGet
.}
proc messagingGetReceivedMessagesV1*(): RestResponse[seq[ReceivedMessageRecord]] {.
rest, endpoint: "/messaging/v1/events/received", meth: HttpMethod.MethodGet
.}

View File

@ -11,6 +11,7 @@ import brokers/broker_context
import logos_delivery
import
logos_delivery/messaging/rest_api/client as messaging_rest_client,
logos_delivery/waku/rest_api/endpoint/client,
logos_delivery/waku/common/base64
import tools/confutils/cli_args
import ../testlib/[wakucore, testasync]
@ -99,8 +100,7 @@ suite "Messaging REST API":
brokerCtx, MessageSentEvent(requestId: reqA, messageHash: "0xaa")
)
MessageErrorEvent.emit(
brokerCtx,
MessageErrorEvent(requestId: reqB, messageHash: "0xbb", error: "boom"),
brokerCtx, MessageErrorEvent(requestId: reqB, messageHash: "0xbb", error: "boom")
)
await sleepAsync(settleDelay)
@ -113,8 +113,9 @@ suite "Messaging REST API":
byIdResp.data.events.anyIt(it.kind == SendEventKind.Sent)
byIdResp.data.events.anyIt(it.kind == SendEventKind.Propagated)
# Unknown / already-polled id → 404.
let missingResp = await client.messagingGetSendEventsByIdV1($reqA)
# Unknown / already-polled id → 404 (raw string client so the text error
# body decodes; the typed client would raise on a non-2xx body).
let missingResp = await client.messagingGetSendEventsByIdRawV1($reqA)
check missingResp.status == 404
# GET all now returns only reqB (with its error), then clears.