mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-01-14 08:37:19 +00:00
Add proof period and timeout to contract
This commit is contained in:
parent
31807dfe58
commit
550fcf4afe
@ -8,10 +8,14 @@ contract StorageContract {
|
|||||||
uint public immutable size; // storage size in bytes
|
uint public immutable size; // storage size in bytes
|
||||||
uint public immutable price; // price in coins
|
uint public immutable price; // price in coins
|
||||||
address public immutable host; // host that provides storage
|
address public immutable host; // host that provides storage
|
||||||
|
uint public immutable proofPeriod; // average time between proofs (in blocks)
|
||||||
|
uint public immutable proofTimeout; // proof has to be submitted before this
|
||||||
|
|
||||||
constructor(uint _duration,
|
constructor(uint _duration,
|
||||||
uint _size,
|
uint _size,
|
||||||
uint _price,
|
uint _price,
|
||||||
|
uint _proofPeriod,
|
||||||
|
uint _proofTimeout,
|
||||||
address _host,
|
address _host,
|
||||||
bytes memory requestSignature,
|
bytes memory requestSignature,
|
||||||
bytes memory bidSignature)
|
bytes memory bidSignature)
|
||||||
@ -24,6 +28,8 @@ contract StorageContract {
|
|||||||
size = _size;
|
size = _size;
|
||||||
price = _price;
|
price = _price;
|
||||||
host = _host;
|
host = _host;
|
||||||
|
proofPeriod = _proofPeriod;
|
||||||
|
proofTimeout = _proofTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates hash for a storage request that can be used to check its signature
|
// creates hash for a storage request that can be used to check its signature
|
||||||
|
@ -4,8 +4,10 @@ const { hashRequest, hashBid, sign } = require("./marketplace")
|
|||||||
|
|
||||||
describe("Storage Contract", function () {
|
describe("Storage Contract", function () {
|
||||||
|
|
||||||
const duration = 31 * 24 * 60 * 60
|
const duration = 31 * 24 * 60 * 60 // 31 days
|
||||||
const size = 1 * 1024 * 1024 * 1024
|
const size = 1 * 1024 * 1024 * 1024 // 1 Gigabyte
|
||||||
|
const proofPeriod = 64 // 64 blocks ≈ 15 minutes
|
||||||
|
const proofTimeout = 42 // 42 blocks ≈ 10 minutes
|
||||||
const price = 42
|
const price = 42
|
||||||
|
|
||||||
var StorageContract
|
var StorageContract
|
||||||
@ -27,6 +29,8 @@ describe("Storage Contract", function () {
|
|||||||
duration,
|
duration,
|
||||||
size,
|
size,
|
||||||
price,
|
price,
|
||||||
|
proofPeriod,
|
||||||
|
proofTimeout,
|
||||||
await host.getAddress(),
|
await host.getAddress(),
|
||||||
await sign(client, requestHash),
|
await sign(client, requestHash),
|
||||||
await sign(host, bidHash)
|
await sign(host, bidHash)
|
||||||
@ -49,6 +53,13 @@ describe("Storage Contract", function () {
|
|||||||
expect(await contract.host()).to.equal(await host.getAddress())
|
expect(await contract.host()).to.equal(await host.getAddress())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("has an average time between proofs (in blocks)", async function (){
|
||||||
|
expect(await contract.proofPeriod()).to.equal(proofPeriod)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("has a proof timeout (in blocks)", async function (){
|
||||||
|
expect(await contract.proofTimeout()).to.equal(proofTimeout)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("cannot be created when client signature is invalid", async function () {
|
it("cannot be created when client signature is invalid", async function () {
|
||||||
@ -57,6 +68,8 @@ describe("Storage Contract", function () {
|
|||||||
duration,
|
duration,
|
||||||
size,
|
size,
|
||||||
price,
|
price,
|
||||||
|
proofPeriod,
|
||||||
|
proofTimeout,
|
||||||
await host.getAddress(),
|
await host.getAddress(),
|
||||||
invalidSignature,
|
invalidSignature,
|
||||||
await sign(host, bidHash)
|
await sign(host, bidHash)
|
||||||
@ -69,6 +82,8 @@ describe("Storage Contract", function () {
|
|||||||
duration,
|
duration,
|
||||||
size,
|
size,
|
||||||
price,
|
price,
|
||||||
|
proofPeriod,
|
||||||
|
proofTimeout,
|
||||||
await host.getAddress(),
|
await host.getAddress(),
|
||||||
await sign(client, requestHash),
|
await sign(client, requestHash),
|
||||||
invalidSignature
|
invalidSignature
|
||||||
|
Loading…
x
Reference in New Issue
Block a user