Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CON-2422 update test for usable-token exercise #90

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions tests/sol/usable-token.test.js
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
})

})
Loading