mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-11 22:47:31 +00:00
d6c48da071
* adds the index object * adds the indexedWakuMessage * adds the PagingInfo * Adds PagingInfo to HistoryResponse and HistoryQuery * adds the computeIndex procedure * Update waku/node/v2/waku_types.nim Fixes spacing issues Co-authored-by: Oskar Thorén <ot@oskarthoren.com> * Changes timestamp to receivedTime and checks for the empty contentTopic * adds a test file for pagination with test scenarios for computeIndex * changes receivedTimestamp to the unix timestamp * updates a test case * replaces std/sha1 with nimcrypto/sha2 * changes the tests titles * minor comments * Some clean up * fixes some formatting issue * edits a test-case * adds comments * changes the digest type to MDigest[256] and modifies the computeIndex * fixes formatting issue * edits indentations and fixes a bug * minor edits * changes suite to procSuite and adds a new text case * fixes all the indentations * cleanup of the imports Co-authored-by: Oskar Thorén <ot@oskarthoren.com>
28 lines
863 B
Nim
28 lines
863 B
Nim
import
|
|
std/unittest,
|
|
../../waku/node/v2/waku_types,
|
|
../test_helpers
|
|
|
|
procSuite "pagination":
|
|
test "computeIndex: empty contentTopic test":
|
|
let
|
|
wm = WakuMessage(payload: @[byte 1, 2, 3])
|
|
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
|
|
index.receivedTime != 0 # the timestamp should be a non-zero value
|
|
|
|
test "computeIndex: identical WakuMessages test":
|
|
let
|
|
wm = WakuMessage(payload: @[byte 1, 2, 3], contentTopic: "topic2")
|
|
index1 = wm.computeIndex()
|
|
wm2 = WakuMessage(payload: @[byte 1, 2, 3], contentTopic: "topic2")
|
|
index2 = wm2.computeIndex()
|
|
|
|
check:
|
|
# the digests of two identical WakuMessages must be the same
|
|
index1.digest == index2.digest
|
|
|