Skip to content

Commit

Permalink
mounting protocols before starting nodes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer committed Jul 17, 2024
1 parent 2207ddb commit 866e248
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
12 changes: 6 additions & 6 deletions tests/waku_store/test_wakunode_store.nim
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ procSuite "WakuNode - Store":
clientKey = generateSecp256k1Key()
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0))

waitFor allFutures(client.start(), server.start())

let mountArchiveRes = server.mountArchive(archiveA)
assert mountArchiveRes.isOk(), mountArchiveRes.error

waitFor server.mountStore()

client.mountStoreClient()

waitFor allFutures(client.start(), server.start())

## Given
let req =
StoreQueryRequest(includeData: true, contentTopics: @[DefaultContentTopic])
Expand All @@ -109,15 +109,15 @@ procSuite "WakuNode - Store":
clientKey = generateSecp256k1Key()
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0))

waitFor allFutures(client.start(), server.start())

let mountArchiveRes = server.mountArchive(archiveA)
assert mountArchiveRes.isOk(), mountArchiveRes.error

waitFor server.mountStore()

client.mountStoreClient()

waitFor allFutures(client.start(), server.start())

## Given
let req = StoreQueryRequest(
includeData: true,
Expand Down Expand Up @@ -165,15 +165,15 @@ procSuite "WakuNode - Store":
clientKey = generateSecp256k1Key()
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0))

waitFor allFutures(client.start(), server.start())

let mountArchiveRes = server.mountArchive(archiveA)
assert mountArchiveRes.isOk(), mountArchiveRes.error

waitFor server.mountStore()

client.mountStoreClient()

waitFor allFutures(client.start(), server.start())

## Given
let req = StoreQueryRequest(
includeData: true,
Expand Down
20 changes: 10 additions & 10 deletions tests/waku_store_legacy/test_wakunode_store.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ procSuite "WakuNode - Store Legacy":
clientKey = generateSecp256k1Key()
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0))

waitFor allFutures(client.start(), server.start())

let mountArchiveRes = server.mountLegacyArchive(archiveA)
assert mountArchiveRes.isOk(), mountArchiveRes.error

waitFor server.mountLegacyStore()

client.mountLegacyStoreClient()

waitFor allFutures(client.start(), server.start())

## Given
let req = HistoryQuery(contentTopics: @[DefaultContentTopic])
let serverPeer = server.peerInfo.toRemotePeerInfo()
Expand All @@ -99,15 +99,15 @@ procSuite "WakuNode - Store Legacy":
clientKey = generateSecp256k1Key()
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0))

waitFor allFutures(client.start(), server.start())

let mountArchiveRes = server.mountLegacyArchive(archiveA)
assert mountArchiveRes.isOk(), mountArchiveRes.error

waitFor server.mountLegacyStore()

client.mountLegacyStoreClient()

waitFor allFutures(client.start(), server.start())

## Given
let req = HistoryQuery(
contentTopics: @[DefaultContentTopic],
Expand Down Expand Up @@ -154,15 +154,15 @@ procSuite "WakuNode - Store Legacy":
clientKey = generateSecp256k1Key()
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0))

waitFor allFutures(client.start(), server.start())

let mountArchiveRes = server.mountLegacyArchive(archiveA)
assert mountArchiveRes.isOk(), mountArchiveRes.error

waitFor server.mountLegacyStore()

client.mountLegacyStoreClient()

waitFor allFutures(client.start(), server.start())

## Given
let req = HistoryQuery(
contentTopics: @[DefaultContentTopic],
Expand Down Expand Up @@ -213,8 +213,6 @@ procSuite "WakuNode - Store Legacy":
clientKey = generateSecp256k1Key()
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0))

waitFor allFutures(client.start(), server.start(), filterSource.start())

waitFor filterSource.mountFilter()
let driver = newSqliteArchiveDriver()

Expand All @@ -225,6 +223,8 @@ procSuite "WakuNode - Store Legacy":
waitFor server.mountFilterClient()
client.mountLegacyStoreClient()

waitFor allFutures(client.start(), server.start(), filterSource.start())

## Given
let message = fakeWakuMessage()
let
Expand Down Expand Up @@ -279,15 +279,15 @@ procSuite "WakuNode - Store Legacy":
clientKey = generateSecp256k1Key()
client = newTestWakuNode(clientKey, parseIpAddress("0.0.0.0"), Port(0))

waitFor allFutures(client.start(), server.start())

let mountArchiveRes = server.mountLegacyArchive(archiveA)
assert mountArchiveRes.isOk(), mountArchiveRes.error

waitFor server.mountLegacyStore()

client.mountLegacyStoreClient()

waitFor allFutures(client.start(), server.start())

## Forcing a bad cursor with empty digest data
var data: array[32, byte] = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Expand Down
2 changes: 2 additions & 0 deletions waku/node/waku_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,8 @@ proc start*(node: WakuNode) {.async.} =
if not node.isBootstrapOnly():
## The switch will update addresses after start using the addressMapper
await node.switch.start()
else:
warn "Did not start libp2p switch as no protocols are mounted"

node.started = true

Expand Down

0 comments on commit 866e248

Please sign in to comment.