123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import { expect } from "chai"
- import { ethers } from "hardhat"
- import { MockUSDT } from "../typechain-types"
- describe("MockUSDT", function () {
- let mockUSDT: MockUSDT
- let owner: any
- let user1: any
- let user2: any
- beforeEach(async function () {
- ;[owner, user1, user2] = await ethers.getSigners()
- const MockUSDTFactory = await ethers.getContractFactory("MockUSDT")
- mockUSDT = await MockUSDTFactory.deploy("Mock USDT", "mUSDT", owner.address)
- })
- describe("Deployment", function () {
- it("Should set the right owner", async function () {
- expect(await mockUSDT.balanceOf(owner.address)).to.equal(ethers.parseUnits("1000000", 6))
- })
- it("Should have correct decimals", async function () {
- expect(await mockUSDT.decimals()).to.equal(6)
- })
- it("Should have correct name and symbol", async function () {
- expect(await mockUSDT.name()).to.equal("Mock USDT")
- expect(await mockUSDT.symbol()).to.equal("mUSDT")
- })
- })
- describe("Minting", function () {
- it("Should allow anyone to mint", async function () {
- const mintAmount = ethers.parseUnits("1000", 6)
- await mockUSDT.connect(user1).mint(user2.address, mintAmount)
- expect(await mockUSDT.balanceOf(user2.address)).to.equal(mintAmount)
- })
- })
- describe("Transfer", function () {
- it("Should transfer tokens correctly", async function () {
- const transferAmount = ethers.parseUnits("100", 6)
- await mockUSDT.connect(owner).transfer(user1.address, transferAmount)
- expect(await mockUSDT.balanceOf(user1.address)).to.equal(transferAmount)
- })
- })
- describe("Burn", function () {
- it("Should burn tokens correctly", async function () {
- const burnAmount = ethers.parseUnits("100", 6)
- const initialBalance = await mockUSDT.balanceOf(owner.address)
- await mockUSDT.connect(owner).burn(burnAmount)
- expect(await mockUSDT.balanceOf(owner.address)).to.equal(initialBalance - burnAmount)
- })
- })
- })
|