diff --git a/contracts/Storage.sol b/contracts/Storage.sol index c390af1..5f68108 100644 --- a/contracts/Storage.sol +++ b/contracts/Storage.sol @@ -29,6 +29,14 @@ contract Storage is Collateral, Marketplace, Proofs { 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 { Offer storage offer = _offer(id); require(msg.sender == offer.host, "Only host can call this function"); diff --git a/test/Storage.test.js b/test/Storage.test.js index 4b61b01..447480d 100644 --- a/test/Storage.test.js +++ b/test/Storage.test.js @@ -51,6 +51,23 @@ describe("Storage", function () { 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 () { it("starts requiring storage proofs", async function () { switchAccount(host)