Repository navigation
Expand file tree
/
Copy pathtestAdvancedToken.test.js
More file actions
56 lines (47 loc) · 1.88 KB
/
Copy pathtestAdvancedToken.test.js
File metadata and controls
56 lines (47 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("AdvancedToken", function () {
let token, owner, addr1, addr2;
beforeEach(async function () {
[owner, addr1, addr2] = await ethers.getSigners();
const AdvancedToken = await ethers.getContractFactory("AdvancedToken");
token = await AdvancedToken.deploy(
"Advanced Token",
"ADV",
18,
ethers.parseEther("100000000"),
owner.address
);
await token.waitForDeployment();
});
describe("Deployment", function () {
it("Should set the correct name", async function () {
expect(await token.name()).to.equal("Advanced Token");
});
it("Should set the correct symbol", async function () {
expect(await token.symbol()).to.equal("ADV");
});
});
describe("Minting", function () {
it("Should mint tokens to an address", async function () {
const mintAmount = ethers.parseEther("1000");
await token.mint(addr1.address, mintAmount);
expect(await token.balanceOf(addr1.address)).to.equal(mintAmount);
});
it("Should not allow non-minter to mint", async function () {
const mintAmount = ethers.parseEther("1000");
await expect(
token.connect(addr1).mint(addr2.address, mintAmount)
).to.be.reverted;
});
});
describe("Transfers", function () {
beforeEach(async function () {
await token.mint(owner.address, ethers.parseEther("10000"));
});
it("Should transfer tokens between accounts", async function () {
await token.transfer(addr1.address, ethers.parseEther("100"));
expect(await token.balanceOf(addr1.address)).to.equal(ethers.parseEther("100"));
});
});
});