Fixes node/testnode.nim

This commit is contained in:
Ben 2024-10-29 10:00:33 +01:00
parent c5607206de
commit 9f94536f13
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
4 changed files with 7 additions and 4 deletions

View File

@ -150,8 +150,7 @@ proc merkleTreeWorker*[H, K](
without y =? self.compress( xs[a + 2 * i], xs[a + 2 * i + 1], key = key ), err:
return failure err
ys[i] = y
# yield?
await sleepAsync(1.millis) # cooperative scheduling (may not be necessary)
await sleepAsync(1.micros) # cooperative scheduling
if isOdd:
const key = when isBottomLayer: K.KeyOddAndBottomLayer else: K.KeyOdd
without y =? self.compress( xs[n], self.zero, key = key ), err:

View File

@ -325,6 +325,7 @@ proc init*[T, H](self: SlotsBuilder[T, H]): Future[?!void] {.async.} =
self.verifiableTree = some tree
trace "Slots builder initialized"
success()
proc new*[T, H](
_: type SlotsBuilder[T, H],

View File

@ -55,7 +55,7 @@ proc digestTree*(
return failure err
leaves.add(digest)
index += chunkSize
await sleepAsync(1.millis) # cooperative scheduling (may not be necessary)
await sleepAsync(1.micros) # cooperative scheduling
return await Poseidon2Tree.init(leaves)
proc digest*(

View File

@ -148,12 +148,15 @@ asyncchecksuite "Test Node - Basic":
codec = ManifestCodec).tryGet()
protected = (await erasure.encode(manifest, 3, 2)).tryGet()
builder = Poseidon2Builder.new(localStore, protected).tryGet()
(await builder.init()).tryGet()
let
verifiable = (await builder.buildManifest()).tryGet()
verifiableBlock = bt.Block.new(
verifiable.encode().tryGet(),
codec = ManifestCodec).tryGet()
(await builder.init()).tryGet()
(await localStore.putBlock(manifestBlock)).tryGet()
let