mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-02 13:33:10 +00:00
* [build] disable XCannotRaiseY hint
There are too many {.raises:[Defect].} in the
libraries that we use, drowning out all other
warnings and hints
* [build] disable BareExcept warning
Not yet enabled in a released version of Nim,
so libraries that we depend on have not fixed
this yet, drowning out our own hints and warnings
* [build] disable DotLikeOps warning
dot-like ops were an experiment that is not going
land in Nim
* [build] compile log statements in tests
When running tests, all log statements are compiled.
They are filtered out at runtime during a test run.
* [build] do not build executable when running unit test
It's already built in the integration test
* [build] Fix warnings
- remove unused code
- remove unused imports
- stop using deprecated stuff
* [build] Put compiler flags behind nim version checks
* [CI] remove Nim 1.2 compatibility
58 lines
1.7 KiB
Nim
58 lines
1.7 KiB
Nim
import codex/contracts
|
|
import ../ethertest
|
|
import ./examples
|
|
|
|
ethersuite "On-Chain Proofs":
|
|
|
|
let contractId = SlotId.example
|
|
let proof = exampleProof()
|
|
|
|
var proofs: OnChainProofs
|
|
var marketplace: Marketplace
|
|
|
|
setup:
|
|
let deployment = deployment()
|
|
marketplace = Marketplace.new(!deployment.address(Marketplace), provider.getSigner())
|
|
proofs = OnChainProofs.new(marketplace)
|
|
|
|
test "can retrieve proof periodicity":
|
|
let periodicity = await proofs.periodicity()
|
|
let config = await marketplace.config()
|
|
let periodLength = config.proofs.period
|
|
check periodicity.seconds == periodLength
|
|
|
|
test "supports checking whether proof is required now":
|
|
check (await proofs.isProofRequired(contractId)) == false
|
|
|
|
test "supports checking whether proof is required soon":
|
|
check (await proofs.willProofBeRequired(contractId)) == false
|
|
|
|
test "retrieves correct slot state when request is unknown":
|
|
check (await proofs.slotState(SlotId.example)) == SlotState.Free
|
|
|
|
test "submits proofs":
|
|
await proofs.submitProof(contractId, proof)
|
|
|
|
test "supports proof submission subscriptions":
|
|
var receivedIds: seq[SlotId]
|
|
var receivedProofs: seq[seq[byte]]
|
|
|
|
proc onProofSubmission(id: SlotId, proof: seq[byte]) =
|
|
receivedIds.add(id)
|
|
receivedProofs.add(proof)
|
|
|
|
let subscription = await proofs.subscribeProofSubmission(onProofSubmission)
|
|
|
|
await proofs.submitProof(contractId, proof)
|
|
|
|
check receivedIds == @[contractId]
|
|
check receivedProofs == @[proof]
|
|
|
|
await subscription.unsubscribe()
|
|
|
|
test "proof not required when slot is empty":
|
|
check not await proofs.isProofRequired(contractId)
|
|
|
|
test "proof will not be required when slot is empty":
|
|
check not await proofs.willProofBeRequired(contractId)
|