logos-messaging-nim/tests/wakunode_rest/test_rest_debug_serdes.nim
NagyZoltanPeter 1762548741
chore: clarify api folders (#3637)
* Rename waku_api to rest_api and underlying rest to endpoint for clearity
* Rename node/api to node/kernel_api to suggest that it is an internal accessor to node interface + make everything compile after renaming
* make waku api a top level import
* fix use of relative path imports and use default to root rather in case of waku and tools modules
2025-11-15 23:31:09 +01:00

35 lines
978 B
Nim

{.used.}
import results, stew/byteutils, testutils/unittests, json_serialization
import waku/rest_api/endpoint/serdes, waku/rest_api/endpoint/debug/types
suite "Waku v2 REST API - Debug - serialization":
suite "DebugWakuInfo - decode":
test "optional field is not provided":
# Given
let jsonBytes = toBytes("""{ "listenAddresses":["123"] }""")
# When
let res = decodeFromJsonBytes(DebugWakuInfo, jsonBytes, requireAllFields = true)
# Then
require(res.isOk())
let value = res.get()
check:
value.listenAddresses == @["123"]
value.enrUri.isNone()
suite "DebugWakuInfo - encode":
test "optional field is none":
# Given
let data = DebugWakuInfo(listenAddresses: @["GO"], enrUri: none(string))
# When
let res = encodeIntoJsonBytes(data)
# Then
require(res.isOk())
let value = res.get()
check:
value == toBytes("""{"listenAddresses":["GO"]}""")