mirror of
https://github.com/logos-storage/logos-storage-network-crawler.git
synced 2026-01-08 16:33:06 +00:00
implements dhtEnable flag
This commit is contained in:
parent
1704d3dc30
commit
5bd35720b5
@ -52,7 +52,8 @@ method start*(c: Crawler): Future[?!void] {.async.} =
|
|||||||
proc onStep(): Future[?!void] {.async: (raises: []), gcsafe.} =
|
proc onStep(): Future[?!void] {.async: (raises: []), gcsafe.} =
|
||||||
await c.step()
|
await c.step()
|
||||||
|
|
||||||
await c.state.whileRunning(onStep, c.state.config.stepDelayMs.milliseconds)
|
if c.state.config.dhtEnable:
|
||||||
|
await c.state.whileRunning(onStep, c.state.config.stepDelayMs.milliseconds)
|
||||||
|
|
||||||
return success()
|
return success()
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,20 @@ suite "Crawler":
|
|||||||
check:
|
check:
|
||||||
!(dht.getNeighborsArg) == nid1
|
!(dht.getNeighborsArg) == nid1
|
||||||
|
|
||||||
|
test "onStep is not activated when config.dhtEnable is false":
|
||||||
|
# Recreate crawler, reset mockstate:
|
||||||
|
(await crawler.stop()).tryGet()
|
||||||
|
state.steppers = @[]
|
||||||
|
# disable DHT:
|
||||||
|
state.config.dhtEnable = false
|
||||||
|
(await crawler.start()).tryGet()
|
||||||
|
|
||||||
|
todo.popReturn = success(nid1)
|
||||||
|
dht.getNeighborsReturn = success(responsive(nid1))
|
||||||
|
|
||||||
|
check:
|
||||||
|
state.steppers.len == 0
|
||||||
|
|
||||||
test "nodes returned by getNeighbors are raised as nodesFound":
|
test "nodes returned by getNeighbors are raised as nodesFound":
|
||||||
var nodesFound = newSeq[Nid]()
|
var nodesFound = newSeq[Nid]()
|
||||||
proc onNodesFound(nids: seq[Nid]): Future[?!void] {.async.} =
|
proc onNodesFound(nids: seq[Nid]): Future[?!void] {.async.} =
|
||||||
|
|||||||
@ -22,7 +22,9 @@ method whileRunning*(s: MockState, step: OnStep, delay: Duration) {.async.} =
|
|||||||
proc createMockState*(): MockState =
|
proc createMockState*(): MockState =
|
||||||
MockState(
|
MockState(
|
||||||
status: ApplicationStatus.Running,
|
status: ApplicationStatus.Running,
|
||||||
config: Config(),
|
config: Config(
|
||||||
|
dhtEnable: true
|
||||||
|
),
|
||||||
events: Events(
|
events: Events(
|
||||||
nodesFound: newAsyncDataEvent[seq[Nid]](),
|
nodesFound: newAsyncDataEvent[seq[Nid]](),
|
||||||
newNodesDiscovered: newAsyncDataEvent[seq[Nid]](),
|
newNodesDiscovered: newAsyncDataEvent[seq[Nid]](),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user