logos-messaging-nim/tests/v2/test_message_store.nim
Hanno Cornelius d09ba25dd6 Change contentTopic to string (#463)
* Change contentTopic to string

* Missed a spot

* Try to fix Windows CI

Co-authored-by: Oskar Thorén <ot@oskarthoren.com>
2021-04-08 17:55:19 +08:00

38 lines
986 B
Nim

{.used.}
import
std/[unittest, options, tables, sets],
chronos, chronicles,
../../waku/v2/node/storage/message/waku_message_store,
../../waku/v2/protocol/waku_store/waku_store,
./utils
suite "Message Store":
test "set and get works":
let
database = SqliteDatabase.init("", inMemory = true)[]
store = WakuMessageStore.init(database)[]
topic = ContentTopic("/waku/2/default-content/proto")
var msgs = @[
WakuMessage(payload: @[byte 1, 2, 3], contentTopic: topic),
WakuMessage(payload: @[byte 1, 2, 3, 4], contentTopic: topic),
WakuMessage(payload: @[byte 1, 2, 3, 4, 5], contentTopic: topic),
]
defer: store.close()
for msg in msgs:
discard store.put(computeIndex(msg), msg)
var responseCount = 0
proc data(timestamp: uint64, msg: WakuMessage) =
responseCount += 1
check msg in msgs
let res = store.getAll(data)
check:
res.isErr == false
responseCount == 3