codex-contracts-eth/test/examples.js

34 lines
854 B
JavaScript
Raw Normal View History

const { ethers } = require("hardhat")
2022-02-15 16:01:54 +00:00
const { now, hours } = require("./time")
const { sha256, hexlify, randomBytes } = ethers.utils
const exampleRequest = () => ({
2022-02-17 10:00:18 +00:00
client: hexlify(randomBytes(20)),
duration: hours(10),
size: 1 * 1024 * 1024 * 1024, // 1 Gigabyte
contentHash: sha256("0xdeadbeef"),
proofProbability: 4, // require a proof roughly once every 4 periods
2022-02-21 10:31:37 +00:00
maxPrice: 84,
2022-02-17 11:24:27 +00:00
expiry: now() + hours(1),
nonce: hexlify(randomBytes(32)),
})
const exampleBid = () => ({
price: 42,
2022-02-15 16:01:54 +00:00
bidExpiry: now() + hours(1),
})
const exampleOffer = () => ({
2022-02-21 10:31:37 +00:00
requestId: hexlify(randomBytes(32)),
2022-02-17 10:06:14 +00:00
host: hexlify(randomBytes(20)),
price: 42,
expiry: now() + hours(1),
})
2022-02-15 16:01:54 +00:00
const exampleLock = () => ({
id: hexlify(randomBytes(32)),
2022-02-15 16:01:54 +00:00
expiry: now() + hours(1),
})
module.exports = { exampleRequest, exampleOffer, exampleBid, exampleLock }