2020-07-07 11:14:11 +00:00
|
|
|
import chronos, bearssl
|
2020-05-08 20:10:06 +00:00
|
|
|
|
|
|
|
import ../libp2p/transports/tcptransport
|
|
|
|
import ../libp2p/stream/bufferstream
|
2020-07-07 11:14:11 +00:00
|
|
|
import ../libp2p/crypto/crypto
|
2020-06-19 17:29:43 +00:00
|
|
|
import ../libp2p/stream/lpstream
|
2020-05-08 20:10:06 +00:00
|
|
|
|
|
|
|
const
|
|
|
|
StreamTransportTrackerName = "stream.transport"
|
|
|
|
StreamServerTrackerName = "stream.server"
|
|
|
|
|
|
|
|
trackerNames = [
|
2020-06-19 17:29:43 +00:00
|
|
|
# ConnectionTrackerName,
|
2020-05-08 20:10:06 +00:00
|
|
|
BufferStreamTrackerName,
|
|
|
|
TcpTransportTrackerName,
|
|
|
|
StreamTransportTrackerName,
|
|
|
|
StreamServerTrackerName
|
|
|
|
]
|
|
|
|
|
|
|
|
iterator testTrackers*(extras: openArray[string] = []): TrackerBase =
|
|
|
|
for name in trackerNames:
|
|
|
|
let t = getTracker(name)
|
|
|
|
if not isNil(t): yield t
|
|
|
|
for name in extras:
|
|
|
|
let t = getTracker(name)
|
|
|
|
if not isNil(t): yield t
|
2020-07-07 11:14:11 +00:00
|
|
|
|
|
|
|
type RngWrap = object
|
|
|
|
rng: ref BrHmacDrbgContext
|
|
|
|
|
|
|
|
var rngVar: RngWrap
|
|
|
|
|
|
|
|
proc getRng(): ref BrHmacDrbgContext =
|
|
|
|
# TODO if `rngVar` is a threadvar like it should be, there are random and
|
|
|
|
# spurious compile failures on mac - this is not gcsafe but for the
|
|
|
|
# purpose of the tests, it's ok as long as we only use a single thread
|
|
|
|
{.gcsafe.}:
|
|
|
|
if rngVar.rng.isNil:
|
|
|
|
rngVar.rng = newRng()
|
|
|
|
rngVar.rng
|
|
|
|
|
|
|
|
template rng*(): ref BrHmacDrbgContext =
|
|
|
|
getRng()
|