update asynctest package, async signatures, add back toSeq from botched merge
This commit is contained in:
parent
809132353c
commit
b26386f631
|
@ -91,13 +91,13 @@ func indexToPos(steps, idx, step: int): int {.inline.} =
|
|||
proc getPendingBlocks(
|
||||
self: Erasure,
|
||||
manifest: Manifest,
|
||||
indicies: seq[int]): AsyncIter[(?!bt.Block, int)] =
|
||||
indices: seq[int]): AsyncIter[(?!bt.Block, int)] =
|
||||
## Get pending blocks iterator
|
||||
##
|
||||
|
||||
var
|
||||
# request blocks from the store
|
||||
pendingBlocks = indicies.map( (i: int) =>
|
||||
pendingBlocks = indices.map( (i: int) =>
|
||||
self.store.getBlock(
|
||||
BlockAddress.init(manifest.treeCid, i)
|
||||
).map((r: ?!bt.Block) => (r, i)) # Get the data blocks (first K)
|
||||
|
@ -135,8 +135,8 @@ proc prepareEncodingData(
|
|||
lastIndex = params.rounded - 1,
|
||||
numberOfIterations = params.steps
|
||||
)
|
||||
indicies = strategy.getIndices(step)
|
||||
pendingBlocksIter = self.getPendingBlocks(manifest, indicies.filterIt(it < manifest.blocksCount))
|
||||
indices = toSeq(strategy.getIndices(step))
|
||||
pendingBlocksIter = self.getPendingBlocks(manifest, indices.filterIt(it < manifest.blocksCount))
|
||||
|
||||
var resolved = 0
|
||||
for fut in pendingBlocksIter:
|
||||
|
@ -151,7 +151,7 @@ proc prepareEncodingData(
|
|||
|
||||
resolved.inc()
|
||||
|
||||
for idx in indicies.filterIt(it >= manifest.blocksCount):
|
||||
for idx in indices.filterIt(it >= manifest.blocksCount):
|
||||
let pos = indexToPos(params.steps, idx, step)
|
||||
trace "Padding with empty block", idx
|
||||
shallowCopy(data[pos], emptyBlock)
|
||||
|
@ -184,8 +184,8 @@ proc prepareDecodingData(
|
|||
lastIndex = encoded.blocksCount - 1,
|
||||
numberOfIterations = encoded.steps
|
||||
)
|
||||
indicies = strategy.getIndices(step)
|
||||
pendingBlocksIter = self.getPendingBlocks(encoded, indicies)
|
||||
indices = toSeq(strategy.getIndices(step))
|
||||
pendingBlocksIter = self.getPendingBlocks(encoded, indices)
|
||||
|
||||
var
|
||||
dataPieces = 0
|
||||
|
|
|
@ -63,7 +63,7 @@ proc getIter(first, last, step: int): Iter[int] =
|
|||
|
||||
Iter.new(get, isFinished)
|
||||
|
||||
method getIndicies*(
|
||||
method getIndices*(
|
||||
self: LinearIndexingStrategy,
|
||||
iteration: int): Iter[int] {.raises: [IndexingError].} =
|
||||
|
||||
|
@ -75,7 +75,7 @@ method getIndicies*(
|
|||
|
||||
getIter(first, last, 1)
|
||||
|
||||
method getIndicies*(
|
||||
method getIndices*(
|
||||
self: SteppedIndexingStrategy,
|
||||
iteration: int): Iter[int] {.raises: [IndexingError].} =
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import std/times
|
|||
|
||||
import pkg/libp2p
|
||||
import pkg/chronos
|
||||
import pkg/asynctest
|
||||
import pkg/asynctest/chronos/unittest
|
||||
|
||||
import pkg/codex/codextypes
|
||||
import pkg/codex/chunker
|
||||
|
@ -13,7 +13,7 @@ proc toTimesDuration*(d: chronos.Duration): times.Duration =
|
|||
|
||||
proc drain*(
|
||||
stream: LPStream | Result[lpstream.LPStream, ref CatchableError]):
|
||||
Future[seq[byte]] {.async.} =
|
||||
Future[seq[byte]] {.async: (handleException: true, raises: [AsyncExceptionError]).} =
|
||||
|
||||
let
|
||||
stream =
|
||||
|
@ -36,7 +36,10 @@ proc drain*(
|
|||
|
||||
data
|
||||
|
||||
proc pipeChunker*(stream: BufferStream, chunker: Chunker) {.async.} =
|
||||
proc pipeChunker*(
|
||||
stream: BufferStream,
|
||||
chunker: Chunker
|
||||
) {.async: (handleException: true, raises: [AsyncExceptionError]).} =
|
||||
try:
|
||||
while (
|
||||
let chunk = await chunker.getBytes();
|
||||
|
|
|
@ -5,7 +5,7 @@ import std/times
|
|||
import std/sequtils
|
||||
import std/importutils
|
||||
|
||||
import pkg/asynctest
|
||||
import pkg/asynctest/chronos/unittest
|
||||
import pkg/chronos
|
||||
import pkg/stew/byteutils
|
||||
import pkg/datastore
|
||||
|
@ -129,7 +129,7 @@ asyncchecksuite "Test Node - Host contracts":
|
|||
(await onStore(request, 1.u256, onBlocks)).tryGet()
|
||||
check fetchedBytes == 786432
|
||||
|
||||
for index in builder.slotIndicies(1):
|
||||
for index in !builder.slotIndices(1):
|
||||
let
|
||||
blk = (await localStore.getBlock(verifiable.treeCid, index)).tryGet
|
||||
expiryKey = (createBlockExpirationMetadataKey(blk.cid)).tryGet
|
||||
|
|
|
@ -5,7 +5,7 @@ import std/times
|
|||
import std/sequtils
|
||||
import std/importutils
|
||||
|
||||
import pkg/asynctest
|
||||
import pkg/asynctest/chronos/unittest
|
||||
import pkg/chronos
|
||||
import pkg/stew/byteutils
|
||||
import pkg/datastore
|
||||
|
@ -69,7 +69,7 @@ asyncchecksuite "Test Node - Basic":
|
|||
(await node.fetchBatched(
|
||||
manifest,
|
||||
batchSize = batchSize,
|
||||
proc(blocks: seq[bt.Block]): Future[?!void] {.gcsafe, async.} =
|
||||
proc(blocks: seq[bt.Block]): Future[?!void] {.gcsafe, async: (handleException: true).} =
|
||||
check blocks.len > 0 and blocks.len <= batchSize
|
||||
return success()
|
||||
)).tryGet()
|
||||
|
|
|
@ -19,15 +19,15 @@ for offset in @[0, 1, 2, 100]:
|
|||
|
||||
test "linear":
|
||||
check:
|
||||
linear.getIndices(0) == @[0, 1, 2, 3, 4].mapIt(it + offset)
|
||||
linear.getIndices(1) == @[5, 6, 7, 8, 9].mapIt(it + offset)
|
||||
linear.getIndices(2) == @[10, 11, 12].mapIt(it + offset)
|
||||
toSeq(linear.getIndices(0)) == @[0, 1, 2, 3, 4].mapIt(it + offset)
|
||||
toSeq(linear.getIndices(1)) == @[5, 6, 7, 8, 9].mapIt(it + offset)
|
||||
toSeq(linear.getIndices(2)) == @[10, 11, 12].mapIt(it + offset)
|
||||
|
||||
test "stepped":
|
||||
check:
|
||||
stepped.getIndices(0) == @[0, 3, 6, 9, 12].mapIt(it + offset)
|
||||
stepped.getIndices(1) == @[1, 4, 7, 10].mapIt(it + offset)
|
||||
stepped.getIndices(2) == @[2, 5, 8, 11].mapIt(it + offset)
|
||||
toSeq(stepped.getIndices(0)) == @[0, 3, 6, 9, 12].mapIt(it + offset)
|
||||
toSeq(stepped.getIndices(1)) == @[1, 4, 7, 10].mapIt(it + offset)
|
||||
toSeq(stepped.getIndices(2)) == @[2, 5, 8, 11].mapIt(it + offset)
|
||||
|
||||
suite "Indexing strategies":
|
||||
let
|
||||
|
@ -39,16 +39,16 @@ suite "Indexing strategies":
|
|||
l = LinearIndexingStrategy.new(0, 0, 1)
|
||||
s = SteppedIndexingStrategy.new(0, 0, 1)
|
||||
check:
|
||||
l.getIndices(0) == @[0]
|
||||
s.getIndices(0) == @[0]
|
||||
toSeq(l.getIndices(0)) == @[0]
|
||||
toSeq(s.getIndices(0)) == @[0]
|
||||
|
||||
test "smallest range 1":
|
||||
let
|
||||
l = LinearIndexingStrategy.new(0, 1, 1)
|
||||
s = SteppedIndexingStrategy.new(0, 1, 1)
|
||||
check:
|
||||
l.getIndices(0) == @[0, 1]
|
||||
s.getIndices(0) == @[0, 1]
|
||||
toSeq(l.getIndices(0)) == @[0, 1]
|
||||
toSeq(s.getIndices(0)) == @[0, 1]
|
||||
|
||||
test "first index must be smaller than last index":
|
||||
expect IndexingWrongIndexError:
|
||||
|
|
Loading…
Reference in New Issue