MockUSDT.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { expect } from "chai"
  2. import { ethers } from "hardhat"
  3. import { MockUSDT } from "../typechain-types"
  4. describe("MockUSDT", function () {
  5. let mockUSDT: MockUSDT
  6. let owner: any
  7. let user1: any
  8. let user2: any
  9. beforeEach(async function () {
  10. ;[owner, user1, user2] = await ethers.getSigners()
  11. const MockUSDTFactory = await ethers.getContractFactory("MockUSDT")
  12. mockUSDT = await MockUSDTFactory.deploy("Mock USDT", "mUSDT", owner.address)
  13. })
  14. describe("Deployment", function () {
  15. it("Should set the right owner", async function () {
  16. expect(await mockUSDT.balanceOf(owner.address)).to.equal(ethers.parseUnits("1000000", 6))
  17. })
  18. it("Should have correct decimals", async function () {
  19. expect(await mockUSDT.decimals()).to.equal(6)
  20. })
  21. it("Should have correct name and symbol", async function () {
  22. expect(await mockUSDT.name()).to.equal("Mock USDT")
  23. expect(await mockUSDT.symbol()).to.equal("mUSDT")
  24. })
  25. })
  26. describe("Minting", function () {
  27. it("Should allow anyone to mint", async function () {
  28. const mintAmount = ethers.parseUnits("1000", 6)
  29. await mockUSDT.connect(user1).mint(user2.address, mintAmount)
  30. expect(await mockUSDT.balanceOf(user2.address)).to.equal(mintAmount)
  31. })
  32. })
  33. describe("Transfer", function () {
  34. it("Should transfer tokens correctly", async function () {
  35. const transferAmount = ethers.parseUnits("100", 6)
  36. await mockUSDT.connect(owner).transfer(user1.address, transferAmount)
  37. expect(await mockUSDT.balanceOf(user1.address)).to.equal(transferAmount)
  38. })
  39. })
  40. describe("Burn", function () {
  41. it("Should burn tokens correctly", async function () {
  42. const burnAmount = ethers.parseUnits("100", 6)
  43. const initialBalance = await mockUSDT.balanceOf(owner.address)
  44. await mockUSDT.connect(owner).burn(burnAmount)
  45. expect(await mockUSDT.balanceOf(owner.address)).to.equal(initialBalance - burnAmount)
  46. })
  47. })
  48. })