mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-28 23:55:43 +00:00
extra changes to serdes, fixing test compilation errors
This commit is contained in:
parent
e3f3177b5a
commit
c897139c49
@ -283,7 +283,7 @@ procSuite "Waku Rest API - Store v3":
|
||||
|
||||
var pages = newSeq[seq[WakuMessage]](2)
|
||||
|
||||
var reqHash = none(WakuMessageHash)
|
||||
var reqHash = none(string)
|
||||
|
||||
for i in 0 ..< 2:
|
||||
let response = await client.getStoreMessagesV3(
|
||||
@ -295,7 +295,7 @@ procSuite "Waku Rest API - Store v3":
|
||||
"", # end time. Empty ignores the field.
|
||||
"", # hashes
|
||||
if reqHash.isSome():
|
||||
reqHash.get().toRestStringWakuMessageHash()
|
||||
reqHash.get()
|
||||
else:
|
||||
"", # base64-encoded digest. Empty ignores the field.
|
||||
"true", # ascending
|
||||
@ -775,7 +775,7 @@ procSuite "Waku Rest API - Store v3":
|
||||
var pages = newSeq[seq[WakuMessage]](2)
|
||||
|
||||
var reqPubsubTopic = DefaultPubsubTopic
|
||||
var reqHash = none(WakuMessageHash)
|
||||
var reqHash = none(string)
|
||||
|
||||
for i in 0 ..< 2:
|
||||
let response = await client.getStoreMessagesV3(
|
||||
@ -787,7 +787,7 @@ procSuite "Waku Rest API - Store v3":
|
||||
"", # end time. Empty ignores the field.
|
||||
"", # hashes
|
||||
if reqHash.isSome():
|
||||
reqHash.get().toRestStringWakuMessageHash()
|
||||
reqHash.get()
|
||||
else:
|
||||
"", # base64-encoded digest. Empty ignores the field.
|
||||
"true", # ascending
|
||||
@ -823,7 +823,7 @@ procSuite "Waku Rest API - Store v3":
|
||||
"", # end time. Empty ignores the field.
|
||||
"", # hashes
|
||||
if reqHash.isSome():
|
||||
reqHash.get().toRestStringWakuMessageHash()
|
||||
reqHash.get()
|
||||
else:
|
||||
"", # base64-encoded digest. Empty ignores the field.
|
||||
)
|
||||
@ -845,7 +845,7 @@ procSuite "Waku Rest API - Store v3":
|
||||
"", # end time. Empty ignores the field.
|
||||
"", # hashes
|
||||
if reqHash.isSome():
|
||||
reqHash.get().toRestStringWakuMessageHash()
|
||||
reqHash.get()
|
||||
else:
|
||||
"", # base64-encoded digest. Empty ignores the field.
|
||||
"true", # ascending
|
||||
|
@ -15,12 +15,12 @@ logScope:
|
||||
topics = "waku node rest store_api"
|
||||
|
||||
proc decodeBytes*(
|
||||
t: typedesc[StoreQueryResponse],
|
||||
t: typedesc[StoreQueryResponseHex],
|
||||
data: openArray[byte],
|
||||
contentType: Opt[ContentTypeData],
|
||||
): RestResult[StoreQueryResponse] =
|
||||
): RestResult[StoreQueryResponseHex] =
|
||||
if MediaType.init($contentType) == MIMETYPE_JSON:
|
||||
let decoded = ?decodeFromJsonBytes(StoreQueryResponse, data)
|
||||
let decoded = ?decodeFromJsonBytes(StoreQueryResponseHex, data)
|
||||
return ok(decoded)
|
||||
|
||||
if MediaType.init($contentType) == MIMETYPE_TEXT:
|
||||
@ -30,11 +30,11 @@ proc decodeBytes*(
|
||||
copyMem(addr res[0], unsafeAddr data[0], len(data))
|
||||
|
||||
return ok(
|
||||
StoreQueryResponse(
|
||||
StoreQueryResponseHex(
|
||||
statusCode: uint32(ErrorCode.BAD_RESPONSE),
|
||||
statusDesc: res,
|
||||
messages: newSeq[WakuMessageKeyValue](0),
|
||||
paginationCursor: none(WakuMessageHash),
|
||||
messages: newSeq[WakuMessageKeyValueHex](0),
|
||||
paginationCursor: none(string),
|
||||
)
|
||||
)
|
||||
|
||||
@ -58,6 +58,6 @@ proc getStoreMessagesV3*(
|
||||
cursor: string = "", # base64-encoded hash
|
||||
ascending: string = "",
|
||||
pageSize: string = "",
|
||||
): RestResponse[StoreQueryResponse] {.
|
||||
): RestResponse[StoreQueryResponseHex] {.
|
||||
rest, endpoint: "/store/v3/messages", meth: HttpMethod.MethodGet
|
||||
.}
|
||||
|
@ -171,7 +171,7 @@ proc readValue*(
|
||||
reader: var JsonReader, value: var WakuMessageKeyValueHex
|
||||
) {.gcsafe, raises: [SerializationError, IOError].} =
|
||||
var
|
||||
messageHash = none(WakuMessageHash)
|
||||
messageHash = none(string)
|
||||
message = none(WakuMessage)
|
||||
pubsubTopic = none(PubsubTopic)
|
||||
|
||||
@ -180,19 +180,19 @@ proc readValue*(
|
||||
of "messageHash":
|
||||
if messageHash.isSome():
|
||||
reader.raiseUnexpectedField(
|
||||
"Multiple `messageHash` fields found", "WakuMessageKeyValue"
|
||||
"Multiple `messageHash` fields found", "WakuMessageKeyValueHex"
|
||||
)
|
||||
messageHash = some(reader.readValue(string))
|
||||
of "message":
|
||||
if message.isSome():
|
||||
reader.raiseUnexpectedField(
|
||||
"Multiple `message` fields found", "WakuMessageKeyValue"
|
||||
"Multiple `message` fields found", "WakuMessageKeyValueHex"
|
||||
)
|
||||
message = some(reader.readValue(WakuMessage))
|
||||
of "pubsubTopic":
|
||||
if pubsubTopic.isSome():
|
||||
reader.raiseUnexpectedField(
|
||||
"Multiple `pubsubTopic` fields found", "WakuMessageKeyValue"
|
||||
"Multiple `pubsubTopic` fields found", "WakuMessageKeyValueHex"
|
||||
)
|
||||
pubsubTopic = some(reader.readValue(string))
|
||||
else:
|
||||
@ -201,7 +201,7 @@ proc readValue*(
|
||||
if messageHash.isNone():
|
||||
reader.raiseUnexpectedValue("Field `messageHash` is missing")
|
||||
|
||||
value = WakuMessageKeyValue(
|
||||
value = WakuMessageKeyValueHex(
|
||||
messageHash: messageHash.get(), message: message, pubsubTopic: pubsubTopic
|
||||
)
|
||||
|
||||
@ -237,31 +237,31 @@ proc readValue*(
|
||||
of "requestId":
|
||||
if requestId.isSome():
|
||||
reader.raiseUnexpectedField(
|
||||
"Multiple `requestId` fields found", "StoreQueryResponse"
|
||||
"Multiple `requestId` fields found", "StoreQueryResponseHex"
|
||||
)
|
||||
requestId = some(reader.readValue(string))
|
||||
of "statusCode":
|
||||
if code.isSome():
|
||||
reader.raiseUnexpectedField(
|
||||
"Multiple `statusCode` fields found", "StoreQueryResponse"
|
||||
"Multiple `statusCode` fields found", "StoreQueryResponseHex"
|
||||
)
|
||||
code = some(reader.readValue(uint32))
|
||||
of "statusDesc":
|
||||
if desc.isSome():
|
||||
reader.raiseUnexpectedField(
|
||||
"Multiple `statusDesc` fields found", "StoreQueryResponse"
|
||||
"Multiple `statusDesc` fields found", "StoreQueryResponseHex"
|
||||
)
|
||||
desc = some(reader.readValue(string))
|
||||
of "messages":
|
||||
if messages.isSome():
|
||||
reader.raiseUnexpectedField(
|
||||
"Multiple `messages` fields found", "StoreQueryResponse"
|
||||
"Multiple `messages` fields found", "StoreQueryResponseHex"
|
||||
)
|
||||
messages = some(reader.readValue(seq[WakuMessageKeyValueHex]))
|
||||
of "paginationCursor":
|
||||
if cursor.isSome():
|
||||
reader.raiseUnexpectedField(
|
||||
"Multiple `paginationCursor` fields found", "StoreQueryResponse"
|
||||
"Multiple `paginationCursor` fields found", "StoreQueryResponseHex"
|
||||
)
|
||||
cursor = some(reader.readValue(string))
|
||||
else:
|
||||
@ -279,7 +279,7 @@ proc readValue*(
|
||||
if messages.isNone():
|
||||
reader.raiseUnexpectedValue("Field `messages` is missing")
|
||||
|
||||
value = StoreQueryResponse(
|
||||
value = StoreQueryResponseHex(
|
||||
requestId: requestId.get(),
|
||||
statusCode: code.get(),
|
||||
statusDesc: desc.get(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user