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 c800d7a commit 5bb2a75
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 @@ -79,15 +79,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 @@ -114,15 +114,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 @@ -170,15 +170,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 @@ -70,15 +70,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.mountArchive(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 @@ -104,15 +104,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.mountArchive(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 @@ -159,15 +159,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.mountArchive(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 @@ -218,8 +218,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 @@ -230,6 +228,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 @@ -284,15 +284,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.mountArchive(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 @@ -1272,6 +1272,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 5bb2a75

Please sign in to comment.