Clean-up test_shh_connect

This commit is contained in:
kdeme 2019-10-03 12:12:22 +02:00 committed by zah
parent 5bc7612e2f
commit 18225f93a5
1 changed files with 7 additions and 21 deletions

View File

@ -92,10 +92,8 @@ suite "Whisper connections":
node2.protocolState(Whisper).queue.items.len == 4 node2.protocolState(Whisper).queue.items.len == 4
var f = all(futures)
await f or sleepAsync(waitInterval)
check: check:
f.finished == true await allFutures(futures).withTimeout(waitInterval)
node1.protocolState(Whisper).queue.items.len == 4 node1.protocolState(Whisper).queue.items.len == 4
for filter in filters: for filter in filters:
@ -125,10 +123,7 @@ suite "Whisper connections":
payload = payloads[1]) == true payload = payloads[1]) == true
node2.protocolState(Whisper).queue.items.len == 2 node2.protocolState(Whisper).queue.items.len == 2
var f = all(futures) await allFutures(futures).withTimeout(waitInterval)
await f or sleepAsync(waitInterval)
check:
f.finished == true
node1.protocolState(Whisper).queue.items.len == 2 node1.protocolState(Whisper).queue.items.len == 2
node1.unsubscribeFilter(filter1) == true node1.unsubscribeFilter(filter1) == true
@ -155,11 +150,8 @@ suite "Whisper connections":
check: check:
node2.postMessage(ttl = safeTTL, topic = topic, payload = payload) == true node2.postMessage(ttl = safeTTL, topic = topic, payload = payload) == true
await futures[0] or sleepAsync(waitInterval) (await futures[0].withTimeout(waitInterval)) == true
await futures[1] or sleepAsync(waitInterval) (await futures[1].withTimeout(waitInterval)) == false
check:
futures[0].finished == true
futures[1].finished == false
node1.protocolState(Whisper).queue.items.len == 1 node1.protocolState(Whisper).queue.items.len == 1
node1.unsubscribeFilter(filter1) == true node1.unsubscribeFilter(filter1) == true
@ -214,9 +206,7 @@ suite "Whisper connections":
payload = payload) == true payload = payload) == true
node2.protocolState(Whisper).queue.items.len == 1 node2.protocolState(Whisper).queue.items.len == 1
await f or sleepAsync(waitInterval) (await f.withTimeout(waitInterval)) == false
check:
f.finished == false
node1.protocolState(Whisper).queue.items.len == 0 node1.protocolState(Whisper).queue.items.len == 0
resetMessageQueues(node1, node2) resetMessageQueues(node1, node2)
@ -228,9 +218,7 @@ suite "Whisper connections":
payload = payload) == true payload = payload) == true
node2.protocolState(Whisper).queue.items.len == 1 node2.protocolState(Whisper).queue.items.len == 1
await f or sleepAsync(waitInterval) await f.withTimeout(waitInterval)
check:
f.finished == true
f.read() == 1 f.read() == 1
node1.protocolState(Whisper).queue.items.len == 1 node1.protocolState(Whisper).queue.items.len == 1
@ -299,9 +287,7 @@ suite "Whisper connections":
payload = repeat(byte 4, 10), payload = repeat(byte 4, 10),
targetPeer = some(toNodeId(node1.keys.pubkey))) == true targetPeer = some(toNodeId(node1.keys.pubkey))) == true
await f or sleepAsync(waitInterval) await f.withTimeout(waitInterval)
check:
f.finished == true
f.read() == 1 f.read() == 1
node1.protocolState(Whisper).queue.items.len == 0 node1.protocolState(Whisper).queue.items.len == 0
node2.protocolState(Whisper).queue.items.len == 0 node2.protocolState(Whisper).queue.items.len == 0