[storage] add getRequest() and getOffer()
This commit is contained in:
parent
169a446769
commit
b145e66a68
|
@ -29,6 +29,14 @@ contract Storage is Collateral, Marketplace, Proofs {
|
||||||
slashPercentage = _slashPercentage;
|
slashPercentage = _slashPercentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRequest(bytes32 id) public view returns (Request memory) {
|
||||||
|
return _request(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOffer(bytes32 id) public view returns (Offer memory) {
|
||||||
|
return _offer(id);
|
||||||
|
}
|
||||||
|
|
||||||
function startContract(bytes32 id) public {
|
function startContract(bytes32 id) public {
|
||||||
Offer storage offer = _offer(id);
|
Offer storage offer = _offer(id);
|
||||||
require(msg.sender == offer.host, "Only host can call this function");
|
require(msg.sender == offer.host, "Only host can call this function");
|
||||||
|
|
|
@ -51,6 +51,23 @@ describe("Storage", function () {
|
||||||
id = offerId(offer)
|
id = offerId(offer)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("can retrieve storage requests", async function () {
|
||||||
|
const id = requestId(request)
|
||||||
|
const retrieved = await storage.getRequest(id)
|
||||||
|
expect(retrieved.client).to.equal(request.client)
|
||||||
|
expect(retrieved.expiry).to.equal(request.expiry)
|
||||||
|
expect(retrieved.nonce).to.equal(request.nonce)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("can retrieve storage offers", async function () {
|
||||||
|
const id = offerId(offer)
|
||||||
|
const retrieved = await storage.getOffer(id)
|
||||||
|
expect(retrieved.requestId).to.equal(offer.requestId)
|
||||||
|
expect(retrieved.host).to.equal(offer.host)
|
||||||
|
expect(retrieved.price).to.equal(offer.price)
|
||||||
|
expect(retrieved.expiry).to.equal(offer.expiry)
|
||||||
|
})
|
||||||
|
|
||||||
describe("starting the contract", function () {
|
describe("starting the contract", function () {
|
||||||
it("starts requiring storage proofs", async function () {
|
it("starts requiring storage proofs", async function () {
|
||||||
switchAccount(host)
|
switchAccount(host)
|
||||||
|
|
Loading…
Reference in New Issue