mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-02-26 21:30:35 +00:00
[Storage] Move missingProofs() to Proofs
This commit is contained in:
parent
154cc00277
commit
c9cf47f327
@ -53,8 +53,8 @@ contract Proofs {
|
|||||||
return _end(_requestId(id));
|
return _end(_requestId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
function _missed(SlotId id) internal view returns (uint256) {
|
function missingProofs(SlotId slotId) public view returns (uint256) {
|
||||||
return missed[id];
|
return missed[slotId];
|
||||||
}
|
}
|
||||||
|
|
||||||
function periodOf(uint256 timestamp) private view returns (uint256) {
|
function periodOf(uint256 timestamp) private view returns (uint256) {
|
||||||
|
@ -35,10 +35,6 @@ contract Storage is Marketplace {
|
|||||||
minCollateralThreshold = _minCollateralThreshold;
|
minCollateralThreshold = _minCollateralThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
function missingProofs(SlotId slotId) public view returns (uint256) {
|
|
||||||
return _missed(slotId);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isProofRequired(SlotId slotId) public view returns (bool) {
|
function isProofRequired(SlotId slotId) public view returns (bool) {
|
||||||
if (!_slotAcceptsProofs(slotId)) {
|
if (!_slotAcceptsProofs(slotId)) {
|
||||||
return false;
|
return false;
|
||||||
@ -74,7 +70,7 @@ contract Storage is Marketplace {
|
|||||||
{
|
{
|
||||||
_markProofAsMissing(slotId, period);
|
_markProofAsMissing(slotId, period);
|
||||||
address host = _host(slotId);
|
address host = _host(slotId);
|
||||||
if (_missed(slotId) % slashMisses == 0) {
|
if (missingProofs(slotId) % slashMisses == 0) {
|
||||||
_slash(host, slashPercentage);
|
_slash(host, slashPercentage);
|
||||||
|
|
||||||
if (balanceOf(host) < minCollateralThreshold) {
|
if (balanceOf(host) < minCollateralThreshold) {
|
||||||
|
@ -28,10 +28,6 @@ contract TestProofs is Proofs {
|
|||||||
return _end(id);
|
return _end(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function missed(SlotId id) public view returns (uint256) {
|
|
||||||
return _missed(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function expectProofs(
|
function expectProofs(
|
||||||
SlotId slot,
|
SlotId slot,
|
||||||
RequestId request,
|
RequestId request,
|
||||||
|
@ -211,12 +211,12 @@ describe("Proofs", function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("marks a proof as missing", async function () {
|
it("marks a proof as missing", async function () {
|
||||||
expect(await proofs.missed(slotId)).to.equal(0)
|
expect(await proofs.missingProofs(slotId)).to.equal(0)
|
||||||
await waitUntilProofIsRequired(slotId)
|
await waitUntilProofIsRequired(slotId)
|
||||||
let missedPeriod = periodOf(await currentTime())
|
let missedPeriod = periodOf(await currentTime())
|
||||||
await advanceTimeTo(periodEnd(missedPeriod))
|
await advanceTimeTo(periodEnd(missedPeriod))
|
||||||
await proofs.markProofAsMissing(slotId, missedPeriod)
|
await proofs.markProofAsMissing(slotId, missedPeriod)
|
||||||
expect(await proofs.missed(slotId)).to.equal(1)
|
expect(await proofs.missingProofs(slotId)).to.equal(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("does not mark a proof as missing before period end", async function () {
|
it("does not mark a proof as missing before period end", async function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user