Skip to content

Commit

Permalink
fixup tests for burnable
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Apr 1, 2024
1 parent 63c6572 commit 4e135b3
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 123 deletions.
71 changes: 71 additions & 0 deletions test/ERC721SeaDrop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,4 +816,75 @@ describe(`ERC721SeaDrop (v${VERSION})`, function () {
.to.emit(seadrop, "SignedMintValidationParamsUpdated")
.withArgs(token.address, config.signers[0], [0, 0, 0, 0, 0, 0, 0]);
});

it("Should only let the token owner burn their own token", async () => {
await token.setMaxSupply(3);

// Mint three tokens to the minter.
await whileImpersonating(
seadrop.address,
provider,
async (impersonatedSigner) => {
await token.connect(impersonatedSigner).mintSeaDrop(minter.address, 3);
}
);

expect(await token.ownerOf(1)).to.equal(minter.address);
expect(await token.ownerOf(2)).to.equal(minter.address);
expect(await token.ownerOf(3)).to.equal(minter.address);
expect(await token.totalSupply()).to.equal(3);

// Only the owner or approved of the minted token should be able to burn it.
await expect(token.connect(owner).burn(1)).to.be.revertedWith(
"TransferCallerNotOwnerNorApproved()"
);
await expect(token.connect(minter).burn(1)).to.be.revertedWith(
"TransferCallerNotOwnerNorApproved()"
);
await expect(token.connect(minter).burn(2)).to.be.revertedWith(
"TransferCallerNotOwnerNorApproved()"
);
await expect(token.connect(owner).burn(3)).to.be.revertedWith(
"TransferCallerNotOwnerNorApproved()"
);

expect(await token.ownerOf(1)).to.equal(minter.address);
expect(await token.ownerOf(2)).to.equal(minter.address);
expect(await token.ownerOf(3)).to.equal(minter.address);
expect(await token.totalSupply()).to.equal(3);

await token.connect(minter).burn(1);

expect(await token.totalSupply()).to.equal(2);

await token.connect(minter).setApprovalForAll(minter.address, true);
await token.connect(minter).burn(2);

expect(await token.totalSupply()).to.equal(1);

await token.connect(minter).setApprovalForAll(minter.address, false);
await expect(token.connect(minter).burn(3)).to.be.revertedWith(
"TransferCallerNotOwnerNorApproved()"
);

await token.connect(minter).approve(owner.address, 3);
await token.connect(owner).burn(3);

expect(await token.totalSupply()).to.equal(0);

await expect(token.ownerOf(1)).to.be.revertedWith(
"OwnerQueryForNonexistentToken()"
);
await expect(token.ownerOf(2)).to.be.revertedWith(
"OwnerQueryForNonexistentToken()"
);
expect(await token.totalSupply()).to.equal(0);

// Should not be able to burn a nonexistent token.
for (const tokenId of [0, 1, 2, 3]) {
await expect(token.connect(minter).burn(tokenId)).to.be.revertedWith(
"OwnerQueryForNonexistentToken()"
);
}
});
});
123 changes: 0 additions & 123 deletions test/ERC721SeaDropBurnable.spec.ts

This file was deleted.

0 comments on commit 4e135b3

Please sign in to comment.