Skip to content

Commit

Permalink
Update FixedPriceAllowedMintersStrategy.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
VolodymyrBg authored Jan 21, 2025
1 parent 09eacb7 commit f493c9f
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,58 @@
import { expect } from "chai";
import { ethers } from "hardhat";
import { time } from "@nomicfoundation/hardhat-network-helpers";
import { FixedPriceAllowedMintersStrategy } from "../../../typechain-types";

describe("FixedPriceAllowedMintersStrategy", () => {
let fixedPriceMinter: FixedPriceAllowedMintersStrategy;

beforeEach(async () => {
const FixedPriceMinter = await ethers.getContractFactory("FixedPriceAllowedMintersStrategy");
fixedPriceMinter = await FixedPriceMinter.deploy();
await fixedPriceMinter.deployed();
});

describe("setSale", () => {
it("should set sale with valid time window", async () => {
const now = await time.latest();
const saleConfig = {
saleStart: now + 100,
saleEnd: now + 1000,
maxTokensPerAddress: 5,
pricePerToken: ethers.utils.parseEther("0.1"),
fundsRecipient: ethers.constants.AddressZero
};

await expect(fixedPriceMinter.setSale(1, saleConfig))
.to.emit(fixedPriceMinter, "SaleSet");
});

it("should revert when saleEnd is before saleStart", async () => {
const now = await time.latest();
const saleConfig = {
saleStart: now + 1000,
saleEnd: now + 100,
maxTokensPerAddress: 5,
pricePerToken: ethers.utils.parseEther("0.1"),
fundsRecipient: ethers.constants.AddressZero
};

await expect(fixedPriceMinter.setSale(1, saleConfig))
.to.be.revertedWithCustomError(fixedPriceMinter, "InvalidSaleTime");
});

it("should revert when saleStart equals saleEnd", async () => {
const now = await time.latest();
const saleConfig = {
saleStart: now + 100,
saleEnd: now + 100,
maxTokensPerAddress: 5,
pricePerToken: ethers.utils.parseEther("0.1"),
fundsRecipient: ethers.constants.AddressZero
};

await expect(fixedPriceMinter.setSale(1, saleConfig))
.to.be.revertedWithCustomError(fixedPriceMinter, "InvalidSaleTime");
});
});
});

0 comments on commit f493c9f

Please sign in to comment.