-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Expect allowance to be a mapping(address => uint)
- Loading branch information
Showing
1 changed file
with
15 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
const { expect } = require("chai") | ||
const { expect } = require('chai') | ||
|
||
describe("Usable token (Allowances)", function() { | ||
describe('Usable token (Allowances)', function () { | ||
let minito, owner, alice, bob | ||
|
||
beforeEach(async ()=>{ | ||
const contractDeployer = await ethers.getContractFactory("UsableToken"); | ||
[owner, alice, bob] = await ethers.getSigners() | ||
beforeEach(async () => { | ||
const contractDeployer = await ethers.getContractFactory('UsableToken') | ||
;[owner, alice, bob] = await ethers.getSigners() | ||
minito = await contractDeployer.deploy(200) | ||
await minito.deployed() | ||
}) | ||
it("Deploy account should have 200 units ", async function() { | ||
it('Deploy account should have 200 units ', async function () { | ||
expect(await minito.accounts(owner.address)).to.equal(200) | ||
}) | ||
|
||
it("Too large transaction should fail", async function() { | ||
await expect( minito.transfer(alice.address, 2000)).to.be.reverted | ||
it('Too large transaction should fail', async function () { | ||
await expect(minito.transfer(alice.address, 2000)).to.be.reverted | ||
}) | ||
it("Transfer should change balances", async function() { | ||
it('Transfer should change balances', async function () { | ||
await minito.transfer(alice.address, 150) | ||
expect(await minito.accounts(alice.address)).to.equal(150) | ||
|
||
}) | ||
|
||
it("Owner can approve and allowance corresponds", async function() { | ||
it('Owner can approve and allowance corresponds', async function () { | ||
await minito.approve(alice.address, 23) | ||
expect(await minito.allowance(owner.address, alice.address)).to.equal(23) | ||
expect(await minito.allowance(alice.address)).to.equal(23) | ||
}) | ||
|
||
it("Too large transferFrom should fail", async function() { | ||
it('Too large transferFrom should fail', async function () { | ||
await minito.approve(bob.address, 23) | ||
|
||
await expect( minito.connect(bob).transferFrom(owner.address, alice.address, 2000)).to.be.reverted | ||
await expect( | ||
minito.connect(bob).transferFrom(owner.address, alice.address, 2000), | ||
).to.be.reverted | ||
}) | ||
|
||
}) |