[contracts] Update to latest dagger-contracts

This commit is contained in:
Mark Spanbroek 2022-06-13 15:04:12 +02:00 committed by markspanbroek
parent e1998e0b61
commit e352a181e4
3 changed files with 6 additions and 24 deletions

View File

@ -14,12 +14,7 @@ type
StorageRequested* = object of Event
requestId*: Id
ask*: StorageAsk
StorageOffered* = object of Event
offerId*: Id
offer*: StorageOffer
requestId* {.indexed.}: Id
OfferSelected* = object of Event
offerId*: Id
RequestFulfilled* = object of Event
requestId* {.indexed.}: Id
ProofSubmitted* = object of Event
id*: Id
@ -34,10 +29,8 @@ proc withdraw*(storage: Storage) {.contract.}
proc balanceOf*(storage: Storage, account: Address): UInt256 {.contract, view.}
proc requestStorage*(storage: Storage, request: StorageRequest) {.contract.}
proc offerStorage*(storage: Storage, offer: StorageOffer) {.contract.}
proc selectOffer*(storage: Storage, id: Id) {.contract.}
proc fulfillRequest*(storage: Storage, id: Id, proof: seq[byte]) {.contract.}
proc startContract*(storage: Storage, id: Id) {.contract.}
proc finishContract*(storage: Storage, id: Id) {.contract.}
proc proofPeriod*(storage: Storage): UInt256 {.contract, view.}

View File

@ -9,6 +9,7 @@ import ./examples
import ./time
ethersuite "Storage contracts":
let proof = seq[byte].example
var client, host: Signer
var storage: Storage
@ -50,10 +51,8 @@ ethersuite "Storage contracts":
switchAccount(host)
await token.approve(storage.address, collateralAmount)
await storage.deposit(collateralAmount)
await storage.offerStorage(offer)
switchAccount(client)
await storage.selectOffer(offer.id)
id = offer.id
await storage.fulfillRequest(request.id, proof)
id = request.id
proc waitUntilProofRequired(id: array[32, byte]) {.async.} =
let currentPeriod = periodicity.periodOf(await provider.currentTime())
@ -64,22 +63,13 @@ ethersuite "Storage contracts":
):
await provider.advanceTime(periodicity.seconds)
test "can be started by the host":
switchAccount(host)
await storage.startContract(id)
let proofEnd = await storage.proofEnd(id)
check proofEnd > 0
test "accept storage proofs":
let proof = seq[byte].example
switchAccount(host)
await storage.startContract(id)
await waitUntilProofRequired(id)
await storage.submitProof(id, proof)
test "can mark missing proofs":
switchAccount(host)
await storage.startContract(id)
await waitUntilProofRequired(id)
let missingPeriod = periodicity.periodOf(await provider.currentTime())
await provider.advanceTime(periodicity.seconds)
@ -88,6 +78,5 @@ ethersuite "Storage contracts":
test "can be finished":
switchAccount(host)
await storage.startContract(id)
await provider.advanceTimeTo(await storage.proofEnd(id))
await storage.finishContract(id)

@ -1 +1 @@
Subproject commit 2bf01da728317fd1f3ae8424785f31b53eb4013f
Subproject commit 97ef1bcd9f09ac3f267a58e7b7ed5df057b88890