Skip to content

Commit

Permalink
Add token controller mint unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patitonar committed Feb 3, 2023
1 parent 5748019 commit 5b04309
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/unit/TokenController/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ describe('TokenController', function () {
require('./withdrawNXMStakeAndRewards');
require('./changeOperator');
require('./operatorTransfer');
require('./mint');
});
29 changes: 29 additions & 0 deletions test/unit/TokenController/mint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { expect } = require('chai');
const { parseEther } = require('ethers/lib/utils');

describe('mint', function () {
it('reverts if caller is not an internal contract', async function () {
const { tokenController } = this.contracts;
const [member1] = this.accounts.members;

const amount = parseEther('10');
await expect(tokenController.connect(member1).mint(member1.address, amount)).to.be.revertedWith(
'Caller is not an internal contract',
);
});

it('mint nxm to member', async function () {
const { tokenController, nxm } = this.contracts;
const [internalContract] = this.accounts.internalContracts;
const [member1] = this.accounts.members;

const initialBalanceMember1 = await nxm.balanceOf(member1.address);

const amount = parseEther('10');
await tokenController.connect(internalContract).mint(member1.address, amount);

const balanceMember1 = await nxm.balanceOf(member1.address);

expect(balanceMember1).to.equal(initialBalanceMember1.add(amount));
});
});

0 comments on commit 5b04309

Please sign in to comment.