2023-10-11 06:58:45 +00:00
|
|
|
|
{.used.}
|
|
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
|
import std/[options, sequtils, tables], testutils/unittests, chronos, chronicles
|
2023-10-11 06:58:45 +00:00
|
|
|
|
import
|
|
|
|
|
../../waku/waku_metadata,
|
|
|
|
|
../../waku/waku_metadata/rpc,
|
|
|
|
|
./testlib/wakucore,
|
|
|
|
|
./testlib/wakunode
|
|
|
|
|
|
|
|
|
|
procSuite "Waku Protobufs":
|
|
|
|
|
# TODO: Missing test coverage in many encode/decode protobuf functions
|
|
|
|
|
|
|
|
|
|
test "WakuMetadataResponse":
|
2024-03-15 23:08:47 +00:00
|
|
|
|
let res = WakuMetadataResponse(clusterId: some(7), shards: @[10, 23, 33])
|
2023-10-11 06:58:45 +00:00
|
|
|
|
|
|
|
|
|
let buffer = res.encode()
|
|
|
|
|
|
|
|
|
|
let decodedBuff = WakuMetadataResponse.decode(buffer.buffer)
|
|
|
|
|
check:
|
|
|
|
|
decodedBuff.isOk()
|
|
|
|
|
decodedBuff.get().clusterId.get() == res.clusterId.get()
|
|
|
|
|
decodedBuff.get().shards == res.shards
|
|
|
|
|
|
|
|
|
|
test "WakuMetadataRequest":
|
2024-03-15 23:08:47 +00:00
|
|
|
|
let req = WakuMetadataRequest(clusterId: some(5), shards: @[100, 2, 0])
|
2023-10-11 06:58:45 +00:00
|
|
|
|
|
|
|
|
|
let buffer = req.encode()
|
|
|
|
|
|
|
|
|
|
let decodedBuff = WakuMetadataRequest.decode(buffer.buffer)
|
|
|
|
|
check:
|
|
|
|
|
decodedBuff.isOk()
|
|
|
|
|
decodedBuff.get().clusterId.get() == req.clusterId.get()
|
|
|
|
|
decodedBuff.get().shards == req.shards
|