Skip to content

Commit

Permalink
Add token controller burnFrom unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patitonar committed Feb 3, 2023
1 parent 5b04309 commit d1111c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/unit/TokenController/burnFrom.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('burnFrom', 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).burnFrom(member1.address, amount)).to.be.revertedWith(
'Caller is not an internal contract',
);
});

it('burns nxm from 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).burnFrom(member1.address, amount);

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

expect(balanceMember1).to.equal(initialBalanceMember1.sub(amount));
});
});
1 change: 1 addition & 0 deletions test/unit/TokenController/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ describe('TokenController', function () {
require('./changeOperator');
require('./operatorTransfer');
require('./mint');
require('./burnFrom');
});

0 comments on commit d1111c9

Please sign in to comment.