logos-delivery/tests/test_waku_protobufs.nim
Fabiana Cecin 44a77b473e
chore: replace minprotobuf with nim-protobuf-serialization
* convert all codecs except sds_persistency to proto2
* add common/protobuf_ext.nim: generic array[N,byte] protobuf extension
* encode PeerId and MultiAddress via libp2p extensions
* encode PublicKey as seq[byte]
* change encode() to return seq[byte] and update all .encode().buffer call sites
* reduce common/protobuf.nim to ProtobufError/ProtobufResult
* add wire-format tests for message, filter v2, lightpush v3/legacy, rln proof
* adapt chat2, chat2mix, chat2bridge, wakustealthcommitments
* delete tests/common/test_protobuf_validation
* add protobuf_serialization to logos_delivery.nimble
2026-07-16 14:43:44 -03:00

35 lines
1.0 KiB
Nim
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{.used.}
import results, std/[sequtils, tables], testutils/unittests, chronos, chronicles
import
logos_delivery/waku/waku_metadata,
logos_delivery/waku/waku_metadata/rpc,
./testlib/wakucore,
./testlib/wakunode
procSuite "Waku Protobufs":
# TODO: Missing test coverage in many encode/decode protobuf functions
test "WakuMetadataResponse":
let res =
WakuMetadataResponse(clusterId: Opt.some(7'u32), shards: @[10'u32, 23, 33])
let buffer = res.encode()
let decodedBuff = WakuMetadataResponse.decode(buffer)
check:
decodedBuff.isOk()
decodedBuff.get().clusterId.get() == res.clusterId.get()
decodedBuff.get().shards == res.shards
test "WakuMetadataRequest":
let req = WakuMetadataRequest(clusterId: Opt.some(5'u32), shards: @[100'u32, 2, 0])
let buffer = req.encode()
let decodedBuff = WakuMetadataRequest.decode(buffer)
check:
decodedBuff.isOk()
decodedBuff.get().clusterId.get() == req.clusterId.get()
decodedBuff.get().shards == req.shards