Chronos v4 Update (v3 Compat Mode) (#814)
* add changes to use chronos v4 in compat mode * switch chronos to compat fix branch * use nimbus-build-system with configurable Nim repo * add missing imports * add missing await * bump compat * pin nim version in Makefile * add await instead of asyncSpawn to advertisement queue loop * bump DHT to v0.5.0 * allow error state of `onBatch` to propagate upwards in test code * pin Nim compiler commit to avoid fetching stale branch * make CI build against branch head instead of merge * fix handling of return values in testslotqueue
This commit is contained in:
parent
fbce240e3d
commit
4f56f2af26
|
@ -105,8 +105,7 @@ proc advertiseQueueLoop(b: DiscoveryEngine) {.async.} =
|
|||
trace "Begin iterating blocks..."
|
||||
for c in cids:
|
||||
if cid =? await c:
|
||||
b.advertiseBlock(cid)
|
||||
await sleepAsync(100.millis)
|
||||
await b.advertiseBlock(cid)
|
||||
trace "Iterating blocks finished."
|
||||
|
||||
await sleepAsync(b.advertiseLoopSleep)
|
||||
|
|
|
@ -31,7 +31,7 @@ import ./codextypes
|
|||
export errors, logutils, units, codextypes
|
||||
|
||||
type
|
||||
Block* = object of RootObj
|
||||
Block* = ref object of RootObj
|
||||
cid*: Cid
|
||||
data*: seq[byte]
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import ../logutils
|
|||
# TODO: Manifest should be reworked to more concrete types,
|
||||
# perhaps using inheritance
|
||||
type
|
||||
Manifest* = object of RootObj
|
||||
Manifest* = ref object of RootObj
|
||||
treeCid {.serialize.}: Cid # Root of the merkle tree
|
||||
datasetSize {.serialize.}: NBytes # Total size of all blocks
|
||||
blockSize {.serialize.}: NBytes # Size of each contained block (might not be needed if blocks are len-prefixed)
|
||||
|
|
|
@ -121,6 +121,9 @@ switch("define", "ctt_asm=false")
|
|||
# Allow the use of old-style case objects for nim config compatibility
|
||||
switch("define", "nimOldCaseObjects")
|
||||
|
||||
# Enable compat mode for Chronos V4
|
||||
switch("define", "chronosHandleException")
|
||||
|
||||
# begin Nimble config (version 1)
|
||||
when system.fileExists("nimble.paths"):
|
||||
include "nimble.paths"
|
||||
|
|
|
@ -323,8 +323,7 @@ asyncchecksuite "Sales":
|
|||
slot: UInt256,
|
||||
onBatch: BatchProc): Future[?!void] {.async.} =
|
||||
let blk = bt.Block.new( @[1.byte] ).get
|
||||
onBatch( blk.repeat(request.ask.slotSize.truncate(int)) )
|
||||
return success()
|
||||
await onBatch( blk.repeat(request.ask.slotSize.truncate(int)) )
|
||||
|
||||
createAvailability()
|
||||
await market.requestStorage(request)
|
||||
|
@ -337,8 +336,8 @@ asyncchecksuite "Sales":
|
|||
onBatch: BatchProc): Future[?!void] {.async.} =
|
||||
slotIndex = slot
|
||||
let blk = bt.Block.new( @[1.byte] ).get
|
||||
onBatch(@[ blk ])
|
||||
return success()
|
||||
await onBatch(@[ blk ])
|
||||
|
||||
let sold = newFuture[void]()
|
||||
sales.onSale = proc(request: StorageRequest, slotIndex: UInt256) =
|
||||
sold.complete()
|
||||
|
|
|
@ -524,7 +524,7 @@ suite "Slot queue":
|
|||
request.ask,
|
||||
request.expiry,
|
||||
seen = true)
|
||||
queue.push(item)
|
||||
check queue.push(item).isOk
|
||||
check eventually queue.paused
|
||||
check onProcessSlotCalledWith.len == 0
|
||||
|
||||
|
@ -534,7 +534,7 @@ suite "Slot queue":
|
|||
|
||||
let request = StorageRequest.example
|
||||
var items = SlotQueueItem.init(request)
|
||||
queue.push(items)
|
||||
check queue.push(items).isOk
|
||||
# check all items processed
|
||||
check eventually queue.len == 0
|
||||
|
||||
|
@ -546,7 +546,7 @@ suite "Slot queue":
|
|||
request.expiry,
|
||||
seen = true)
|
||||
check queue.paused
|
||||
queue.push(item0)
|
||||
check queue.push(item0).isOk
|
||||
check queue.paused
|
||||
|
||||
test "paused queue waits for unpause before continuing processing":
|
||||
|
@ -558,7 +558,7 @@ suite "Slot queue":
|
|||
seen = false)
|
||||
check queue.paused
|
||||
# push causes unpause
|
||||
queue.push(item)
|
||||
check queue.push(item).isOk
|
||||
# check all items processed
|
||||
check eventually onProcessSlotCalledWith == @[
|
||||
(item.requestId, item.slotIndex),
|
||||
|
@ -576,8 +576,8 @@ suite "Slot queue":
|
|||
request.ask,
|
||||
request.expiry,
|
||||
seen = true)
|
||||
queue.push(item0)
|
||||
queue.push(item1)
|
||||
check queue.push(item0).isOk
|
||||
check queue.push(item1).isOk
|
||||
check queue[0].seen
|
||||
check queue[1].seen
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ ethersuite "On-Chain Market":
|
|||
receivedIds.add(requestId)
|
||||
|
||||
let subscription = await market.subscribeRequestCancelled(request.id, onRequestCancelled)
|
||||
advanceToCancelledRequest(otherRequest) # shares expiry with otherRequest
|
||||
await advanceToCancelledRequest(otherRequest) # shares expiry with otherRequest
|
||||
await market.withdrawFunds(otherRequest.id)
|
||||
check receivedIds.len == 0
|
||||
await market.withdrawFunds(request.id)
|
||||
|
|
|
@ -25,5 +25,5 @@ template ethersuite*(name, body) =
|
|||
|
||||
body
|
||||
|
||||
export unittest
|
||||
export asynctest
|
||||
export ethers except `%`
|
||||
|
|
|
@ -2,8 +2,9 @@ import pkg/chronos
|
|||
|
||||
# Allow multiple setups and teardowns in a test suite
|
||||
template asyncmultisetup* =
|
||||
var setups: seq[proc: Future[void] {.gcsafe.}]
|
||||
var teardowns: seq[proc: Future[void] {.gcsafe.}]
|
||||
var setups: seq[proc: Future[void].Raising([AsyncExceptionError]) {.gcsafe.}]
|
||||
var teardowns: seq[
|
||||
proc: Future[void].Raising([AsyncExceptionError]) {.gcsafe.}]
|
||||
|
||||
setup:
|
||||
for setup in setups:
|
||||
|
@ -14,10 +15,12 @@ template asyncmultisetup* =
|
|||
await teardown()
|
||||
|
||||
template setup(setupBody) {.inject, used.} =
|
||||
setups.add(proc {.async.} = setupBody)
|
||||
setups.add(proc {.async: (
|
||||
handleException: true, raises: [AsyncExceptionError]).} = setupBody)
|
||||
|
||||
template teardown(teardownBody) {.inject, used.} =
|
||||
teardowns.insert(proc {.async.} = teardownBody)
|
||||
teardowns.insert(proc {.async: (
|
||||
handleException: true, raises: [AsyncExceptionError]).} = teardownBody)
|
||||
|
||||
template multisetup* =
|
||||
var setups: seq[proc() {.gcsafe.}]
|
||||
|
@ -32,7 +35,8 @@ template multisetup* =
|
|||
teardown()
|
||||
|
||||
template setup(setupBody) {.inject, used.} =
|
||||
setups.add(proc = setupBody)
|
||||
let setupProc = proc = setupBody
|
||||
setups.add(setupProc)
|
||||
|
||||
template teardown(teardownBody) {.inject, used.} =
|
||||
teardowns.insert(proc = teardownBody)
|
||||
|
|
|
@ -2,6 +2,7 @@ import pkg/questionable
|
|||
import pkg/questionable/results
|
||||
import pkg/confutils
|
||||
import pkg/chronicles
|
||||
import pkg/chronos/asyncproc
|
||||
import pkg/ethers
|
||||
import pkg/libp2p
|
||||
import std/os
|
||||
|
|
|
@ -3,6 +3,7 @@ import pkg/questionable/results
|
|||
import pkg/confutils
|
||||
import pkg/chronicles
|
||||
import pkg/chronos
|
||||
import pkg/chronos/asyncproc
|
||||
import pkg/stew/io2
|
||||
import std/os
|
||||
import std/sets
|
||||
|
|
|
@ -2,6 +2,7 @@ import pkg/questionable
|
|||
import pkg/questionable/results
|
||||
import pkg/confutils
|
||||
import pkg/chronicles
|
||||
import pkg/chronos/asyncproc
|
||||
import pkg/libp2p
|
||||
import std/os
|
||||
import std/strutils
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0277b65be2c7a365ac13df002fba6e172be55537
|
||||
Subproject commit 035ae11ba92369e7722e649db597e79134fd06b9
|
|
@ -1 +1 @@
|
|||
Subproject commit a7f14bc9b783f1b9e2d02cc85a338b1411058095
|
||||
Subproject commit 63822e83561ea1c6396d0f3eca583b038f5d44c6
|
|
@ -1 +1 @@
|
|||
Subproject commit 3b491a40c60aad9e8d3407443f46f62511e63b18
|
||||
Subproject commit be57dbc902d36f37540897e98c69aa80f868cb45
|
|
@ -1 +1 @@
|
|||
Subproject commit fe9bc3f3759ae1add6bf8c899db2e75327f03782
|
||||
Subproject commit b2e1fb022f1ee800b439648953e92cc993c1264c
|
Loading…
Reference in New Issue