2020-10-30 19:00:14 +00:00
|
|
|
{.used.}
|
2020-10-20 02:20:44 +00:00
|
|
|
import
|
2022-02-17 10:00:45 +00:00
|
|
|
std/[algorithm, options, sequtils],
|
2021-03-26 09:52:04 +00:00
|
|
|
testutils/unittests, nimcrypto/sha2,
|
2021-04-02 21:28:46 +00:00
|
|
|
libp2p/protobuf/minprotobuf,
|
2020-11-24 04:34:32 +00:00
|
|
|
../../waku/v2/protocol/waku_store/waku_store,
|
2022-02-17 15:00:15 +00:00
|
|
|
../../waku/v2/utils/time,
|
2020-10-20 02:20:44 +00:00
|
|
|
../test_helpers
|
|
|
|
|
2020-11-09 04:48:09 +00:00
|
|
|
|
2022-02-17 10:00:45 +00:00
|
|
|
proc createSampleStoreQueue(s: int): StoreQueueRef =
|
|
|
|
## takes s as input and outputs a StoreQueue with s amount of IndexedWakuMessage
|
|
|
|
|
|
|
|
let testStoreQueue = StoreQueueRef.new(s)
|
|
|
|
|
2020-11-09 04:48:09 +00:00
|
|
|
var data {.noinit.}: array[32, byte]
|
|
|
|
for x in data.mitems: x = 1
|
2022-02-17 10:00:45 +00:00
|
|
|
|
2020-11-09 04:48:09 +00:00
|
|
|
for i in 0..<s:
|
2022-02-17 10:00:45 +00:00
|
|
|
discard testStoreQueue.add(IndexedWakuMessage(msg: WakuMessage(payload: @[byte i]),
|
2022-02-17 15:00:15 +00:00
|
|
|
index: Index(receiverTime: Timestamp(i),
|
|
|
|
senderTime: Timestamp(i),
|
2022-02-17 10:00:45 +00:00
|
|
|
digest: MDigest[256](data: data)) ))
|
|
|
|
|
|
|
|
return testStoreQueue
|
2020-11-09 04:48:09 +00:00
|
|
|
|
2020-10-20 02:20:44 +00:00
|
|
|
procSuite "pagination":
|
2020-11-09 04:48:09 +00:00
|
|
|
test "Index computation test":
|
2020-10-20 02:20:44 +00:00
|
|
|
let
|
2021-07-07 23:56:20 +00:00
|
|
|
wm = WakuMessage(payload: @[byte 1, 2, 3], timestamp: 2)
|
2020-10-20 02:20:44 +00:00
|
|
|
index = wm.computeIndex()
|
|
|
|
check:
|
|
|
|
# the fields of the index should be non-empty
|
|
|
|
len(index.digest.data) != 0
|
|
|
|
len(index.digest.data) == 32 # sha2 output length in bytes
|
2021-07-07 23:56:20 +00:00
|
|
|
index.receiverTime != 0 # the receiver timestamp should be a non-zero value
|
|
|
|
index.senderTime == 2
|
2020-10-20 02:20:44 +00:00
|
|
|
|
|
|
|
let
|
2021-04-08 09:55:19 +00:00
|
|
|
wm1 = WakuMessage(payload: @[byte 1, 2, 3], contentTopic: ContentTopic("/waku/2/default-content/proto"))
|
2020-11-09 04:48:09 +00:00
|
|
|
index1 = wm1.computeIndex()
|
2021-04-08 09:55:19 +00:00
|
|
|
wm2 = WakuMessage(payload: @[byte 1, 2, 3], contentTopic: ContentTopic("/waku/2/default-content/proto"))
|
2020-10-20 02:20:44 +00:00
|
|
|
index2 = wm2.computeIndex()
|
|
|
|
|
|
|
|
check:
|
|
|
|
# the digests of two identical WakuMessages must be the same
|
|
|
|
index1.digest == index2.digest
|
|
|
|
|
2020-11-09 04:48:09 +00:00
|
|
|
test "Forward pagination test":
|
2022-02-17 10:00:45 +00:00
|
|
|
var
|
|
|
|
stQ = createSampleStoreQueue(10)
|
|
|
|
indexList = toSeq(stQ.fwdIterator()).mapIt(it[0]) # Seq copy of the store queue indices for verification
|
|
|
|
msgList = toSeq(stQ.fwdIterator()).mapIt(it[1].msg) # Seq copy of the store queue messages for verification
|
|
|
|
pagingInfo = PagingInfo(pageSize: 2, cursor: indexList[3], direction: PagingDirection.FORWARD)
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for a normal pagination
|
2022-02-17 10:00:45 +00:00
|
|
|
var (data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 2
|
|
|
|
data == msgList[4..5]
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[5]
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == pagingInfo.pageSize
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for an initial pagination request with an empty cursor
|
|
|
|
pagingInfo = PagingInfo(pageSize: 2, direction: PagingDirection.FORWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 2
|
|
|
|
data == msgList[0..1]
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[1]
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 2
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2021-04-12 17:29:09 +00:00
|
|
|
|
|
|
|
# test for an initial pagination request with an empty cursor to fetch the entire history
|
|
|
|
pagingInfo = PagingInfo(pageSize: 13, direction: PagingDirection.FORWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2021-04-12 17:29:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 10
|
|
|
|
data == msgList[0..9]
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[9]
|
2021-04-12 17:29:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 10
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for an empty msgList
|
|
|
|
pagingInfo = PagingInfo(pageSize: 2, direction: PagingDirection.FORWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(createSampleStoreQueue(0), pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 0
|
|
|
|
newPagingInfo.pageSize == 0
|
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.cursor == pagingInfo.cursor
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for a page size larger than the remaining messages
|
2022-02-17 10:00:45 +00:00
|
|
|
pagingInfo = PagingInfo(pageSize: 10, cursor: indexList[3], direction: PagingDirection.FORWARD)
|
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 6
|
|
|
|
data == msgList[4..9]
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[9]
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 6
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for a page size larger than the maximum allowed page size
|
2022-02-17 10:00:45 +00:00
|
|
|
pagingInfo = PagingInfo(pageSize: MaxPageSize+1, cursor: indexList[3], direction: PagingDirection.FORWARD)
|
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
2021-04-09 10:04:21 +00:00
|
|
|
uint64(data.len) <= MaxPageSize
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize <= MaxPageSize
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
2021-07-13 19:01:21 +00:00
|
|
|
# test for a cursor pointing to the end of the message list
|
2022-02-17 10:00:45 +00:00
|
|
|
pagingInfo = PagingInfo(pageSize: 10, cursor: indexList[9], direction: PagingDirection.FORWARD)
|
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 0
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[9]
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 0
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for an invalid cursor
|
|
|
|
pagingInfo = PagingInfo(pageSize: 10, cursor: computeIndex(WakuMessage(payload: @[byte 10])), direction: PagingDirection.FORWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 0
|
|
|
|
newPagingInfo.cursor == pagingInfo.cursor
|
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 0
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.INVALID_CURSOR
|
2021-04-12 17:29:09 +00:00
|
|
|
|
|
|
|
# test initial paging query over a message list with one message
|
2022-02-17 10:00:45 +00:00
|
|
|
var singleItemMsgList = createSampleStoreQueue(1)
|
2021-04-12 17:29:09 +00:00
|
|
|
pagingInfo = PagingInfo(pageSize: 10, direction: PagingDirection.FORWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(singleItemMsgList, pagingInfo)
|
2021-04-12 17:29:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 1
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[0]
|
2021-04-12 17:29:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 1
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2021-04-12 17:29:09 +00:00
|
|
|
|
|
|
|
# test pagination over a message list with one message
|
2022-02-17 10:00:45 +00:00
|
|
|
singleItemMsgList = createSampleStoreQueue(1)
|
|
|
|
pagingInfo = PagingInfo(pageSize: 10, cursor: indexList[0], direction: PagingDirection.FORWARD)
|
|
|
|
(data, newPagingInfo, error) = getPage(singleItemMsgList, pagingInfo)
|
2021-04-12 17:29:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 0
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[0]
|
2021-04-12 17:29:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 0
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2021-04-12 17:29:09 +00:00
|
|
|
|
2020-11-09 04:48:09 +00:00
|
|
|
test "Backward pagination test":
|
|
|
|
var
|
2022-02-17 10:00:45 +00:00
|
|
|
stQ = createSampleStoreQueue(10)
|
|
|
|
indexList = toSeq(stQ.fwdIterator()).mapIt(it[0]) # Seq copy of the store queue indices for verification
|
|
|
|
msgList = toSeq(stQ.fwdIterator()).mapIt(it[1].msg) # Seq copy of the store queue messages for verification
|
|
|
|
pagingInfo = PagingInfo(pageSize: 2, cursor: indexList[3], direction: PagingDirection.BACKWARD)
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for a normal pagination
|
2022-02-17 10:00:45 +00:00
|
|
|
var (data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data == msgList[1..2]
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[1]
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == pagingInfo.pageSize
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for an empty msgList
|
|
|
|
pagingInfo = PagingInfo(pageSize: 2, direction: PagingDirection.BACKWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(createSampleStoreQueue(0), pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 0
|
|
|
|
newPagingInfo.pageSize == 0
|
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.cursor == pagingInfo.cursor
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for an initial pagination request with an empty cursor
|
|
|
|
pagingInfo = PagingInfo(pageSize: 2, direction: PagingDirection.BACKWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 2
|
|
|
|
data == msgList[8..9]
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[8]
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 2
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2021-04-12 17:29:09 +00:00
|
|
|
|
|
|
|
# test for an initial pagination request with an empty cursor to fetch the entire history
|
|
|
|
pagingInfo = PagingInfo(pageSize: 13, direction: PagingDirection.BACKWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2021-04-12 17:29:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 10
|
|
|
|
data == msgList[0..9]
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[0]
|
2021-04-12 17:29:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 10
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for a page size larger than the remaining messages
|
2022-02-17 10:00:45 +00:00
|
|
|
pagingInfo = PagingInfo(pageSize: 5, cursor: indexList[3], direction: PagingDirection.BACKWARD)
|
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data == msgList[0..2]
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[0]
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 3
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for a page size larger than the Maximum allowed page size
|
2022-02-17 10:00:45 +00:00
|
|
|
pagingInfo = PagingInfo(pageSize: MaxPageSize+1, cursor: indexList[3], direction: PagingDirection.BACKWARD)
|
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
2021-04-09 10:04:21 +00:00
|
|
|
uint64(data.len) <= MaxPageSize
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize <= MaxPageSize
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for a cursor pointing to the begining of the message list
|
2022-02-17 10:00:45 +00:00
|
|
|
pagingInfo = PagingInfo(pageSize: 5, cursor: indexList[0], direction: PagingDirection.BACKWARD)
|
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2021-04-09 10:04:21 +00:00
|
|
|
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 0
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[0]
|
2020-11-09 04:48:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 0
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2020-11-09 04:48:09 +00:00
|
|
|
|
|
|
|
# test for an invalid cursor
|
|
|
|
pagingInfo = PagingInfo(pageSize: 5, cursor: computeIndex(WakuMessage(payload: @[byte 10])), direction: PagingDirection.BACKWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(stQ, pagingInfo)
|
2020-11-09 04:48:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 0
|
|
|
|
newPagingInfo.cursor == pagingInfo.cursor
|
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 0
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.INVALID_CURSOR
|
2021-04-12 17:29:09 +00:00
|
|
|
|
|
|
|
# test initial paging query over a message list with one message
|
2022-02-17 10:00:45 +00:00
|
|
|
var singleItemMsgList = createSampleStoreQueue(1)
|
2021-04-12 17:29:09 +00:00
|
|
|
pagingInfo = PagingInfo(pageSize: 10, direction: PagingDirection.BACKWARD)
|
2022-02-17 10:00:45 +00:00
|
|
|
(data, newPagingInfo, error) = getPage(singleItemMsgList, pagingInfo)
|
2021-04-12 17:29:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 1
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[0]
|
2021-04-12 17:29:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 1
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2021-04-12 17:29:09 +00:00
|
|
|
|
|
|
|
# test paging query over a message list with one message
|
2022-02-17 10:00:45 +00:00
|
|
|
singleItemMsgList = createSampleStoreQueue(1)
|
|
|
|
pagingInfo = PagingInfo(pageSize: 10, cursor: indexList[0], direction: PagingDirection.BACKWARD)
|
|
|
|
(data, newPagingInfo, error) = getPage(singleItemMsgList, pagingInfo)
|
2021-04-12 17:29:09 +00:00
|
|
|
check:
|
|
|
|
data.len == 0
|
2022-02-17 10:00:45 +00:00
|
|
|
newPagingInfo.cursor == indexList[0]
|
2021-04-12 17:29:09 +00:00
|
|
|
newPagingInfo.direction == pagingInfo.direction
|
|
|
|
newPagingInfo.pageSize == 0
|
2021-07-13 19:01:21 +00:00
|
|
|
error == HistoryResponseError.NONE
|
2021-04-02 21:28:46 +00:00
|
|
|
|
|
|
|
suite "time-window history query":
|
|
|
|
test "Encode/Decode waku message with timestamp":
|
|
|
|
# test encoding and decoding of the timestamp field of a WakuMessage
|
|
|
|
# Encoding
|
|
|
|
let
|
|
|
|
version = 0'u32
|
|
|
|
payload = @[byte 0, 1, 2]
|
2022-02-17 15:00:15 +00:00
|
|
|
timestamp = Timestamp(10)
|
2021-10-20 00:37:29 +00:00
|
|
|
msg = WakuMessage(payload: payload, version: version, timestamp: timestamp)
|
2021-04-02 21:28:46 +00:00
|
|
|
pb = msg.encode()
|
|
|
|
|
|
|
|
# Decoding
|
|
|
|
let
|
|
|
|
msgDecoded = WakuMessage.init(pb.buffer)
|
|
|
|
check:
|
|
|
|
msgDecoded.isOk()
|
|
|
|
|
|
|
|
let
|
|
|
|
timestampDecoded = msgDecoded.value.timestamp
|
|
|
|
check:
|
|
|
|
timestampDecoded == timestamp
|
2022-02-17 10:00:45 +00:00
|
|
|
|
2021-04-02 21:28:46 +00:00
|
|
|
test "Encode/Decode waku message without timestamp":
|
|
|
|
# test the encoding and decoding of a WakuMessage with an empty timestamp field
|
|
|
|
|
|
|
|
# Encoding
|
|
|
|
let
|
|
|
|
version = 0'u32
|
|
|
|
payload = @[byte 0, 1, 2]
|
2021-10-20 00:37:29 +00:00
|
|
|
msg = WakuMessage(payload: payload, version: version)
|
2021-04-02 21:28:46 +00:00
|
|
|
pb = msg.encode()
|
|
|
|
|
|
|
|
# Decoding
|
|
|
|
let
|
|
|
|
msgDecoded = WakuMessage.init(pb.buffer)
|
|
|
|
doAssert:
|
|
|
|
msgDecoded.isOk()
|
|
|
|
|
|
|
|
let
|
|
|
|
timestampDecoded = msgDecoded.value.timestamp
|
|
|
|
check:
|
2022-02-17 15:00:15 +00:00
|
|
|
timestampDecoded == Timestamp(0)
|