Skip to content

Commit

Permalink
Merge pull request #315 from joinzien/tests
Browse files Browse the repository at this point in the history
Move a lot of values to constants
  • Loading branch information
Zoe Nolan authored Oct 24, 2023
2 parents d62c32e + cf253e8 commit 2225268
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
42 changes: 38 additions & 4 deletions test/DiscountTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ describe("Discounts", () => {
let annualPassContract: TestPassOne;
let lifetimePassContract: TestPassTwo;

const nullAddress = "0x0000000000000000000000000000000000000000";
const mintCostAllowlist = ethers.utils.parseEther("0.4");
const mintCostGeneral = ethers.utils.parseEther("0.8");

const hundreadPercentInBps = 10000;
const annualPassDiscountBps = 2500;
const lifetimePassDiscountBps = 5000;

beforeEach(async () => {
signer = (await ethers.getSigners())[0];
Expand Down Expand Up @@ -78,10 +83,8 @@ describe("Discounts", () => {
)) as TestPassTwo;
lifetimePassContract.initialize();

const mintCostAllowlist = ethers.utils.parseEther("0.4");
const mintCostGeneral = ethers.utils.parseEther("0.8");
await minterContract.setPricing(10, 500, mintCostAllowlist, mintCostGeneral, 2, 1);
await minterContract.updateDiscounts(annualPassContract.address, lifetimePassContract.address, 2500, 5000);
await minterContract.updateDiscounts(annualPassContract.address, lifetimePassContract.address, annualPassDiscountBps, lifetimePassDiscountBps);
});

it("A non pass holder can not mint while the drop is not for sale", async () => {
Expand Down Expand Up @@ -337,4 +340,35 @@ describe("Discounts", () => {

await expect(minterContract.connect(user).mintEditions([signerAddress], { value: ethers.utils.parseEther("0.9") })).to.be.revertedWith("Wrong price");
});

it("A pass holder can mint for free with 100% discount", async () => {
await minterContract.updateDiscounts(annualPassContract.address, lifetimePassContract.address, hundreadPercentInBps, hundreadPercentInBps);

await annualPassContract.connect(user).mint(userAddress);
await minterContract.setAllowedMinter(2);

expect(await minterContract.connect(user).mintEditions([signerAddress], { value: ethers.utils.parseEther("0") })).to.emit(minterContract, "EditionSold");

expect(await minterContract.totalSupply()).to.be.equal(1);
expect(await minterContract.getAllowListMintLimit()).to.be.equal(2);
expect(await minterContract.getGeneralMintLimit()).to.be.equal(1);
expect(await minterContract.getMintLimit(signerAddress)).to.be.equal(9);

});

it("A pass holder can mint for the standard cost with 0% discount", async () => {
await minterContract.updateDiscounts(annualPassContract.address, lifetimePassContract.address, 0, 0);

await annualPassContract.connect(user).mint(userAddress);
await minterContract.setAllowedMinter(2);

expect(await minterContract.connect(user).mintEditions([signerAddress], { value: ethers.utils.parseEther("0.8") })).to.emit(minterContract, "EditionSold");

expect(await minterContract.totalSupply()).to.be.equal(1);
expect(await minterContract.getAllowListMintLimit()).to.be.equal(2);
expect(await minterContract.getGeneralMintLimit()).to.be.equal(1);
expect(await minterContract.getMintLimit(signerAddress)).to.be.equal(9);

});

});
13 changes: 13 additions & 0 deletions test/MintRandomlyTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ describe("Mint randomly", () => {
expect(await minterContract.getMintLimit(signerAddress)).to.be.equal(9);
});

it("Mint 2 editions via mintMultipleEditions", async () => {
await minterContract.setAllowedMinter(2);
const mintCost = ethers.utils.parseEther("0.1");
await minterContract.setPricing(10, 500, mintCost, mintCost, 2, 2);

expect(await minterContract.mintMultipleEditions(signerAddress, 2, { value: ethers.utils.parseEther("0.2") })).to.emit(minterContract, "EditionSold");

expect(await minterContract.totalSupply()).to.be.equal(2);
expect(await minterContract.getAllowListMintLimit()).to.be.equal(2);
expect(await minterContract.getGeneralMintLimit()).to.be.equal(2);
expect(await minterContract.getMintLimit(signerAddress)).to.be.equal(8);
});

it("Can mint zero cost", async () => {
const mintCost = ethers.utils.parseEther("0.0");
await minterContract.setPricing(10, 500, mintCost, mintCost, 2, 1);
Expand Down

0 comments on commit 2225268

Please sign in to comment.