Skip to content

Commit

Permalink
Merge pull request #10 from citydaoproject/mnorman-issue1
Browse files Browse the repository at this point in the history
fix: [#1] added test for pausing and fixed so that can't mint while p…
  • Loading branch information
mdnorman authored May 11, 2022
2 parents e69e15b + 5ed78eb commit abdf3b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contracts/ParcelNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ contract ParcelNFT is
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721EnumerableUpgradeable, ERC721Upgradeable) {
) internal virtual override(ERC721EnumerableUpgradeable, ERC721Upgradeable) whenNotPaused {
super._beforeTokenTransfer(from, to, tokenId);
}

Expand Down
26 changes: 25 additions & 1 deletion test/contracts/allowListClaim/allowListClaim.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BigNumber } from 'ethers';
import { DateTime } from 'luxon';
import { ZERO_ADDRESS } from '../../../src/constants/accounts';
import { ALLOW_LIST_CLAIM_INTERFACE_ID } from '../../../src/constants/interfaces';
import { PARCEL_MANAGER_ROLE } from '../../../src/constants/roles';
import { PARCEL_MANAGER_ROLE, PAUSER_ROLE } from '../../../src/constants/roles';
import {
buildMerkleTreeForAllowList,
convertToClaimPeriodTimestamp,
Expand Down Expand Up @@ -421,6 +421,30 @@ describe('allowListMint', () => {
expect(await parcelNFT.totalSupply()).to.eq(0);
});

it('should fail if paused', async () => {
const parcelNFT = await createParcelNFT();
await parcelNFT.grantRole(PARCEL_MANAGER_ROLE, INITIALIZER.address);
await parcelNFT.grantRole(PAUSER_ROLE, INITIALIZER.address);

await setValidClaimPeriod(parcelNFT);

const merkleTree = buildMerkleTreeForAllowList({ [USER1.address]: 1 });
await parcelNFT.setMerkleRoot(merkleTree.getHexRoot());

await parcelNFT.pause();

await expect(
parcelNFT.connect(USER1).allowListMint(1, 1, getMerkleProof(USER1.address, 1, merkleTree)),
).to.be.revertedWith('paused');
expect(await parcelNFT.balanceOf(USER1.address)).to.eq(0);
expect(await parcelNFT.balanceOf(USER2.address)).to.eq(0);
expect(await parcelNFT.balanceOf(USER3.address)).to.eq(0);
expect(await parcelNFT.alreadyClaimed(USER1.address)).to.eq(0);
expect(await parcelNFT.alreadyClaimed(USER2.address)).to.eq(0);
expect(await parcelNFT.alreadyClaimed(USER3.address)).to.eq(0);
expect(await parcelNFT.totalSupply()).to.eq(0);
});

it('should send Transfer event', async () => {
const parcelNFT = await createParcelNFT();
await parcelNFT.grantRole(PARCEL_MANAGER_ROLE, INITIALIZER.address);
Expand Down

0 comments on commit abdf3b4

Please sign in to comment.