fix startSamplingDA counter and introduce samplethreshold

- Test is only passed if future is finished and OK.
- Test is passed if at least samplethreshold found.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-09-05 09:43:19 +02:00
parent 197cd75b24
commit 6df79c44e6
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
1 changed files with 7 additions and 4 deletions

11
das.nim
View File

@ -101,6 +101,7 @@ when isMainModule:
segmentsize = 2
samplesize = 3
sampling_timeout = 5.seconds
samplethreshold = samplesize
delay_init = 60.minutes
upload_timeout = 4.seconds
sampling_delay = 4.seconds
@ -165,13 +166,15 @@ when isMainModule:
var futs = startSamplingDA(n)
# test is passed if all segments are retrieved in time
let pass = await allFutures(futs).withTimeout(sampling_timeout)
discard await allFutures(futs).withTimeout(sampling_timeout)
var passcount: int
for f in futs:
if f.finished():
for i in 0 ..< futs.len:
if futs[i].finished() and isOk(await futs[i]):
passcount += 1
let time = Moment.now() - startTime
let
time = Moment.now() - startTime
pass = (passcount >= samplethreshold)
info "sample", by = n.localNode, pass, cnt = passcount, time
return (pass, passcount, time)