From 5ed010421ebefecb4013c73b9082af3e70587981 Mon Sep 17 00:00:00 2001 From: gavfu Date: Tue, 26 Mar 2024 18:21:07 +0800 Subject: [PATCH] Remove duplicated test case --- test/contractsv2/BridgeV2.test.ts | 94 ------------------------------- 1 file changed, 94 deletions(-) diff --git a/test/contractsv2/BridgeV2.test.ts b/test/contractsv2/BridgeV2.test.ts index 88478354d..455f02499 100644 --- a/test/contractsv2/BridgeV2.test.ts +++ b/test/contractsv2/BridgeV2.test.ts @@ -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;