Skip to content

Commit

Permalink
Remove duplicated test case
Browse files Browse the repository at this point in the history
  • Loading branch information
gavfu committed Mar 26, 2024
1 parent a38e68b commit 5ed0104
Showing 1 changed file with 0 additions and 94 deletions.
94 changes: 0 additions & 94 deletions test/contractsv2/BridgeV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,100 +211,6 @@ describe("PolygonZkEVMBridge Contract", () => {
expect(computedGlobalExitRoot).to.be.equal(await polygonZkEVMGlobalExitRoot.getLastGlobalExitRoot());
});

it("should PolygonZkEVM bridge asset and verify merkle proof", async () => {
const depositCount = await polygonZkEVMBridgeContract.depositCount();
const originNetwork = networkIDMainnet;
const tokenAddress = polTokenContract.target;
const amount = ethers.parseEther("10");
const destinationNetwork = networkIDRollup;
const destinationAddress = deployer.address;

const metadata = metadataToken;
const metadataHash = ethers.solidityPackedKeccak256(["bytes"], [metadata]);

const balanceDeployer = await polTokenContract.balanceOf(deployer.address);
const balanceBridge = await polTokenContract.balanceOf(polygonZkEVMBridgeContract.target);

const rollupExitRoot = await polygonZkEVMGlobalExitRoot.lastRollupExitRoot();

// create a new deposit
await expect(polTokenContract.approve(polygonZkEVMBridgeContract.target, amount))
.to.emit(polTokenContract, "Approval")
.withArgs(deployer.address, polygonZkEVMBridgeContract.target, amount);

// pre compute root merkle tree in Js
const height = 32;
const merkleTree = new MerkleTreeBridge(height);
const leafValue = getLeafValue(
LEAF_TYPE_ASSET,
originNetwork,
tokenAddress,
destinationNetwork,
destinationAddress,
amount,
metadataHash
);
merkleTree.add(leafValue);
const rootJSMainnet = merkleTree.getRoot();

await expect(
polygonZkEVMBridgeContract.bridgeAsset(
destinationNetwork,
destinationAddress,
amount,
tokenAddress,
true,
"0x",
{value: 1}
)
).to.be.revertedWithCustomError(polygonZkEVMBridgeContract, "MsgValueNotZero");

await expect(
polygonZkEVMBridgeContract.bridgeAsset(
destinationNetwork,
destinationAddress,
amount,
tokenAddress,
true,
"0x"
)
)
.to.emit(polygonZkEVMBridgeContract, "BridgeEvent")
.withArgs(
LEAF_TYPE_ASSET,
originNetwork,
tokenAddress,
destinationNetwork,
destinationAddress,
amount,
metadata,
depositCount
)
.to.emit(polygonZkEVMGlobalExitRoot, "UpdateGlobalExitRoot")
.withArgs(rootJSMainnet, rollupExitRoot);

expect(await polTokenContract.balanceOf(deployer.address)).to.be.equal(balanceDeployer - amount);
expect(await polTokenContract.balanceOf(polygonZkEVMBridgeContract.target)).to.be.equal(balanceBridge + amount);
expect(await polygonZkEVMBridgeContract.lastUpdatedDepositCount()).to.be.equal(1);

// check merkle root with SC
const rootSCMainnet = await polygonZkEVMBridgeContract.getRoot();
expect(rootSCMainnet).to.be.equal(rootJSMainnet);

// check merkle proof
const proof = merkleTree.getProofTreeByIndex(0);
const index = 0;

// verify merkle proof
expect(verifyMerkleProof(leafValue, proof, index, rootSCMainnet)).to.be.equal(true);
expect(await polygonZkEVMBridgeContract.verifyMerkleProof(leafValue, proof, index, rootSCMainnet)).to.be.equal(
true
);

const computedGlobalExitRoot = calculateGlobalExitRoot(rootJSMainnet, rollupExitRoot);
expect(computedGlobalExitRoot).to.be.equal(await polygonZkEVMGlobalExitRoot.getLastGlobalExitRoot());
});

it("should PolygonZkEVMBridge message and verify merkle proof", async () => {
const depositCount = await polygonZkEVMBridgeContract.depositCount();
const originNetwork = networkIDMainnet;
Expand Down

0 comments on commit 5ed0104

Please sign in to comment.