[marketplace] fix tests
Fix tests based from two changes: - Addition of the Reservations module - ContractInteractions split into ClientInteractions and HostInteractions
This commit is contained in:
parent
cff2ca93d8
commit
8444b1b967
|
@ -47,8 +47,8 @@ proc new*(_: type ClientInteractions,
|
|||
ClientInteractions.new("ws://localhost:8545", account)
|
||||
|
||||
proc start*(self: ClientInteractions) {.async.} =
|
||||
await self.purchasing.start()
|
||||
await procCall ContractInteractions(self).start()
|
||||
await self.purchasing.start()
|
||||
|
||||
proc stop*(self: ClientInteractions) {.async.} =
|
||||
await self.purchasing.stop()
|
||||
|
|
|
@ -57,9 +57,9 @@ proc new*(_: type HostInteractions,
|
|||
HostInteractions.new("ws://localhost:8545", account, repo)
|
||||
|
||||
method start*(self: HostInteractions) {.async.} =
|
||||
await procCall ContractInteractions(self).start()
|
||||
await self.sales.start()
|
||||
await self.proving.start()
|
||||
await procCall ContractInteractions(self).start()
|
||||
|
||||
method stop*(self: HostInteractions) {.async.} =
|
||||
await self.sales.stop()
|
||||
|
|
|
@ -38,8 +38,8 @@ proc prepare*(
|
|||
|
||||
return success((signer, deploy))
|
||||
|
||||
method start*(interactions: ContractInteractions) {.async, base.} =
|
||||
await interactions.clock.start()
|
||||
method start*(self: ContractInteractions) {.async, base.} =
|
||||
await self.clock.start()
|
||||
|
||||
method stop*(interactions: ContractInteractions) {.async, base.} =
|
||||
await interactions.clock.stop()
|
||||
method stop*(self: ContractInteractions) {.async, base.} =
|
||||
await self.clock.stop()
|
||||
|
|
|
@ -372,9 +372,16 @@ proc start*(node: CodexNodeRef) {.async.} =
|
|||
try:
|
||||
await contracts.start()
|
||||
except CatchableError as error:
|
||||
error "Unable to start contract interactions: ", error=error.msg
|
||||
error "Unable to start host contract interactions: ", error=error.msg
|
||||
node.contracts.host = HostInteractions.none
|
||||
|
||||
if contracts =? node.contracts.client:
|
||||
try:
|
||||
await contracts.start()
|
||||
except CatchableError as error:
|
||||
error "Unable to start client contract interactions: ", error=error.msg
|
||||
node.contracts.client = ClientInteractions.none
|
||||
|
||||
node.networkId = node.switch.peerInfo.peerId
|
||||
notice "Started codex node", id = $node.networkId, addrs = node.switch.peerInfo.addrs
|
||||
|
||||
|
|
|
@ -247,7 +247,10 @@ proc initRestApi*(node: CodexNodeRef, conf: CodexConf): RestRouter =
|
|||
without contracts =? node.contracts.host:
|
||||
return RestApiResponse.error(Http503, "Sales unavailable")
|
||||
|
||||
let json = %contracts.sales.available
|
||||
without unused =? (await contracts.sales.reservations.unused), err:
|
||||
return RestApiResponse.error(Http500, err.msg)
|
||||
|
||||
let json = %unused
|
||||
return RestApiResponse.response($json)
|
||||
|
||||
router.rawApi(
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
## those terms.
|
||||
|
||||
import std/typetraits
|
||||
|
||||
import pkg/chronos
|
||||
import pkg/chronicles
|
||||
import pkg/upraises
|
||||
|
@ -274,6 +275,18 @@ proc availabilities*(
|
|||
iter.next = next
|
||||
return success iter
|
||||
|
||||
proc unused*(r: Reservations): Future[?!seq[Availability]] {.async.} =
|
||||
var ret: seq[Availability] = @[]
|
||||
|
||||
without availabilities =? (await r.availabilities), err:
|
||||
return failure(err)
|
||||
|
||||
for a in availabilities:
|
||||
if availability =? (await a) and not availability.used:
|
||||
ret.add availability
|
||||
|
||||
return success(ret)
|
||||
|
||||
proc find*(
|
||||
self: Reservations,
|
||||
size, duration, minPrice: UInt256,
|
||||
|
|
Loading…
Reference in New Issue