Skip to content

Commit

Permalink
Make the tests use the proxy instead of the mastercopy
Browse files Browse the repository at this point in the history
  • Loading branch information
asgeir-s committed Jan 2, 2023
1 parent bf56d3b commit ba33270
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/myModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import { expect } from "chai"
import { ethers, deployments, getNamedAccounts } from "hardhat"

const setup = async () => {
await deployments.fixture(["MyModule"])
await deployments.fixture(["moduleProxy"])
const { tester } = await getNamedAccounts()
const testSigner = await ethers.getSigner(tester)
const buttonDeployment = await deployments.get("Button")
const myModuleDeployment = await deployments.get("MyModule")
const myModuleProxyDeployment = await deployments.get("MyModuleProxy")
const buttonContract = await ethers.getContractAt("Button", buttonDeployment.address, testSigner)
const myModuleContract = await ethers.getContractAt("MyModule", myModuleDeployment.address, testSigner)
return { buttonContract, myModuleContract }
const myModuleProxyContract = await ethers.getContractAt("MyModule", myModuleProxyDeployment.address, testSigner)
return { buttonContract, myModuleProxyContract }
}

describe("MyModule", function () {
it("Should be possible to 'press the button' through MyModule", async function () {
const { buttonContract, myModuleContract } = await setup()
const { buttonContract, myModuleProxyContract } = await setup()
expect(await buttonContract.pushes()).to.equal(0)
await myModuleContract.pushButton()
await myModuleProxyContract.pushButton()
expect(await buttonContract.pushes()).to.equal(1)
})
it("Should NOT be possible to 'press the button' directly on the Button contract", async function () {
const { buttonContract } = await setup()
expect(buttonContract.pushButton()).to.revertedWith("Ownable: caller is not the owner")
await expect(buttonContract.pushButton()).to.revertedWith("Ownable: caller is not the owner")
})
})

0 comments on commit ba33270

Please sign in to comment.