Skip to content

Commit

Permalink
Add test for burning tokens.
Browse files Browse the repository at this point in the history
  • Loading branch information
kantp committed Mar 22, 2024
1 parent 20182c9 commit 0a70f8e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ describe('token integration', () => {
});

const mintAmount = UInt64.from(1000);
const burnAmount = UInt64.from(100);

describe('mint', () => {
describe('mint/burn', () => {
it('should mint for the sender account', async () => {

const tx = await Mina.transaction(context.senderAccount, () => {
Expand All @@ -176,6 +177,18 @@ describe('token integration', () => {
context.tokenA.getBalanceOf(context.senderAccount).toBigInt()
).toBe(mintAmount.toBigInt());
});

it('should burn tokens for the sender account', async () => {
const tx = await Mina.transaction(context.senderAccount, () => {
context.tokenA.burn(context.senderAccount, burnAmount);
});
tx.sign([context.senderKey, context.tokenAdminKey]);
await tx.prove();
await tx.send();
expect(
context.tokenA.getBalanceOf(context.senderAccount).toBigInt()
).toBe(mintAmount.toBigInt() - burnAmount.toBigInt());
});
});

describe('third party', () => {
Expand Down Expand Up @@ -210,7 +223,7 @@ describe('token integration', () => {

expect(
context.tokenA.getBalanceOf(context.senderAccount).toBigInt()
).toBe(mintAmount.toBigInt() - depositAmount.toBigInt());
).toBe(mintAmount.toBigInt() - burnAmount.toBigInt() - depositAmount.toBigInt());
});

it('should send tokens from one contract to another', async () => {
Expand Down

0 comments on commit 0a70f8e

Please sign in to comment.