-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
projects/DAPIO/tests/integration-tests/erc20_factory_test.js
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { expect } = require("chai"); | ||
const { ethers } = require("hardhat"); | ||
|
||
describe("ERC20 Factory", function () { | ||
let erc20Factory; | ||
let owner; | ||
|
||
beforeEach(async function () { | ||
[owner] = await ethers.getSigners(); | ||
erc20Factory = await ethers.deploy("ERC20Factory"); | ||
}); | ||
|
||
it("should create a new ERC20 token", async function () { | ||
const tokenName = "MyToken"; | ||
const tokenSymbol = "MTK"; | ||
const totalSupply = 1000; | ||
|
||
const tx = await erc20Factory.createToken(tokenName, tokenSymbol, totalSupply); | ||
const receipt = await tx.wait(); | ||
|
||
const tokenAddress = receipt.events[0].args.token; | ||
const token = await ethers.getContractAt("ERC20", tokenAddress); | ||
|
||
expect(await token.name()).to.equal(tokenName); | ||
expect(await token.symbol()).to.equal(tokenSymbol); | ||
expect(await token.totalSupply()).to.equal(totalSupply); | ||
}); | ||
|
||
it("should return the correct token address", async function () { | ||
const tokenName = "MyToken"; | ||
const tokenSymbol = "MTK"; | ||
const totalSupply = 1000; | ||
|
||
const tx = await erc20Factory.createToken(tokenName, tokenSymbol, totalSupply); | ||
const receipt = await tx.wait(); | ||
|
||
const tokenAddress = receipt.events[0].args.token; | ||
expect(await erc20Factory.getToken(owner.address)).to.equal(tokenAddress); | ||
}); | ||
}); |