Skip to content

Commit aed125f

Browse files
committed
feat: 100% coverage in tests
(again)
1 parent dfd8f15 commit aed125f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/DATAv2onPolygon-test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,22 @@ describe("DATAv2onPolygon", () => {
2525
await token.deployed()
2626
await expect(token.connect(another).deposit(another.address, parseEther("1").toHexString())).to.be.revertedWith("error_onlyBridge")
2727
})
28+
29+
it("withdraw burns tokens", async () => {
30+
const [bridge, user] = await hardhatEthers.getSigners()
31+
const DATAv2onPolygon = await hardhatEthers.getContractFactory("DATAv2onPolygon")
32+
const token = await DATAv2onPolygon.deploy(bridge.address)
33+
await token.deployed()
34+
35+
expect((await token.balanceOf(user.address)).toString()).to.equal("0")
36+
const amountWei = parseEther("1")
37+
const amountBytes = hexZeroPad(amountWei, 32)
38+
await expect(token.connect(bridge).deposit(user.address, amountBytes)).to.emit(token, "Transfer(address,address,uint256,bytes)")
39+
expect((await token.balanceOf(user.address)).toString()).to.equal(amountWei.toString())
40+
41+
await expect(token.connect(user).withdraw(parseEther("1"))).to.emit(token, "Transfer(address,address,uint256)")
42+
.withArgs(user.address, "0x0000000000000000000000000000000000000000", amountWei.toHexString())
43+
44+
expect((await token.balanceOf(user.address)).toString()).to.equal("0")
45+
})
2846
})

0 commit comments

Comments
 (0)