Skip to content

Commit

Permalink
Improve test fixture used in Acre test
Browse files Browse the repository at this point in the history
- use Acre and TBTC contracts deployed with hardhat dpeloyment scripts
- use unnamed signers as stakers, to not overlap with named signers
  (deployer and governance)
  • Loading branch information
nkuba committed Dec 5, 2023
1 parent be6036f commit 1e0ff45
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions core/test/Acre.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import {
SnapshotRestorer,
loadFixture,
takeSnapshot,
loadFixture,
} from "@nomicfoundation/hardhat-toolbox/network-helpers"
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers"
import { ethers } from "hardhat"
import { expect } from "chai"
import { ContractTransactionResponse, ZeroAddress } from "ethers"
import type { TestERC20, Acre } from "../typechain"

import type { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers"
import type { SnapshotRestorer } from "@nomicfoundation/hardhat-toolbox/network-helpers"
import { deployment } from "./helpers/context"
import { getUnnamedSigner } from "./helpers/signer"

import { to1e18 } from "./utils"

async function acreFixture() {
const [staker, staker2] = await ethers.getSigners()
const Token = await ethers.getContractFactory("TestERC20")
const tbtc = await Token.deploy()
import type { Acre, TestERC20 } from "../typechain"

async function fixture() {
const { tbtc, acre } = await deployment()

const [staker, staker2] = await getUnnamedSigner()

const amountToMint = to1e18(100000)

tbtc.mint(staker, amountToMint)
tbtc.mint(staker2, amountToMint)

const Acre = await ethers.getContractFactory("Acre")
const acre = await Acre.deploy(await tbtc.getAddress())

return { acre, tbtc, staker, staker2 }
}

Expand All @@ -33,7 +34,7 @@ describe("Acre", () => {
let staker2: HardhatEthersSigner

before(async () => {
;({ acre, tbtc, staker, staker2 } = await loadFixture(acreFixture))
;({ acre, tbtc, staker, staker2 } = await loadFixture(fixture))
})

describe("Staking", () => {
Expand Down

0 comments on commit 1e0ff45

Please sign in to comment.