mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-05 11:34:45 +00:00
ab344a9dec
* chore: remove v1 code * chore: deprecate support for v1 compatibility from JSON-RPC API * chore: remove v1 tests from JSON-RPC suite * chore: remove wakubridge code * chore: remove v1 compatibility functions * chore: remove support for v1 payloads from chat2 app * chore: remove v1 from CI processes * fix: lingering references to private API functions * fix: remove v1 compat from chat2 * fix: some more lingering references in tests
55 lines
1.2 KiB
Nim
55 lines
1.2 KiB
Nim
{.used.}
|
|
|
|
import
|
|
testutils/unittests
|
|
import
|
|
stew/results,
|
|
../../waku/v2/waku_core/message,
|
|
../../waku/v2/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.buffer)
|
|
|
|
## 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.buffer)
|
|
|
|
## Then
|
|
check:
|
|
msgDecoded.isOk()
|
|
|
|
let timestampDecoded = msgDecoded.value.timestamp
|
|
check:
|
|
timestampDecoded == Timestamp(0)
|