nwaku/tests/testlib/tables.nim

22 lines
679 B
Nim
Raw Normal View History

import std/[tables, sequtils, options]
import waku/waku_core/topics, ../testlib/wakucore
proc `==`*(
2024-08-19 09:29:35 +00:00
table: Table[pubsub_topic.RelayShard, seq[NsContentTopic]],
other: array[0 .. 0, (string, seq[string])],
): bool =
let otherTyped = other.map(
2024-08-19 09:29:35 +00:00
proc(item: (string, seq[string])): (RelayShard, seq[NsContentTopic]) =
let
(pubsubTopic, contentTopics) = item
2024-08-19 09:29:35 +00:00
shard = RelayShard.parse(pubsubTopic).value()
nsContentTopics = contentTopics.map(
proc(contentTopic: string): NsContentTopic =
NsContentTopic.parse(contentTopic).value()
)
2024-08-19 09:29:35 +00:00
return (shard, nsContentTopics)
)
table == otherTyped.toTable()