Add getHost() to retrieve host that fulfills request
This commit is contained in:
parent
1227ce8658
commit
97ef1bcd9f
|
@ -38,6 +38,10 @@ contract Storage is Collateral, Marketplace {
|
|||
return _request(id);
|
||||
}
|
||||
|
||||
function getHost(bytes32 id) public view returns (address) {
|
||||
return _host(id);
|
||||
}
|
||||
|
||||
function finishContract(bytes32 id) public {
|
||||
require(_host(id) != address(0), "Contract not started");
|
||||
require(!contractFinished[id], "Contract already finished");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const { expect } = require("chai")
|
||||
const { ethers, deployments } = require("hardhat")
|
||||
const { hexlify, randomBytes } = ethers.utils
|
||||
const { AddressZero } = ethers.constants
|
||||
const { exampleRequest } = require("./examples")
|
||||
const { advanceTime, advanceTimeTo, currentTime } = require("./evm")
|
||||
const { requestId } = require("./ids")
|
||||
|
@ -55,6 +56,12 @@ describe("Storage", function () {
|
|||
expect(retrieved.nonce).to.equal(request.nonce)
|
||||
})
|
||||
|
||||
it("can retrieve host that fulfilled request", async function () {
|
||||
expect(await storage.getHost(requestId(request))).to.equal(AddressZero)
|
||||
await storage.fulfillRequest(requestId(request), proof)
|
||||
expect(await storage.getHost(requestId(request))).to.equal(host.address)
|
||||
})
|
||||
|
||||
describe("finishing the contract", function () {
|
||||
async function waitUntilEnd() {
|
||||
const end = (await storage.proofEnd(id)).toNumber()
|
||||
|
|
Loading…
Reference in New Issue