From 7b6c6c2fc589ae67bcb7c694240bccd8d308016f Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Mon, 1 Nov 2021 16:34:01 +0100 Subject: [PATCH] Rename: StorageContracts -> Storage --- .../{StorageContracts.sol => Storage.sol} | 2 +- test/Contracts.test.js | 2 +- ...orageContracts.test.js => Storage.test.js} | 59 +++++++++---------- 3 files changed, 29 insertions(+), 34 deletions(-) rename contracts/{StorageContracts.sol => Storage.sol} (98%) rename test/{StorageContracts.test.js => Storage.test.js} (53%) diff --git a/contracts/StorageContracts.sol b/contracts/Storage.sol similarity index 98% rename from contracts/StorageContracts.sol rename to contracts/Storage.sol index 835c7b8..0d62748 100644 --- a/contracts/StorageContracts.sol +++ b/contracts/Storage.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import "./Contracts.sol"; import "./Proofs.sol"; -contract StorageContracts is Contracts, Proofs { +contract Storage is Contracts, Proofs { function newContract( uint _duration, diff --git a/test/Contracts.test.js b/test/Contracts.test.js index 9e4e067..02f5aa1 100644 --- a/test/Contracts.test.js +++ b/test/Contracts.test.js @@ -2,7 +2,7 @@ const { expect } = require("chai") const { ethers } = require("hardhat") const { hashRequest, hashBid, sign } = require("./marketplace") -describe("Storage Contracts", function () { +describe("Contracts", function () { const duration = 31 * 24 * 60 * 60 // 31 days const size = 1 * 1024 * 1024 * 1024 // 1 Gigabyte diff --git a/test/StorageContracts.test.js b/test/Storage.test.js similarity index 53% rename from test/StorageContracts.test.js rename to test/Storage.test.js index 5585fb5..180ecef 100644 --- a/test/StorageContracts.test.js +++ b/test/Storage.test.js @@ -2,42 +2,37 @@ const { expect } = require("chai") const { ethers } = require("hardhat") const { hashRequest, hashBid, sign } = require("./marketplace") -describe("Storage Contracts", function () { +describe("Storage", function () { - const duration = 31 * 24 * 60 * 60 // 31 days - const size = 1 * 1024 * 1024 * 1024 // 1 Gigabyte - const contentHash = ethers.utils.sha256("0xdeadbeef") // hash of content - const proofPeriod = 8 // 8 blocks ≈ 2 minutes - const proofTimeout = 4 // 4 blocks ≈ 1 minute - const price = 42 - const nonce = ethers.utils.randomBytes(32) + describe("creating a new storage contract", function () { - var contracts - var client, host - var bidExpiry - var requestHash, bidHash - var id + const duration = 31 * 24 * 60 * 60 // 31 days + const size = 1 * 1024 * 1024 * 1024 // 1 Gigabyte + const contentHash = ethers.utils.sha256("0xdeadbeef") // hash of content + const proofPeriod = 8 // 8 blocks ≈ 2 minutes + const proofTimeout = 4 // 4 blocks ≈ 1 minute + const price = 42 + const nonce = ethers.utils.randomBytes(32) - beforeEach(async function () { - [client, host] = await ethers.getSigners() - let StorageContracts = await ethers.getContractFactory("StorageContracts") - contracts = await StorageContracts.deploy() - requestHash = hashRequest( - duration, - size, - contentHash, - proofPeriod, - proofTimeout, - nonce - ) - bidExpiry = Math.round(Date.now() / 1000) + 60 * 60 // 1 hour from now - bidHash = hashBid(requestHash, bidExpiry, price) - id = bidHash - }) - - describe("when properly instantiated", function () { + let contracts + let client, host + let id beforeEach(async function () { + [client, host] = await ethers.getSigners() + let StorageContracts = await ethers.getContractFactory("Storage") + contracts = await StorageContracts.deploy() + let requestHash = hashRequest( + duration, + size, + contentHash, + proofPeriod, + proofTimeout, + nonce + ) + let bidExpiry = Math.round(Date.now() / 1000) + 60 * 60 // 1 hour from now + let bidHash = hashBid(requestHash, bidExpiry, price) + id = bidHash await contracts.newContract( duration, size, @@ -53,7 +48,7 @@ describe("Storage Contracts", function () { ) }) - it("created a contract", async function () { + it("created the contract", async function () { expect(await contracts.duration(id)).to.equal(duration) expect(await contracts.size(id)).to.equal(size) expect(await contracts.contentHash(id)).to.equal(contentHash)