Skip to content

Commit

Permalink
Test implementation for (in-)sufficient funds provided
Browse files Browse the repository at this point in the history
  • Loading branch information
velitchko committed May 29, 2024
1 parent 23687e8 commit 305b31b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/ERC4908Example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,42 @@ describe("ERC4908", function () {
);
await expect(mintAvailableContent).to.be.fulfilled;
});

it("Should check if the expected NFT price is met", async function () {

/* Arrange */

const { erc4908Example, wallets } = await loadFixture(deployERC4908ExampleFixture);
const { contentId, price, expirationTime } = paramsDefault;
const [Alice, Bob] = wallets;

let alice = await impersonate(erc4908Example, Alice);
let bob = await impersonate(erc4908Example, Bob);

await alice.write.setAccess([contentId, price, expirationTime]);

/* Act */

const mintInsufficientFunds = bob.write.mint([
Alice.account.address,
contentId,
Bob.account.address
], { value: price - 1n})

const mintSufficientFunds = bob.write.mint([
Alice.account.address,
contentId,
Bob.account.address
], { value: price })


/* Assert */

await expect(mintInsufficientFunds).to.be.rejectedWith(
'InsufficientFunds(2)'
);
await expect(mintSufficientFunds).to.be.fulfilled;
});
});

describe("Resources access check", function () {
Expand Down

0 comments on commit 305b31b

Please sign in to comment.