logos-delivery/tests/test_utils_compat.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

53 lines
1.2 KiB
Nim

{.used.}
import testutils/unittests
import
results,
logos_delivery/waku/waku_core/message,
logos_delivery/waku/waku_core/time,
./testlib/common
suite "Waku Payload":
test "Encode/Decode waku message with timestamp":
## Test encoding and decoding of the timestamp field of a WakuMessage
## Given
let
version = 0'u32
payload = @[byte 0, 1, 2]
timestamp = Timestamp(10)
msg = WakuMessage(payload: payload, version: version, timestamp: timestamp)
## When
let pb = msg.encode()
let msgDecoded = WakuMessage.decode(pb)
## Then
check:
msgDecoded.isOk()
let timestampDecoded = msgDecoded.value.timestamp
check:
timestampDecoded == timestamp
test "Encode/Decode waku message without timestamp":
## Test the encoding and decoding of a WakuMessage with an empty timestamp field
## Given
let
version = 0'u32
payload = @[byte 0, 1, 2]
msg = WakuMessage(payload: payload, version: version)
## When
let pb = msg.encode()
let msgDecoded = WakuMessage.decode(pb)
## Then
check:
msgDecoded.isOk()
let timestampDecoded = msgDecoded.value.timestamp
check:
timestampDecoded == Timestamp(0)