From a69a6d697531fad89b1e5f3319b38815d4d1d0a0 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 16 Nov 2021 14:26:28 +0100 Subject: [PATCH] Use deployment fixture for Storage contract tests --- contracts/Storage.sol | 6 +++--- test/Storage.test.js | 18 ++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/contracts/Storage.sol b/contracts/Storage.sol index 49beb0b..9c8fcb1 100644 --- a/contracts/Storage.sol +++ b/contracts/Storage.sol @@ -7,9 +7,9 @@ import "./Stakes.sol"; contract Storage is Contracts, Proofs, Stakes { - uint private stakeAmount; - uint private slashMisses; - uint private slashPercentage; + uint public stakeAmount; + uint public slashMisses; + uint public slashPercentage; mapping(bytes32=>bool) private finished; diff --git a/test/Storage.test.js b/test/Storage.test.js index 33c547b..e3a62b1 100644 --- a/test/Storage.test.js +++ b/test/Storage.test.js @@ -1,30 +1,28 @@ const { expect } = require("chai") -const { ethers } = require("hardhat") +const { ethers, deployments } = require("hardhat") const { hashRequest, hashBid, sign } = require("./marketplace") const { exampleRequest, exampleBid } = require("./examples") const { mineBlock, minedBlockNumber } = require ("./mining") describe("Storage", function () { - const stakeAmount = 100 - const slashMisses = 3 - const slashPercentage = 10 const request = exampleRequest() const bid = exampleBid() let storage let token let client, host + let stakeAmount, slashMisses, slashPercentage beforeEach(async function () { [client, host] = await ethers.getSigners() - let Token = await ethers.getContractFactory("TestToken") - let StorageContracts = await ethers.getContractFactory("Storage") - token = await Token.deploy() - storage = await StorageContracts.deploy( - token.address, stakeAmount, slashMisses, slashPercentage - ) + await deployments.fixture(['TestToken', 'Storage']) + token = await ethers.getContract('TestToken') + storage = await ethers.getContract('Storage') await token.mint([client.address, host.address], 1000) + stakeAmount = await storage.stakeAmount() + slashMisses = await storage.slashMisses() + slashPercentage = await storage.slashPercentage() }) describe("creating a new storage contract", function () {