Skip to content

Commit

Permalink
Unit test NFT transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
pouya-eghbali committed Mar 17, 2024
1 parent 367caa9 commit 92cdad7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/Staking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,4 +657,16 @@ describe("Staking", function () {
const user1Stake = await staking["stakeOf(bytes20)"](user1bls);
expect(user1Stake.amount).to.equal(ethers.parseUnits("500"));
});

it("reverts if the NFT is not the expected one", async function () {
await expect(
staking.onERC721Received(user1.address, user2.address, 123, "0x")
).to.be.revertedWithCustomError(staking, "WrongNFT()");
});

it("reverts if accepting NFT is forbidden", async function () {
await expect(
nft.connect(user1).safeTransferFrom(user1.address, stakingAddr, 1)
).to.be.revertedWithCustomError(staking, "Forbidden()");
});
});

0 comments on commit 92cdad7

Please sign in to comment.