mirror of https://github.com/waku-org/nwaku.git
stop sockets after use in test_waku_store.nim (#829)
* stop sockets after use - this frees resources (closes sockets) * rename switch and proto - in asyncTest "resume message history" to avoid confusion. Co-authored-by: ksr <kaiserd@users.noreply.github.com>
This commit is contained in:
parent
cf4a1e1c70
commit
d45e3c8f7a
|
@ -54,6 +54,11 @@ procSuite "Waku Store":
|
|||
|
||||
check:
|
||||
(await completionFut.withTimeout(5.seconds)) == true
|
||||
|
||||
# free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
asyncTest "handle query with multiple content filters":
|
||||
let
|
||||
key = PrivateKey.random(ECDSA, rng[]).get()
|
||||
|
@ -96,6 +101,10 @@ procSuite "Waku Store":
|
|||
|
||||
check:
|
||||
(await completionFut.withTimeout(5.seconds)) == true
|
||||
|
||||
# free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
asyncTest "handle query with pubsub topic filter":
|
||||
let
|
||||
|
@ -144,6 +153,10 @@ procSuite "Waku Store":
|
|||
check:
|
||||
(await completionFut.withTimeout(5.seconds)) == true
|
||||
|
||||
# free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
asyncTest "handle query with pubsub topic filter with no match":
|
||||
let
|
||||
key = PrivateKey.random(ECDSA, rng[]).get()
|
||||
|
@ -185,6 +198,11 @@ procSuite "Waku Store":
|
|||
|
||||
check:
|
||||
(await completionFut.withTimeout(5.seconds)) == true
|
||||
|
||||
# free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
asyncTest "handle query with pubsub topic filter matching the entire stored messages":
|
||||
let
|
||||
key = PrivateKey.random(ECDSA, rng[]).get()
|
||||
|
@ -229,6 +247,10 @@ procSuite "Waku Store":
|
|||
check:
|
||||
(await completionFut.withTimeout(5.seconds)) == true
|
||||
|
||||
# free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
asyncTest "handle query with store and restarts":
|
||||
let
|
||||
key = PrivateKey.random(ECDSA, rng[]).get()
|
||||
|
@ -292,6 +314,10 @@ procSuite "Waku Store":
|
|||
|
||||
check:
|
||||
(await completionFut2.withTimeout(5.seconds)) == true
|
||||
|
||||
# free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
asyncTest "handle query with forward pagination":
|
||||
let
|
||||
|
@ -342,6 +368,10 @@ procSuite "Waku Store":
|
|||
check:
|
||||
(await completionFut.withTimeout(5.seconds)) == true
|
||||
|
||||
# free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
asyncTest "handle query with backward pagination":
|
||||
let
|
||||
key = PrivateKey.random(ECDSA, rng[]).get()
|
||||
|
@ -389,6 +419,10 @@ procSuite "Waku Store":
|
|||
check:
|
||||
(await completionFut.withTimeout(5.seconds)) == true
|
||||
|
||||
# free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
asyncTest "handle queries with no paging info (auto-paginate)":
|
||||
let
|
||||
key = PrivateKey.random(ECDSA, rng[]).get()
|
||||
|
@ -439,6 +473,10 @@ procSuite "Waku Store":
|
|||
check:
|
||||
(await completionFut.withTimeout(5.seconds)) == true
|
||||
|
||||
# free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
test "Index Protobuf encoder/decoder test":
|
||||
let
|
||||
index = computeIndex(WakuMessage(payload: @[byte 1], contentTopic: defaultContentTopic))
|
||||
|
@ -666,17 +704,19 @@ procSuite "Waku Store":
|
|||
|
||||
asyncTest "resume message history":
|
||||
# starts a new node
|
||||
var dialSwitch2 = newStandardSwitch()
|
||||
await dialSwitch2.start()
|
||||
var dialSwitch3 = newStandardSwitch()
|
||||
await dialSwitch3.start()
|
||||
|
||||
let proto2 = WakuStore.init(PeerManager.new(dialSwitch2), crypto.newRng())
|
||||
proto2.setPeer(listenSwitch.peerInfo.toRemotePeerInfo())
|
||||
let proto3 = WakuStore.init(PeerManager.new(dialSwitch2), crypto.newRng())
|
||||
proto3.setPeer(listenSwitch.peerInfo.toRemotePeerInfo())
|
||||
|
||||
let successResult = await proto2.resume()
|
||||
let successResult = await proto3.resume()
|
||||
check:
|
||||
successResult.isOk
|
||||
successResult.value == 10
|
||||
proto2.messages.len == 10
|
||||
proto3.messages.len == 10
|
||||
|
||||
await dialSwitch3.stop()
|
||||
|
||||
asyncTest "queryFrom":
|
||||
|
||||
|
@ -723,7 +763,10 @@ procSuite "Waku Store":
|
|||
let successResult = await proto3.resume(some(@[offListenSwitch.peerInfo.toRemotePeerInfo()]))
|
||||
check:
|
||||
successResult.isErr
|
||||
await dialSwitch3.stop()
|
||||
|
||||
#free resources
|
||||
await allFutures(dialSwitch3.stop(),
|
||||
offListenSwitch.stop())
|
||||
|
||||
asyncTest "resume history from a list of candidate peers":
|
||||
|
||||
|
@ -746,8 +789,15 @@ procSuite "Waku Store":
|
|||
successResult.isOk
|
||||
successResult.value == 14
|
||||
|
||||
#free resources
|
||||
await allFutures(dialSwitch3.stop(),
|
||||
offListenSwitch.stop())
|
||||
|
||||
#free resources
|
||||
await allFutures(dialSwitch.stop(),
|
||||
dialSwitch2.stop())
|
||||
dialSwitch2.stop(),
|
||||
listenSwitch.stop())
|
||||
|
||||
|
||||
asyncTest "limit store capacity":
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue