remove sleeps

This commit is contained in:
Dmitriy Ryajov 2020-02-13 13:04:30 -05:00
parent acdaeb8f5d
commit 9023bf786d
5 changed files with 12 additions and 16 deletions

View File

@ -413,8 +413,9 @@ method start*(g: GossipSub) {.async.} =
# setup the heartbeat interval
g.heartbeatCancel = addInterval(GossipSubHeartbeatInterval,
proc (arg: pointer = nil) {.gcsafe, locks: 0.} =
asyncCheck g.heartbeat)
proc (arg: pointer = nil)
{.gcsafe, locks: 0.} =
asyncCheck g.heartbeat)
method stop*(g: GossipSub) {.async.} =
## stopt pubsub

View File

@ -107,11 +107,6 @@ proc pushTo*(s: BufferStream, data: seq[byte]) {.async.} =
await s.lock.acquire()
var index = 0
while true:
# give readers a chance free up the buffer
# it it's full.
if s.readBuf.len >= s.maxSize:
await sleepAsync(1.millis)
while index < data.len and s.readBuf.len < s.maxSize:
s.readBuf.addLast(data[index])
inc(index)

View File

@ -190,7 +190,7 @@ suite "FloodSub":
await node.publish("foobar", cast[seq[byte]]("Hello!"))
await sleepAsync(100.millis)
await sleepAsync(5000.millis)
await sleepAsync(1.minutes)
await allFutures(nodes.mapIt(it.stop()))
await allFutures(awaitters)
@ -223,7 +223,7 @@ suite "FloodSub":
await node.publish("foobar", cast[seq[byte]]("Hello!"))
await sleepAsync(100.millis)
await sleepAsync(5000.millis)
await sleepAsync(1.minutes)
await allFutures(nodes.mapIt(it.stop()))
await allFutures(awaitters)

View File

@ -1,4 +1,4 @@
include ../../libp2p/protocols/pubsub/gossipsub
import testfloodsub,
testgossipsub,
import testgossipsub,
testfloodsub,
testmcache

View File

@ -2,13 +2,13 @@ import testvarint
import testrsa, testecnist, tested25519, testsecp256k1, testcrypto
import testmultibase, testmultihash, testmultiaddress, testcid, testpeer
import testtransport,
testmultistream,
testbufferstream,
testidentify,
import testtransport,
testmultistream,
testbufferstream,
testidentify,
testswitch,
testpeerinfo,
pubsub/testpubsub,
# TODO: placing this before pubsub tests,
# TODO: placing this before pubsub tests,
# breaks some flood and gossip tests - no idea why
testmplex