Skip to content

Commit

Permalink
repair test
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Dec 25, 2023
1 parent 5948118 commit 410f724
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions helix-contract/test/1_test_bscv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,8 @@ describe("darwinia<>bsc mapping token tests", () => {
});
console.log(wallets[0].address, wallets[1].address, wallets[2].address);
const guardContract = await ethers.getContractFactory("Guard");
const guard = await guardContract.deploy([wallets[0].address, wallets[1].address, wallets[2].address], 3, 60);
const guard = await guardContract.deploy([wallets[0].address, wallets[1].address, wallets[2].address], 3, 60, owner.address);
await guard.deployed();
await guard.setDepositor(owner.address, true);

await originalToken.approve(guard.address, 1000);
await guard.deposit(1, originalToken.address, wallets[1].address, 100);
Expand All @@ -426,16 +425,15 @@ describe("darwinia<>bsc mapping token tests", () => {
ethUtil.keccak256(
abi.rawEncode(
['bytes4', 'bytes'],
[abi.methodID('claim', [ 'address', 'uint256', 'uint256', 'address', 'address', 'uint256', 'bytes[]' ]),
abi.rawEncode(['address', 'uint256', 'uint256', 'address', 'address', 'uint256'],
[owner.address, 1, timestamp01, originalToken.address, wallets[1].address, 100])
[abi.methodID('claim', ['uint256', 'uint256', 'address', 'address', 'uint256', 'bytes[]' ]),
abi.rawEncode(['uint256', 'uint256', 'address', 'address', 'uint256'],
[1, timestamp01, originalToken.address, wallets[1].address, 100])
]
)
);

// cannot claim without signatures
await expect(guard.claimByTimeout(
owner.address,
2,
timestamp01,
originalToken.address,
Expand All @@ -445,23 +443,20 @@ describe("darwinia<>bsc mapping token tests", () => {

await network.provider.send("evm_increaseTime", [3600]);
await expect(guard.claimByTimeout(
owner.address,
2,
timestamp01,
originalToken.address,
wallets[1].address,
100,
false)).to.be.revertedWith("Guard: Invalid id to claim");
await expect(guard.claimByTimeout(
owner.address,
1,
timestamp01,
originalToken.address,
wallets[1].address,
101,
false)).to.be.revertedWith("Guard: Invalid id to claim");
await expect(guard.claimByTimeout(
owner.address,
1,
timestamp01,
originalToken.address,
Expand All @@ -480,19 +475,18 @@ describe("darwinia<>bsc mapping token tests", () => {
);
return ethers.utils.hexlify(signature);
});
await guard.claim(owner.address, 1, timestamp01, originalToken.address, wallets[1].address, 100, signatures);
await guard.claim(1, timestamp01, originalToken.address, wallets[1].address, 100, signatures);
expect(await originalToken.balanceOf(wallets[1].address)).to.equal(100);
// can't claim twice
await expect(guard.claim(owner.address, 1, timestamp01, originalToken.address, wallets[1].address, 100, signatures)).to.be.revertedWith("Guard: Invalid id to claim");
await expect(guard.claim(1, timestamp01, originalToken.address, wallets[1].address, 100, signatures)).to.be.revertedWith("Guard: Invalid id to claim");
await expect(guard.claimByTimeout(
owner.address,
1,
timestamp01,
originalToken.address,
wallets[1].address,
100,
true)).to.be.revertedWith("Guard: Invalid id to claim");
await expect(guard.claim(owner.address, 2, timestamp02, originalToken.address, wallets[2].address, 200, signatures)).to.be.revertedWith("Guard: Invalid guard provided");
await expect(guard.claim(2, timestamp02, originalToken.address, wallets[2].address, 200, signatures)).to.be.revertedWith("Guard: Invalid guard provided");
});

it("test_gas", async function () {
Expand Down Expand Up @@ -530,9 +524,8 @@ describe("darwinia<>bsc mapping token tests", () => {
mtf.setMappingNativeWrappedToken(mappingTokenAddress);

const guardContract = await ethers.getContractFactory("Guard");
const guard = await guardContract.deploy([owner.address], 1, 60);
const guard = await guardContract.deploy([owner.address], 1, 60, mtf.address);
await guard.deployed();
await guard.setDepositor(mtf.address, true);

await mtf.updateGuard(guard.address);

Expand Down

0 comments on commit 410f724

Please sign in to comment.