[market] Require a storage contract with a signer

This commit is contained in:
Mark Spanbroek 2022-03-28 17:28:51 +02:00 committed by markspanbroek
parent e78a0fb43e
commit e52153e2ba
2 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import pkg/ethers
import pkg/upraises
import pkg/questionable
import ../market
import ./storage
@ -15,7 +16,9 @@ type
export market
func new*(_: type OnChainMarket, contract: Storage): OnChainMarket =
OnChainMarket(contract: contract, signer: !contract.signer)
without signer =? contract.signer:
raiseAssert("Storage contract should have a signer")
OnChainMarket(contract: contract, signer: signer)
method subscribeRequests(market: OnChainMarket,
callback: OnRequest):

View File

@ -16,6 +16,11 @@ ethersuite "On-Chain Market":
await token.mint(accounts[0], 1000.u256)
market = OnChainMarket.new(storage)
test "fails to instantiate when contract does not have a signer":
let storageWithoutSigner = storage.connect(provider)
expect AssertionError:
discard OnChainMarket.new(storageWithoutSigner)
test "supports storage requests":
var submitted: seq[StorageRequest]
proc onRequest(request: StorageRequest) =