Use deployment fixture for Storage contract tests

This commit is contained in:
Mark Spanbroek 2021-11-16 14:26:28 +01:00 committed by markspanbroek
parent 7b16841534
commit a69a6d6975
2 changed files with 11 additions and 13 deletions

View File

@ -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;

View File

@ -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 () {