From 866e248927843e80f761da2e42b3b8df0c1a8def Mon Sep 17 00:00:00 2001 From: Gabriel mermelstein Date: Wed, 17 Jul 2024 15:20:52 +0300 Subject: [PATCH] mounting protocols before starting nodes in tests --- tests/waku_store/test_wakunode_store.nim | 12 +++++------ .../waku_store_legacy/test_wakunode_store.nim | 20 +++++++++---------- waku/node/waku_node.nim | 2 ++ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/waku_store/test_wakunode_store.nim b/tests/waku_store/test_wakunode_store.nim index 1f48d18f27..94b3d4e36f 100644 --- a/tests/waku_store/test_wakunode_store.nim +++ b/tests/waku_store/test_wakunode_store.nim @@ -74,8 +74,6 @@ 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 @@ -83,6 +81,8 @@ procSuite "WakuNode - Store": client.mountStoreClient() + waitFor allFutures(client.start(), server.start()) + ## Given let req = StoreQueryRequest(includeData: true, contentTopics: @[DefaultContentTopic]) @@ -109,8 +109,6 @@ 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 @@ -118,6 +116,8 @@ procSuite "WakuNode - Store": client.mountStoreClient() + waitFor allFutures(client.start(), server.start()) + ## Given let req = StoreQueryRequest( includeData: true, @@ -165,8 +165,6 @@ 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 @@ -174,6 +172,8 @@ procSuite "WakuNode - Store": client.mountStoreClient() + waitFor allFutures(client.start(), server.start()) + ## Given let req = StoreQueryRequest( includeData: true, diff --git a/tests/waku_store_legacy/test_wakunode_store.nim b/tests/waku_store_legacy/test_wakunode_store.nim index 496ab753e5..ed3b08f717 100644 --- a/tests/waku_store_legacy/test_wakunode_store.nim +++ b/tests/waku_store_legacy/test_wakunode_store.nim @@ -65,8 +65,6 @@ 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 @@ -74,6 +72,8 @@ procSuite "WakuNode - Store Legacy": client.mountLegacyStoreClient() + waitFor allFutures(client.start(), server.start()) + ## Given let req = HistoryQuery(contentTopics: @[DefaultContentTopic]) let serverPeer = server.peerInfo.toRemotePeerInfo() @@ -99,8 +99,6 @@ 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 @@ -108,6 +106,8 @@ procSuite "WakuNode - Store Legacy": client.mountLegacyStoreClient() + waitFor allFutures(client.start(), server.start()) + ## Given let req = HistoryQuery( contentTopics: @[DefaultContentTopic], @@ -154,8 +154,6 @@ 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 @@ -163,6 +161,8 @@ procSuite "WakuNode - Store Legacy": client.mountLegacyStoreClient() + waitFor allFutures(client.start(), server.start()) + ## Given let req = HistoryQuery( contentTopics: @[DefaultContentTopic], @@ -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() @@ -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 @@ -279,8 +279,6 @@ 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 @@ -288,6 +286,8 @@ procSuite "WakuNode - Store Legacy": 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, diff --git a/waku/node/waku_node.nim b/waku/node/waku_node.nim index a793615322..013fb7ffc6 100644 --- a/waku/node/waku_node.nim +++ b/waku/node/waku_node.nim @@ -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