Skip to content

Commit

Permalink
New DMC mint test case
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqiushi committed Jan 10, 2024
1 parent 28125e6 commit 3eae867
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/test_exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Exchange", function () {
before(async () => {
signers = await ethers.getSigners()

dmc = await (await ethers.deployContract("DMCToken", [ethers.parseEther("1000000000")])).waitForDeployment()
dmc = await (await ethers.deployContract("DMCToken", [ethers.parseEther("1000000000"), [], []])).waitForDeployment()
gwt = await (await ethers.deployContract("GWTToken")).waitForDeployment()
exchange = await (await upgrades.deployProxy(await ethers.getContractFactory("Exchange"),
[await dmc.getAddress(), await gwt.getAddress()],
Expand All @@ -24,17 +24,21 @@ describe("Exchange", function () {

await (await gwt.enableMinter([await exchange.getAddress()])).wait();
await (await dmc.enableMinter([await exchange.getAddress()])).wait();

// await (await dmc.transfer(signers[1].address, ethers.parseEther("1000"))).wait()
})

it("mint dmc", async () => {
await expect(exchange.connect(signers[0]).mintDMC(ethers.ZeroHash, []))
.emit(dmc, "Transfer").withArgs(ethers.ZeroAddress, signers[0].address, ethers.parseEther("210"));
await (await exchange.allowMintDMC(signers[0].address, "cookie1", ethers.parseEther("500"))).wait();

await expect(exchange.connect(signers[1]).allowMintDMC(signers[1].address, "cookie2", ethers.parseEther("1500"))).revertedWith("not mint admin");
await expect(exchange.connect(signers[1]).mintDMC("cookie1")).revertedWith("cannot mint");

await expect(exchange.mintDMC("cookie1")).changeTokenBalance(dmc, signers[0].address, ethers.parseEther("500"));

await expect(exchange.mintDMC("cookie1")).revertedWith("cannot mint");

// 为了测试,将signers[0]直接加入dmc的minter,并给signers[1] mint 1000 dmc
await (await dmc.enableMinter([signers[0].address])).wait();
await (await dmc.connect(signers[0]).mint(signers[1].address, ethers.parseEther("1000"))).wait()
await (await exchange.setMintAdmin(signers[1].address)).wait();
await (await exchange.connect(signers[1]).allowMintDMC(signers[1].address, "cookie2", ethers.parseEther("1000"))).wait();
await expect(exchange.connect(signers[1]).mintDMC("cookie2")).changeTokenBalance(dmc, signers[1].address, ethers.parseEther("1000"));
});

it("exchange dmc to gwt", async () => {
Expand Down

0 comments on commit 3eae867

Please sign in to comment.