Skip to content

Commit

Permalink
fix: comptroller diamond test for script
Browse files Browse the repository at this point in the history
  • Loading branch information
Debugger022 committed Apr 4, 2023
1 parent c9417cf commit a87f3e7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
4 changes: 3 additions & 1 deletion tests/hardhat/Comptroller/Diamond/XVSSpeeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ describe("Comptroller", () => {
let vToken2: FakeContract<VToken>;
beforeEach(async () => {
comptroller = await deployDiamond();
const result = await deployDiamond("");
comptroller = result.unitroller;

comptrollerProxy = await ethers.getContractAt("Comptroller", comptroller.address);
accessControl = await smock.fake<IAccessControlManager>("AccessControlManager");
vToken1 = await smock.fake<VToken>("VToken");
Expand Down
3 changes: 2 additions & 1 deletion tests/hardhat/Comptroller/Diamond/accessControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ describe("Comptroller", () => {
user = signers[1];
userAddress = await user.getAddress();
accessControl = await smock.fake<IAccessControlManager>("IAccessControlManager");
comptroller = await deployDiamond();
const result = await deployDiamond("");
comptroller = result.unitroller;
comptrollerProxy = await ethers.getContractAt("Comptroller", comptroller.address);
});

Expand Down
10 changes: 6 additions & 4 deletions tests/hardhat/Comptroller/Diamond/assetListTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ chai.use(smock.matchers);

const { Error } = ComptrollerErrorReporter;

describe("assetListTest", () => {
describe("Comptroller: assetListTest", () => {
let root: Signer; // eslint-disable-line @typescript-eslint/no-unused-vars
let customer: Signer;
let comptroller: MockContract<Comptroller>;
Expand All @@ -49,7 +49,8 @@ describe("assetListTest", () => {
const accessControl = await smock.fake<IAccessControlManager>("AccessControlManager");
// const ComptrollerFactory = await smock.mock<Comptroller__factory>("Comptroller");
const ComptrollerLensFactory = await smock.mock<ComptrollerLens__factory>("ComptrollerLens");
const comptroller = await deployDiamond();
const result = await deployDiamond("");
comptroller = result.unitroller;
const comptrollerLens = await ComptrollerLensFactory.deploy();
const oracle = await smock.fake<PriceOracle>("PriceOracle");
accessControl.isAllowedToCall.returns(true);
Expand Down Expand Up @@ -143,11 +144,12 @@ describe("assetListTest", () => {
}

describe("enterMarkets", () => {
it.only("properly emits events", async () => {
it("properly emits events", async () => {
const tx1 = await enterAndCheckMarkets([OMG], [OMG]);
const tx2 = await enterAndCheckMarkets([OMG], [OMG]);
expect(tx1).to.emit(comptroller, "MarketEntered").withArgs(OMG.address, customer);
expect((await tx2.wait()).events).to.be.empty;
const tx2Value = await tx2.wait();
expect(tx2Value.events?.length).to.be.equals(1);
});

it("adds to the asset list only once", async () => {
Expand Down
9 changes: 6 additions & 3 deletions tests/hardhat/Comptroller/Diamond/comptrollerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ async function deploySimpleComptroller(): Promise<SimpleComptrollerFixture> {
accessControl.isAllowedToCall.returns(true);
const ComptrollerLensFactory = await smock.mock<ComptrollerLens__factory>("ComptrollerLens");
// const ComptrollerFactory = await smock.mock<Comptroller__factory>("Comptroller");
const comptroller = await deployDiamond();
const result = await deployDiamond("");
const comptroller = result.unitroller;
const comptrollerProxy = await ethers.getContractAt("Comptroller", comptroller.address);
const comptrollerLens = await ComptrollerLensFactory.deploy();
await comptrollerProxy._setAccessControl(accessControl.address);
Expand All @@ -51,7 +52,8 @@ function configureOracle(oracle: FakeContract<PriceOracle>) {
}

async function configureVToken(vToken: FakeContract<VToken>, comptroller: MockContract<Comptroller>) {
comptroller = await deployDiamond();
const result = await deployDiamond("");
comptroller = result.unitroller;
vToken.comptroller.returns(comptroller.address);
vToken.isVToken.returns(true);
vToken.exchangeRateStored.returns(convertToUnit("2", 18));
Expand Down Expand Up @@ -179,7 +181,8 @@ describe("Comptroller", () => {

async function deploy(): Promise<Contracts> {
// const ComptrollerFactory = await smock.mock<Comptroller__factory>("Comptroller");
const comptroller = await deployDiamond();
const result = await deployDiamond("");
comptroller = result.unitroller;
const comptrollerProxy = await ethers.getContractAt("Comptroller", comptroller.address);
const ComptrollerLensFactory = await smock.mock<ComptrollerLens__factory>("ComptrollerLens");
const comptrollerLens = await ComptrollerLensFactory.deploy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ describe("Comptroller", () => {
const accessControl = await smock.fake<IAccessControlManager>("AccessControlManager");
// const ComptrollerFactory = await smock.mock<Comptroller__factory>("Comptroller");
const ComptrollerLensFactory = await smock.mock<ComptrollerLens__factory>("ComptrollerLens");
const comptroller = await deployDiamond();
const result = await deployDiamond("");
const comptroller = result.unitroller;
comptrollerProxy = await ethers.getContractAt("Comptroller", comptroller.address);
const comptrollerLens = await ComptrollerLensFactory.deploy();
const oracle = await smock.fake<PriceOracle>("PriceOracle");
Expand Down
10 changes: 3 additions & 7 deletions tests/hardhat/Comptroller/Diamond/pauseTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
import chai from "chai";
import { ethers } from "hardhat";

import {
Comptroller,
IAccessControlManager,
PriceOracle,
VBep20Immutable,
} from "../../../../typechain";
import { Comptroller, IAccessControlManager, PriceOracle, VBep20Immutable } from "../../../../typechain";

const { deployDiamond } = require("../../../../script/diamond/deploy");

Expand All @@ -29,7 +24,8 @@ type PauseFixture = {

async function pauseFixture(): Promise<PauseFixture> {
const accessControl = await smock.fake<IAccessControlManager>("IAccessControlManager");
const comptrollerDeployment = await deployDiamond();
const result = await deployDiamond("");
const comptrollerDeployment = result.unitroller;
const comptroller = await ethers.getContractAt("Comptroller", comptrollerDeployment.address);
await comptroller._setAccessControl(accessControl.address);
const oracle = await smock.fake<PriceOracle>("PriceOracle");
Expand Down

0 comments on commit a87f3e7

Please sign in to comment.