From 5dc462332944a2fba70a78d28f725649d570691a Mon Sep 17 00:00:00 2001 From: abilevych Date: Tue, 24 Oct 2023 14:31:31 +0300 Subject: [PATCH 01/25] test: restructure test solution --- .../tests/api/before-all/tokens.test.ts | 19 ----- .../tests/api/common/endpoints.test.ts | 47 +---------- .../tests/api/common/tokens.test.ts | 78 +++++++++++++++++++ 3 files changed, 82 insertions(+), 62 deletions(-) create mode 100644 packages/integration-tests/tests/api/common/tokens.test.ts diff --git a/packages/integration-tests/tests/api/before-all/tokens.test.ts b/packages/integration-tests/tests/api/before-all/tokens.test.ts index 9f2aee8dca..09e6c8b7d0 100644 --- a/packages/integration-tests/tests/api/before-all/tokens.test.ts +++ b/packages/integration-tests/tests/api/before-all/tokens.test.ts @@ -20,25 +20,6 @@ describe("Tokens", () => { expect(deployedToken).toContain(Logger.txHashStartsWith); }); - //@id1456 - it("Verify deployed to L2 custom token via /tokens/{tokenAddress}", async () => { - await setTimeout(localConfig.extendedPause); //works unstable without timeout - const apiRoute = `/tokens/${deployedToken}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body).toStrictEqual({ - l2Address: deployedToken, - l1Address: null, - symbol: Token.customL2TokenSymbol, - name: Token.customL2TokenName, - decimals: Token.customL2TokenDecimals, - }) - ); - }); - //@id657 it("Deploy custom ERC20 token to L1", async () => { deployedToken = await playbook.deployERC20toL1(); diff --git a/packages/integration-tests/tests/api/common/endpoints.test.ts b/packages/integration-tests/tests/api/common/endpoints.test.ts index 187d0418ce..68bfa0f3d7 100644 --- a/packages/integration-tests/tests/api/common/endpoints.test.ts +++ b/packages/integration-tests/tests/api/common/endpoints.test.ts @@ -2,12 +2,12 @@ import * as request from "supertest"; import { setTimeout } from "timers/promises"; import { environment, localConfig } from "../../../src/config"; -import { Buffer } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; +// import { Buffer } from "../../../src/entities"; +// import { Helper } from "../../../src/helper"; describe("Endpoints", () => { - const helper = new Helper(); - const bufferRoute = "src/playbook/"; + // const helper = new Helper(); + // const bufferRoute = "src/playbook/"; jest.setTimeout(localConfig.extendedTimeout); @@ -29,45 +29,6 @@ describe("Endpoints", () => { }); }); - describe("/tokens", () => { - //@id1508 - it("Verify the response via /tokens", async () => { - const l2DepositedToken = await helper.getStringFromFile(bufferRoute + Buffer.L2deposited); - const l1Token = await helper.getStringFromFile(bufferRoute + Buffer.L1); - const l2Token = await helper.getStringFromFile(bufferRoute + Buffer.L2); - - const apiRoute = `/tokens`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ l2Address: l2DepositedToken })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ l1Address: l1Token }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ symbol: "L1" }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ name: "L1 ERC20 token" }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ decimals: 18 }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ l2Address: l2Token }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ l1Address: null }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ symbol: "L2" }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ name: "L2 ERC20 token" }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ decimals: 18 }))) - .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) - .expect((res) => expect(res.body.links.first).toStrictEqual("tokens?limit=10")) - .expect((res) => expect(res.body.links.previous).toStrictEqual("")) - .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); - }); - }); - describe("/batches", () => { //@id1513 it("Verify the response via /batches", async () => { diff --git a/packages/integration-tests/tests/api/common/tokens.test.ts b/packages/integration-tests/tests/api/common/tokens.test.ts new file mode 100644 index 0000000000..8684fab6a1 --- /dev/null +++ b/packages/integration-tests/tests/api/common/tokens.test.ts @@ -0,0 +1,78 @@ +import * as request from "supertest"; +import { setTimeout } from "timers/promises"; + +import { environment } from "../../../src/config"; +import { localConfig } from "../../../src/config"; +import { Buffer, Token } from "../../../src/entities"; +import { Helper } from "../../../src/helper"; + +describe("Tokens", () => { + jest.setTimeout(localConfig.standardTimeout); + + const helper = new Helper(); + const bufferFile = "src/playbook/"; + let deployedToken: string; + + beforeAll(async () => { + deployedToken = await helper.getStringFromFile(bufferFile + Buffer.L2); + }); + + describe("/tokens", () => { + //@id1508 + it("Verify the response via /tokens", async () => { + const l2DepositedToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + const l1Token = await helper.getStringFromFile(bufferFile + Buffer.L1); + const l2Token = deployedToken; + + const apiRoute = `/tokens`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ l2Address: l2DepositedToken })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ l1Address: l1Token }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ symbol: "L1" }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ name: "L1 ERC20 token" }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ decimals: 18 }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ l2Address: l2Token }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ l1Address: null }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ symbol: "L2" }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ name: "L2 ERC20 token" }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ decimals: 18 }))) + .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) + .expect((res) => expect(res.body.links.first).toStrictEqual("tokens?limit=10")) + .expect((res) => expect(res.body.links.previous).toStrictEqual("")) + .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); + }); + }); + describe("/tokens/{tokenAddress}", () => { + //@id1456 + it("Verify deployed to L2 custom token via /tokens/{tokenAddress}", async () => { + await setTimeout(localConfig.extendedPause); //works unstable without timeout + const apiRoute = `/tokens/${deployedToken}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body).toStrictEqual({ + l2Address: deployedToken, + l1Address: null, + symbol: Token.customL2TokenSymbol, + name: Token.customL2TokenName, + decimals: Token.customL2TokenDecimals, + }) + ); + }); + }); +}); From 1c6074efe21a4fba4ed31e4cfa0319bd32801eed Mon Sep 17 00:00:00 2001 From: abilevych Date: Tue, 24 Oct 2023 15:49:11 +0300 Subject: [PATCH 02/25] test: the tokens API-related suite re-structuring --- .../tests/api/before-all/tokens.test.ts | 6 +- .../tests/api/common/tokens.test.ts | 58 ++++++++++++++++--- .../tests/api/common/transfers.test.ts | 18 ------ .../api/transactions/transaction.test.ts | 19 ------ 4 files changed, 52 insertions(+), 49 deletions(-) diff --git a/packages/integration-tests/tests/api/before-all/tokens.test.ts b/packages/integration-tests/tests/api/before-all/tokens.test.ts index 09e6c8b7d0..168f0fb396 100644 --- a/packages/integration-tests/tests/api/before-all/tokens.test.ts +++ b/packages/integration-tests/tests/api/before-all/tokens.test.ts @@ -1,9 +1,5 @@ -import * as request from "supertest"; -import { setTimeout } from "timers/promises"; - -import { environment } from "../../../src/config"; import { localConfig } from "../../../src/config"; -import { Logger, Token } from "../../../src/entities"; +import { Logger } from "../../../src/entities"; import { Playbook } from "../../../src/playbook/playbook"; describe("Tokens", () => { diff --git a/packages/integration-tests/tests/api/common/tokens.test.ts b/packages/integration-tests/tests/api/common/tokens.test.ts index 8684fab6a1..a1781456d5 100644 --- a/packages/integration-tests/tests/api/common/tokens.test.ts +++ b/packages/integration-tests/tests/api/common/tokens.test.ts @@ -3,18 +3,21 @@ import { setTimeout } from "timers/promises"; import { environment } from "../../../src/config"; import { localConfig } from "../../../src/config"; -import { Buffer, Token } from "../../../src/entities"; +import { Buffer, Token, TransactionsType, Wallets } from "../../../src/entities"; import { Helper } from "../../../src/helper"; +import { Playbook } from "../../../src/playbook/playbook"; describe("Tokens", () => { jest.setTimeout(localConfig.standardTimeout); const helper = new Helper(); + const playbook = new Playbook(); const bufferFile = "src/playbook/"; - let deployedToken: string; + let l2Token: string; + let txHash: string; beforeAll(async () => { - deployedToken = await helper.getStringFromFile(bufferFile + Buffer.L2); + l2Token = await helper.getStringFromFile(bufferFile + Buffer.L2); }); describe("/tokens", () => { @@ -22,8 +25,6 @@ describe("Tokens", () => { it("Verify the response via /tokens", async () => { const l2DepositedToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); const l1Token = await helper.getStringFromFile(bufferFile + Buffer.L1); - const l2Token = deployedToken; - const apiRoute = `/tokens`; await setTimeout(localConfig.standardPause); //works unstable without timeout @@ -58,15 +59,16 @@ describe("Tokens", () => { describe("/tokens/{tokenAddress}", () => { //@id1456 it("Verify deployed to L2 custom token via /tokens/{tokenAddress}", async () => { + const apiRoute = `/tokens/${l2Token}`; + await setTimeout(localConfig.extendedPause); //works unstable without timeout - const apiRoute = `/tokens/${deployedToken}`; return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) .expect((res) => expect(res.body).toStrictEqual({ - l2Address: deployedToken, + l2Address: l2Token, l1Address: null, symbol: Token.customL2TokenSymbol, name: Token.customL2TokenName, @@ -75,4 +77,46 @@ describe("Tokens", () => { ); }); }); + describe("/tokens/{address}/transfers", () => { + //@id1448 + it("Verify the custom ERC20 token transfer via /tokens/{address}/transfers", async () => { + const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; + const txHash = await playbook.transferERC20("0.01", l2Token, "L2"); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[0].amount).toBe("10000000000000000")) + .expect((res) => expect(res.body.items[0].from).toBe(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.items[0].to).toBe(Wallets.secondWalletAddress)) + .expect((res) => expect(res.body.items[0].token).toEqual(expect.objectContaining({ l2Address: l2Token }))) + .expect((res) => expect(res.body.items[0]).toEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toEqual(expect.objectContaining({ type: "transfer" }))); + }); + + //@id1451 + it("Verify the custom token includes paymaster transaction", async () => { + l2Token = await helper.getStringFromFile(bufferFile + Buffer.customToken); + const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); + const paymaster = await helper.getStringFromFile(bufferFile + Buffer.paymaster); + txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); + + const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: paymaster }))) + .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ l2Address: l2Token }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ); + }); + }); }); diff --git a/packages/integration-tests/tests/api/common/transfers.test.ts b/packages/integration-tests/tests/api/common/transfers.test.ts index 2f4bb9b1d0..474fc977a5 100644 --- a/packages/integration-tests/tests/api/common/transfers.test.ts +++ b/packages/integration-tests/tests/api/common/transfers.test.ts @@ -38,22 +38,4 @@ describe("Transfer", () => { .expect((res) => expect(res.body.items[1].amount).toBe("1000000000000")) .expect((res) => expect(res.body.items[1].type).toBe("transfer")); }); - - //@id1448 - it("Verify the custom ERC20 token transfer via /tokens/{address}/transfers", async () => { - const apiRoute = `/tokens/${token}/transfers?page=1&limit=10`; - token = await helper.getStringFromFile(bufferFile); - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[0].amount).toBe("10000000000000000")) - .expect((res) => expect(res.body.items[0].from).toBe(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.items[0].to).toBe(Wallets.secondWalletAddress)) - .expect((res) => expect(res.body.items[0].token).toEqual(expect.objectContaining({ l2Address: token }))) - .expect((res) => expect(res.body.items[0]).toEqual(expect.objectContaining({ transactionHash: txHashCust }))) - .expect((res) => expect(res.body.items[0]).toEqual(expect.objectContaining({ type: "transfer" }))); - }); }); diff --git a/packages/integration-tests/tests/api/transactions/transaction.test.ts b/packages/integration-tests/tests/api/transactions/transaction.test.ts index c8431a49b7..94f98a3869 100644 --- a/packages/integration-tests/tests/api/transactions/transaction.test.ts +++ b/packages/integration-tests/tests/api/transactions/transaction.test.ts @@ -37,25 +37,6 @@ describe("Transactions", () => { expect(result).toContain(Logger.txHashStartsWith); }); - //@id1451 - it("Verify the custom token includes paymaster transaction", async () => { - const paymaster = await helper.getStringFromFile(bufferRoute + Buffer.paymaster); - const apiRoute = `/tokens/${token}/transfers?page=1&limit=10`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: paymaster }))) - .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ l2Address: token }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ); - }); - //@id1452 it("Verify transaction through Paymaster", async () => { const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; From bacb018ed1d63df6a02931f7e25729fe6e045876 Mon Sep 17 00:00:00 2001 From: abilevych Date: Wed, 25 Oct 2023 11:55:58 +0300 Subject: [PATCH 03/25] test: the address API-related suite re-structuring --- .../endpoints/address-endpoints.test.ts | 238 ++++++++++++++++++ .../tokens-endpoints.test.ts} | 10 +- .../tests/api/common/nft.test.ts | 24 -- .../tests/api/transactions/multiCall.test.ts | 60 ----- .../api/transactions/multiTransfer.test.ts | 15 -- .../api/transactions/transaction.test.ts | 117 --------- 6 files changed, 243 insertions(+), 221 deletions(-) create mode 100644 packages/integration-tests/tests/api/common/endpoints/address-endpoints.test.ts rename packages/integration-tests/tests/api/common/{tokens.test.ts => endpoints/tokens-endpoints.test.ts} (96%) diff --git a/packages/integration-tests/tests/api/common/endpoints/address-endpoints.test.ts b/packages/integration-tests/tests/api/common/endpoints/address-endpoints.test.ts new file mode 100644 index 0000000000..d49af7dcb6 --- /dev/null +++ b/packages/integration-tests/tests/api/common/endpoints/address-endpoints.test.ts @@ -0,0 +1,238 @@ +import * as request from "supertest"; +import { setTimeout } from "timers/promises"; + +import { environment } from "../../../../src/config"; +import { localConfig } from "../../../../src/config"; +import { Buffer, Token, Wallets } from "../../../../src/entities"; +import { Helper } from "../../../../src/helper"; + +describe("Address", () => { + jest.setTimeout(localConfig.standardTimeout); + + const helper = new Helper(); + const bufferFile = "src/playbook/"; + let token: string; + let contract: string; + let txHash: string; + + describe("/address/{address}", () => { + //@id1457 + it("Verify deployed to L2 NFT via /address/{address}", async () => { + token = await helper.getStringFromFile(bufferFile + Buffer.NFTtoL2); + + await setTimeout(localConfig.extendedPause); + const apiRoute = `/address/${token}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body).toEqual( + expect.objectContaining({ + type: "contract", + address: token, + balances: { + [`${token}`]: { + balance: "1", + token: null, + }, + }, + }) + ) + ); + }); + + //@id1464 + it("Verify the deployed Root contract via /address/{address}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallRoot); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); + + const apiRoute = `/address/${contract}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ type: "contract" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) + .expect((res) => + expect(res.body).toStrictEqual(expect.objectContaining({ creatorAddress: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ creatorTxHash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ balances: {} }))); + }); + + //@id1465 + it("Verify the deployed Middle contract via /address/{address}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallMiddle); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + + const apiRoute = `/address/${contract}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ type: "contract" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) + .expect((res) => + expect(res.body).toStrictEqual(expect.objectContaining({ creatorAddress: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ creatorTxHash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ balances: {} }))); + }); + + //@id1466 + it("Verify the deployed Caller contract via /address/{address}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallCaller); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); + + const apiRoute = `/address/${contract}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ type: "contract" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) + .expect((res) => + expect(res.body).toStrictEqual(expect.objectContaining({ creatorAddress: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ creatorTxHash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ balances: {} }))); + }); + + //@id1476 + it("Verify the deployed multitransfer contract via /address/{address}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + const apiRoute = `/address/${contract}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) + .expect((res) => + expect(res.body).toStrictEqual(expect.objectContaining({ creatorAddress: Wallets.richWalletAddress })) + ); + }); + + //@id1449 + it("Verify the deployed Greeter contract via /address/{address}", async () => { + const apiRoute = `/address/${contract}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ balances: {} }))); + }); + }); + + describe("/address/{address}/logs", () => { + //@id1510 + it("Verify the transaction via /address/{address}/logs", async () => { + contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); + txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); + + const apiRoute = `/address/${contract}/logs`; + const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ address: contract }))) + .expect((res) => expect(Array.isArray(res.body.items[0].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[0].data).toStrictEqual("string")) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[0].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[0].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 1 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 1 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) + .expect((res) => + expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) + ) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) + .expect((res) => + expect(res.body.links).toStrictEqual( + expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) + ) + ); + }); + }); + + describe("/address/{address}/logs", () => { + //@id1509 + it("Verify the transaction via /address/{address}/transfers", async () => { + contract = await helper.getStringFromFile(bufferFile + Buffer.paymaster); + const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); + txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); + + const customTokenAddress = await helper.getStringFromFile(bufferFile + Buffer.customToken); + const apiRoute = `/address/${contract}/transfers`; + const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ amount: "1" }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: customTokenAddress })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ l2Address: customTokenAddress })) + ) + .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ l1Address: null }))) + .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ symbol: "MyToken" }))) + .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ name: "MyToken" }))) + .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ decimals: 18 }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(typeof res.body.items[1].timestamp).toStrictEqual("string")) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "30000000000000000" })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 2 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 2 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) + .expect((res) => + expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) + ) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) + .expect((res) => + expect(res.body.links).toStrictEqual( + expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) + ) + ); + }); + }); +}); diff --git a/packages/integration-tests/tests/api/common/tokens.test.ts b/packages/integration-tests/tests/api/common/endpoints/tokens-endpoints.test.ts similarity index 96% rename from packages/integration-tests/tests/api/common/tokens.test.ts rename to packages/integration-tests/tests/api/common/endpoints/tokens-endpoints.test.ts index a1781456d5..b1709b56ca 100644 --- a/packages/integration-tests/tests/api/common/tokens.test.ts +++ b/packages/integration-tests/tests/api/common/endpoints/tokens-endpoints.test.ts @@ -1,11 +1,11 @@ import * as request from "supertest"; import { setTimeout } from "timers/promises"; -import { environment } from "../../../src/config"; -import { localConfig } from "../../../src/config"; -import { Buffer, Token, TransactionsType, Wallets } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; +import { environment } from "../../../../src/config"; +import { localConfig } from "../../../../src/config"; +import { Buffer, Token, TransactionsType, Wallets } from "../../../../src/entities"; +import { Helper } from "../../../../src/helper"; +import { Playbook } from "../../../../src/playbook/playbook"; describe("Tokens", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/common/nft.test.ts b/packages/integration-tests/tests/api/common/nft.test.ts index ed6271a478..f9bb62f6d3 100644 --- a/packages/integration-tests/tests/api/common/nft.test.ts +++ b/packages/integration-tests/tests/api/common/nft.test.ts @@ -26,29 +26,5 @@ describe("NFTs", () => { deployedToken = await playbook.deployNFTtoL2(); expect(deployedToken).toContain(Logger.txHashStartsWith); }); - - //@id1457 - it("Verify deployed to L2 NFT via /address/{address}", async () => { - await setTimeout(localConfig.extendedPause); - const apiRoute = `/address/${deployedToken}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body).toEqual( - expect.objectContaining({ - type: "contract", - address: deployedToken, - balances: { - [`${deployedToken}`]: { - balance: "1", - token: null, - }, - }, - }) - ) - ); - }); }); }); diff --git a/packages/integration-tests/tests/api/transactions/multiCall.test.ts b/packages/integration-tests/tests/api/transactions/multiCall.test.ts index 310a5fea9b..f6d4ac9020 100644 --- a/packages/integration-tests/tests/api/transactions/multiCall.test.ts +++ b/packages/integration-tests/tests/api/transactions/multiCall.test.ts @@ -23,66 +23,6 @@ describe("Multicall transactions", () => { expect(contract[2]).toContain(Logger.txHashStartsWith); }); - //@id1464 - it("Verify the deployed Root contract via /address/{address}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - contract = await helper.getStringFromFile(bufferRoute + Buffer.addressMultiCallRoot); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiCallRoot); - - const apiRoute = `/address/${contract}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ type: "contract" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) - .expect((res) => - expect(res.body).toStrictEqual(expect.objectContaining({ creatorAddress: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ creatorTxHash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ balances: {} }))); - }); - - //@id1465 - it("Verify the deployed Middle contract via /address/{address}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - contract = await helper.getStringFromFile(bufferRoute + Buffer.addressMultiCallMiddle); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiCallMiddle); - - const apiRoute = `/address/${contract}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ type: "contract" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) - .expect((res) => - expect(res.body).toStrictEqual(expect.objectContaining({ creatorAddress: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ creatorTxHash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ balances: {} }))); - }); - - //@id1466 - it("Verify the deployed Caller contract via /address/{address}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - contract = await helper.getStringFromFile(bufferRoute + Buffer.addressMultiCallCaller); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiCallCaller); - - const apiRoute = `/address/${contract}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ type: "contract" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) - .expect((res) => - expect(res.body).toStrictEqual(expect.objectContaining({ creatorAddress: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ creatorTxHash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ balances: {} }))); - }); - //@id690:I --> @id1467 it("Use the multicall contracts", async () => { txMulticall = await playbook.useMultiCallContracts(); diff --git a/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts b/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts index 7bdde1c14f..2b996f2e05 100644 --- a/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts +++ b/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts @@ -26,21 +26,6 @@ describe("Mulitransfer ETH", () => { expect(contract).toContain(Logger.txHashStartsWith); }); - //@id1476 - it("Verify the deployed multitransfer contract via /address/{address}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - const apiRoute = `/address/${contract}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) - .expect((res) => - expect(res.body).toStrictEqual(expect.objectContaining({ creatorAddress: Wallets.richWalletAddress })) - ); - }); - //@id690 --> //@id1477 it("Call the multitransfer contract to the L2", async () => { txMultiTransfer = await playbook.useMultiTransferETH(); diff --git a/packages/integration-tests/tests/api/transactions/transaction.test.ts b/packages/integration-tests/tests/api/transactions/transaction.test.ts index 94f98a3869..dc39338d0e 100644 --- a/packages/integration-tests/tests/api/transactions/transaction.test.ts +++ b/packages/integration-tests/tests/api/transactions/transaction.test.ts @@ -135,19 +135,6 @@ describe("Transactions", () => { expect(contract).toContain(Logger.txHashStartsWith); }); - //@id1449 - it("Verify the deployed Greeter contract via /address/{address}", async () => { - const apiRoute = `/address/${contract}`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ address: contract }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ balances: {} }))); - }); - //@id604 it("Use the Greeter contract - execute SetGreeting", async () => { const executedContract = await playbook.useGreeter(); @@ -210,110 +197,6 @@ describe("Transactions", () => { }); }); - describe("Transactions for the /address/{address} endpoints", () => { - jest.setTimeout(localConfig.extendedTimeout); - - //@id1510 - it("Verify the transaction via /address/{address}/logs", async () => { - contract = await helper.getStringFromFile(bufferRoute + Buffer.greeterL2); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.executeGreeterTx); - - const apiRoute = `/address/${contract}/logs`; - const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ address: contract }))) - .expect((res) => expect(Array.isArray(res.body.items[0].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[0].data).toStrictEqual("string")) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[0].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[0].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 1 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 1 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) - .expect((res) => - expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) - ) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) - .expect((res) => - expect(res.body.links).toStrictEqual( - expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) - ) - ); - }); - - //@id1509 - it("Verify the transaction via /address/{address}/transfers", async () => { - contract = await helper.getStringFromFile(bufferRoute + Buffer.paymaster); - emptyWallet = await helper.getStringFromFile(bufferRoute + Buffer.emptyWalletAddress); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.paymasterTx); - - const customTokenAddress = await helper.getStringFromFile(bufferRoute + Buffer.customToken); - const apiRoute = `/address/${contract}/transfers`; - const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ amount: "1" }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: customTokenAddress })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ l2Address: customTokenAddress })) - ) - .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ l1Address: null }))) - .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ symbol: "MyToken" }))) - .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ name: "MyToken" }))) - .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ decimals: 18 }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(typeof res.body.items[1].timestamp).toStrictEqual("string")) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "30000000000000000" })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 2 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 2 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) - .expect((res) => - expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) - ) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) - .expect((res) => - expect(res.body.links).toStrictEqual( - expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) - ) - ); - }); - }); describe("Transactions for the /transactions endpoint", () => { jest.setTimeout(localConfig.extendedTimeout); From 38723b1627f9d89bf7716bbfa73729af370373cf Mon Sep 17 00:00:00 2001 From: abilevych Date: Thu, 26 Oct 2023 17:07:59 +0300 Subject: [PATCH 04/25] test: the transaction API-related suite re-structuring --- packages/integration-tests/src/config.ts | 4 +- packages/integration-tests/src/entities.ts | 2 + .../scenarios/transfers/transferERC20.ts | 6 +- .../scenarios/transfers/transferETH.ts | 6 +- .../endpoints/transactions-endpoints.test.ts | 984 ++++++++++++++++++ .../tests/api/common/transfers.test.ts | 15 - .../tests/api/common/withdrawal.test.ts | 288 ----- .../tests/api/transactions/multiCall.test.ts | 242 ----- .../api/transactions/multiTransfer.test.ts | 255 ----- .../api/transactions/transaction.test.ts | 216 ---- 10 files changed, 998 insertions(+), 1020 deletions(-) create mode 100644 packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts diff --git a/packages/integration-tests/src/config.ts b/packages/integration-tests/src/config.ts index 543bdd9509..ca7034d8ec 100644 --- a/packages/integration-tests/src/config.ts +++ b/packages/integration-tests/src/config.ts @@ -1,8 +1,8 @@ import { Wallets } from "./entities"; export const localConfig = { - gasLimit: { gasLimit: 8000000 }, - l2GasLimit: 8000000, + gasLimit: { gasLimit: 10000000 }, + l2GasLimit: 10000000, L1Network: "http://localhost:8545", L2Network: "http://localhost:3050", privateKey: Wallets.richWalletPrivateKey, diff --git a/packages/integration-tests/src/entities.ts b/packages/integration-tests/src/entities.ts index f0f4d545c5..07697620fa 100644 --- a/packages/integration-tests/src/entities.ts +++ b/packages/integration-tests/src/entities.ts @@ -19,6 +19,8 @@ export enum Buffer { txMultiCallCaller = "./buffer/txMultiCallCaller.txt", txMultiCallRoot = "./buffer/txmultiCallRoot.txt", txUseMultiCallContracts = "./buffer/txUseMultiCallContracts.txt", + txEthTransfer = "./buffer/txEthTransfer.txt", + txERC20Transfer = "./buffer/txERC20Transfer.txt", emptyWalletPrivateKey = "./buffer/emptyWalletPrivateKey.txt", emptyWalletAddress = "./buffer/emptyWalletAddress.txt", failedState = "./buffer/failedState.txt", diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts b/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts index 44316badf4..13a1ab0ed3 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/transferERC20.ts @@ -1,8 +1,9 @@ import * as ethers from "ethers"; +import { promises as fs } from "fs"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Logger, Wallets } from "../../../entities"; +import { Buffer, Logger, Wallets } from "../../../entities"; import { Helper } from "../../../helper"; export const transferERC20 = async function (sum: string, tokenAddress: string, tokenName?: string /*, units = 18*/) { @@ -11,6 +12,8 @@ export const transferERC20 = async function (sum: string, tokenAddress: string, const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const syncWallet2 = new zksync.Wallet(Wallets.secondWalletPrivateKey, syncProvider, ethProvider); + const playbookRoot = "src/playbook/"; + const bufferFile = playbookRoot + Buffer.txEthTransfer; const transfer = await syncWallet.transfer({ to: syncWallet2.address, @@ -21,6 +24,7 @@ export const transferERC20 = async function (sum: string, tokenAddress: string, const txHash = transfer.hash; await helper.txHashLogger(Logger.transfer, txHash, tokenName); + await fs.writeFile(bufferFile, txHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts b/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts index b6d801eb97..fdd21c6e51 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/transferETH.ts @@ -1,8 +1,9 @@ import * as ethers from "ethers"; +import { promises as fs } from "fs"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Logger, Wallets } from "../../../entities"; +import { Buffer, Logger, Wallets } from "../../../entities"; import { Helper } from "../../../helper"; export const transferEth = async function (sum = "0.000009", address: string = Wallets.mainWalletPrivateKey) { @@ -11,6 +12,8 @@ export const transferEth = async function (sum = "0.000009", address: string = W const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const syncWallet2 = new zksync.Wallet(address, syncProvider, ethProvider); + const playbookRoot = "src/playbook/"; + const bufferFile = playbookRoot + Buffer.txEthTransfer; const transfer = await syncWallet.transfer({ to: syncWallet2.address, @@ -20,6 +23,7 @@ export const transferEth = async function (sum = "0.000009", address: string = W const txHash = transfer.hash; await helper.txHashLogger(Logger.transfer, txHash, "ETH"); + await fs.writeFile(bufferFile, txHash); return txHash; }; diff --git a/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts b/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts new file mode 100644 index 0000000000..ea2e1ee046 --- /dev/null +++ b/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts @@ -0,0 +1,984 @@ +import * as request from "supertest"; +import { setTimeout } from "timers/promises"; + +import { environment } from "../../../../src/config"; +import { localConfig } from "../../../../src/config"; +import { Buffer, Token, TransactionsStatus, TransactionsType, Wallets } from "../../../../src/entities"; +import { Helper } from "../../../../src/helper"; +import { Playbook } from "../../../../src/playbook/playbook"; + +describe("Transactions", () => { + jest.setTimeout(localConfig.extendedTimeout); + + const helper = new Helper(); + const bufferFile = "src/playbook/"; + const playbook = new Playbook(); + + let contract: any; + let token: string; + let txHash: any; + + //@id1447 + it("Verify transfer ETH L2-L2 via /transactions/{transactionHash}/transfers", async () => { + txHash = await playbook.transferETH("0.000001"); + const apiRoute = `/transactions/${txHash}/transfers`; + await setTimeout(localConfig.standardPause); + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[1].from).toBe(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.items[1].to).toBe(Wallets.mainWalletAddress)) + .expect((res) => expect(res.body.items[1].transactionHash).toBe(txHash)) + .expect((res) => expect(res.body.items[1].amount).toBe("1000000000000")) + .expect((res) => expect(res.body.items[1].type).toBe("transfer")); + }); + + //@id1459 + it("Verify the ETH withdrawal via /transactions/{transactionHash}/transfers", async () => { + txHash = await playbook.withdrawETH(); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/transactions/${txHash}/transfers`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); + }); + + //@id1460 + it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}", async () => { + txHash = await playbook.withdrawETHtoOtherAddress(); + await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.hash).toBe(txHash)) + .expect((res) => expect(res.body.to).toBe("0x000000000000000000000000000000000000800A")) + .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.value).toBe("9000000000000")); + }); + + //@id1461 + it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}/transfers", async () => { + txHash = await playbook.withdrawETHtoOtherAddress(); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/transactions/${txHash}/transfers`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.mainWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); + }); + + //@id1462 + it("Verify the custom token withdrawal via /transactions/{transactionHash}", async () => { + token = bufferFile + "/" + Buffer.L2deposited; + const customToken = await helper.getStringFromFile(token); + txHash = await playbook.withdrawERC20(customToken); + await setTimeout(localConfig.standardPause); //works unstable without timeout + + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.hash).toBe(txHash)) + .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)); + }); + + //@id1463 + it("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { + token = bufferFile + "/" + Buffer.L2deposited; + const l1Token = bufferFile + "/" + Buffer.L1; + const customTokenL2 = await helper.getStringFromFile(token); + const customTokenL1 = await helper.getStringFromFile(l1Token); + txHash = await playbook.withdrawERC20(customTokenL2); + const apiRoute = `/transactions/${txHash}/transfers`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_Address }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: customTokenL2, + l1Address: customTokenL1, + symbol: "L1", + name: "L1 ERC20 token", + decimals: 18, + }, + }) + ) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: customTokenL2, + l1Address: customTokenL1, + symbol: "L1", + name: "L1 ERC20 token", + decimals: 18, + }, + }) + ) + ) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); + }); + + //@id1458 + it("Verify the ETH withdrawal via /transactions/{transactionHash}", async () => { + txHash = await playbook.withdrawETH(); + const apiRoute = `/transactions/${txHash}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.hash).toBe(txHash)) + .expect((res) => expect(res.body.to).toBe("0x000000000000000000000000000000000000800A")) + .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.value).toBe("9000000000000")); + }); + + //@id1507 + it("Verify the transaction via /transactions/{transactionHash}/logs", async () => { + contract = await playbook.deployGreeterToL2(); + txHash = await playbook.useGreeter(); + + const apiRoute = `/transactions/${txHash}/logs`; + const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(Array.isArray(res.body.items[0].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[0].data).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.items[0].blockNumber).toStrictEqual("number")) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[0].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[0].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ address: contract }))) + .expect((res) => expect(Array.isArray(res.body.items[1].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[1].data).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.items[1].blockNumber).toStrictEqual("number")) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[1].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[1].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[1].timestamp).toStrictEqual("string")) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(Array.isArray(res.body.items[2].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[2].data).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.items[2].blockNumber).toStrictEqual("number")) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[2].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[2].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[2].timestamp).toStrictEqual("string")) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 3 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 3 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) + .expect((res) => + expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) + ) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) + .expect((res) => + expect(res.body.links).toStrictEqual( + expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) + ) + ); + }); + + // //@id1478 + it("Verify transaction for the ETH via /transactions/${txHash}", async () => { + // txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferETH); + contract = await playbook.deployMultiTransferETH(); + txHash = await playbook.useMultiTransferETH(); + const apiRoute = `/transactions/${txHash[0]}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash[0] }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); + }); + + //@id1479 + it("Verify transaction for the Custom Token I via /transactions/${txHash}", async () => { + contract = await playbook.deployERC20toL2(); + txHash = await playbook.useMultiTransferETH(); + const apiRoute = `/transactions/${txHash[1]}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash[1] }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); + }); + + //@id1480 + it("Verify transaction for the Custom Token II via /transactions/${txHash}", async () => { + token = await playbook.deployERC20toL1(); + await setTimeout(0.9 * 1000); + await playbook.depositERC20("100", token, 18); + await setTimeout(0.9 * 1000); + contract = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + txHash = await playbook.useMultiTransferETH(); + txHash = txHash[2]; + const apiRoute = `/transactions/${txHash}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); + }); + + //@id1481 + it("Verify transaction for the ETH via /transactions/${txHash}/transfers", async () => { + contract = await playbook.deployMultiTransferETH(); + txHash = await playbook.useMultiTransferETH(); + txHash = txHash[0]; + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1482 + it("Verify transaction for the Custom tokenI via /transactions/${txHash}/transfers", async () => { + token = await playbook.deployERC20toL2(); + contract = await playbook.deployMultiTransferETH(); + txHash = await playbook.useMultiTransferETH(); + txHash = txHash[1]; + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: token, + l1Address: null, + symbol: "L2", + name: "L2 ERC20 token", + decimals: 18, + }, + }) + ) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1483 + it("Verify transaction for the Custom tokenII via /transactions/${txHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + const tokenL1 = await playbook.deployERC20toL1(); + await setTimeout(0.9 * 1000); + await playbook.depositERC20("100", tokenL1, 18); + await setTimeout(0.9 * 1000); + token = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + contract = await playbook.deployMultiTransferETH(); + await setTimeout(0.9 * 1000); + txHash = await playbook.useMultiTransferETH(); + txHash = txHash[2]; + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: token, + l1Address: tokenL1, + symbol: "L1", + name: "L1 ERC20 token", + decimals: 18, + }, + }) + ) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1452 + it("Verify transaction through Paymaster", async () => { + // const paymasterAddress = await helper.getStringFromFile(bufferFile + Buffer.paymaster); + await playbook.deployViaPaymaster(); + const paymasterAddress = await helper.getStringFromFile(bufferFile + Buffer.paymaster); + const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); + token = await helper.getStringFromFile(bufferFile + Buffer.customToken); + txHash = await playbook.usePaymaster(); + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: paymasterAddress }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ amount: "1" }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: token, + l1Address: null, + symbol: "MyToken", + name: "MyToken", + decimals: 18, + }, + }) + ) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: paymasterAddress }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: paymasterAddress }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1455 + it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}/transfers", async () => { + await playbook.deployGreeterToL2(); + txHash = await playbook.useGreeter(); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1454 + it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}", async () => { + contract = await playbook.deployGreeterToL2(); + txHash = await playbook.useGreeter(); + const apiRoute = `/transactions/${txHash}?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); + }); + + //@id1506 + it("Verify the transaction via /transactions", async () => { + contract = await playbook.deployGreeterToL2(); + txHash = await playbook.useGreeter(); + + const apiRoute = `/transactions`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) + .expect((res) => expect(res.body.items.length).toBe(10)) + .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); + }); + + // describe("Verify the multicall transactions via /transactions/${txHash}/transfers", () => { + //@id1472 + it("Verify transaction for the Root contract via /transactions/${txHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + contract = await playbook.deployMultiCallContracts(); + contract = contract[0]; + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1473 + it("Verify transaction for the Middle contract via /transactions/${txHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + contract = await playbook.deployMultiCallContracts(); + contract = contract[1]; + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1474 + it("Verify transaction for the Caller contract via /transactions/${txHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + contract = await playbook.deployMultiCallContracts(); + contract = contract[2]; + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1475 + it("Verify transaction for the use multicall contract via /transactions/${txHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + // }); + // + // describe("Verify the multicall transactions via /transactions/${txHash}", () => { + //@id1464:I --> @id1468 + it("Verify transaction for the Root contract via /transactions/${txHash}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); + }); + + //@id1465:I --> @id1469 + it("Verify transaction for the Middle contract via /transactions/${txHash}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); + }); + + //@id1466:I --> @id1470 + it("Verify transaction for the Caller contract via /transactions/${txHash}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); + + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); + }); + + //@id1471 + it("Verify transaction for the use multicall contract via /transactions/${txHash}", async () => { + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + + txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); + const apiRoute = `/transactions/${txHash}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); + }); + // }); + // + //@id645 + it("Verify the transactions with failed state", async () => { + token = await playbook.deployERC20toL2(); + txHash = await playbook.transferFailedState(token); + + const apiRoute = `/transactions/${txHash}?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.from).toStrictEqual(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.to).toStrictEqual(token)) + .expect((res) => expect(res.body.hash).toStrictEqual(txHash)) + .expect((res) => expect(res.body.status).toStrictEqual(TransactionsStatus.failed)); + }); +}); diff --git a/packages/integration-tests/tests/api/common/transfers.test.ts b/packages/integration-tests/tests/api/common/transfers.test.ts index 474fc977a5..24506578a4 100644 --- a/packages/integration-tests/tests/api/common/transfers.test.ts +++ b/packages/integration-tests/tests/api/common/transfers.test.ts @@ -23,19 +23,4 @@ describe("Transfer", () => { return [txHashCust, txHashEth]; }); - - //@id1447 - it("Verify transfer ETH L2-L2 via /transactions/{transactionHash}/transfers", async () => { - const apiRoute = `/transactions/${txHashEth}/transfers`; - await setTimeout(localConfig.standardPause); - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[1].from).toBe(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.items[1].to).toBe(Wallets.mainWalletAddress)) - .expect((res) => expect(res.body.items[1].transactionHash).toBe(txHashEth)) - .expect((res) => expect(res.body.items[1].amount).toBe("1000000000000")) - .expect((res) => expect(res.body.items[1].type).toBe("transfer")); - }); }); diff --git a/packages/integration-tests/tests/api/common/withdrawal.test.ts b/packages/integration-tests/tests/api/common/withdrawal.test.ts index 68e716b0ee..77166fb294 100644 --- a/packages/integration-tests/tests/api/common/withdrawal.test.ts +++ b/packages/integration-tests/tests/api/common/withdrawal.test.ts @@ -24,64 +24,6 @@ describe("Withdrawal", () => { await expect(result).not.toBeUndefined(); await expect(result.includes(Logger.txHashStartsWith)).toBe(true); }); - - //@id1458 - it("Verify the ETH withdrawal via /transactions/{transactionHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${result}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.hash).toBe(result)) - .expect((res) => expect(res.body.to).toBe("0x000000000000000000000000000000000000800A")) - .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.value).toBe("9000000000000")); - }); - - //@id1459 - it("Verify the ETH withdrawal via /transactions/{transactionHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${result}/transfers`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); - }); }); describe("Withdrawal ETH to the other address", () => { @@ -91,64 +33,6 @@ describe("Withdrawal", () => { await expect(result).not.toBeUndefined(); await expect(result.includes(Logger.txHashStartsWith)).toBe(true); }); - - //@id1460 - it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${result}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.hash).toBe(result)) - .expect((res) => expect(res.body.to).toBe("0x000000000000000000000000000000000000800A")) - .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.value).toBe("9000000000000")); - }); - - //@id1461 - it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${result}/transfers`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.mainWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); - }); }); describe("Withdrawal the custom token to the own address", () => { @@ -159,92 +43,6 @@ describe("Withdrawal", () => { await expect(result).not.toBeUndefined(); await expect(result.includes(Logger.txHashStartsWith)).toBe(true); }); - - //@id1462 - it("Verify the custom token withdrawal via /transactions/{transactionHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${result}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.hash).toBe(result)) - .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)); - }); - - //@id1463 - it("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - const customTokenL2 = await helper.getStringFromFile(l2Token); - const customTokenL1 = await helper.getStringFromFile(l1Token); - const apiRoute = `/transactions/${result}/transfers`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_Address }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: customTokenL2, - l1Address: customTokenL1, - symbol: "L1", - name: "L1 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: customTokenL2, - l1Address: customTokenL1, - symbol: "L1", - name: "L1 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); - }); }); describe("Withdrawal the custom token to the other address", () => { @@ -255,91 +53,5 @@ describe("Withdrawal", () => { await expect(result).not.toBeUndefined(); await expect(result.includes(Logger.txHashStartsWith)).toBe(true); }); - - //@id1462 - it("Verify the custom token withdrawal via /transactions/{transactionHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${result}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.hash).toBe(result)) - .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)); - }); - - //@id1463 - it("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - const customTokenL2 = await helper.getStringFromFile(l2Token); - const customTokenL1 = await helper.getStringFromFile(l1Token); - const apiRoute = `/transactions/${result}/transfers`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_Address }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: customTokenL2, - l1Address: customTokenL1, - symbol: "L1", - name: "L1 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.mainWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: customTokenL2, - l1Address: customTokenL1, - symbol: "L1", - name: "L1 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: result }))) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); - }); }); }); diff --git a/packages/integration-tests/tests/api/transactions/multiCall.test.ts b/packages/integration-tests/tests/api/transactions/multiCall.test.ts index f6d4ac9020..c9340815ac 100644 --- a/packages/integration-tests/tests/api/transactions/multiCall.test.ts +++ b/packages/integration-tests/tests/api/transactions/multiCall.test.ts @@ -28,246 +28,4 @@ describe("Multicall transactions", () => { txMulticall = await playbook.useMultiCallContracts(); expect(txMulticall).toContain(Logger.txHashStartsWith); }); - - describe("Verify the multicall transactions via /transactions/${txHash}", () => { - //@id1464:I --> @id1468 - it("Verify transaction for the Root contract via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiCallRoot); - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); - }); - - //@id1465:I --> @id1469 - it("Verify transaction for the Middle contract via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiCallMiddle); - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); - }); - - //@id1466:I --> @id1470 - it("Verify transaction for the Caller contract via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiCallCaller); - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); - }); - - //@id1471 - it("Verify transaction for the use multicall contract via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txUseMultiCallContracts); - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); - }); - }); - - describe("Verify the multicall transactions via /transactions/${txHash}/transfers", () => { - //@id1472 - it("Verify transaction for the Root contract via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiCallRoot); - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1473 - it("Verify transaction for the Middle contract via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiCallMiddle); - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1474 - it("Verify transaction for the Caller contract via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiCallCaller); - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1475 - it("Verify transaction for the use multicall contract via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txUseMultiCallContracts); - - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - }); }); diff --git a/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts b/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts index 2b996f2e05..9cb847b665 100644 --- a/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts +++ b/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts @@ -33,259 +33,4 @@ describe("Mulitransfer ETH", () => { expect(txMultiTransfer[1]).toContain(Logger.txHashStartsWith); expect(txMultiTransfer[2]).toContain(Logger.txHashStartsWith); }); - - describe("Verify the multitransfer transactions via /transactions/${txHash}", () => { - //@id1478 - it("Verify transaction for the ETH via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiTransferETH); - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); - }); - - //@id1479 - it("Verify transaction for the Custom Token I via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiTransferCustomTokenI); - contract = await helper.getStringFromFile(bufferRoute + Buffer.L2); - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); - }); - - //@id1480 - it("Verify transaction for the Custom Token II via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiTransferCustomTokenII); - contract = await helper.getStringFromFile(bufferRoute + Buffer.L2deposited); - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); - }); - }); - - describe("Verify the multitransfer transactions via /transactions/${txHash}/transfer", () => { - beforeAll(async () => { - token = await helper.getStringFromFile(bufferRoute + Buffer.L2); - }); - - //@id1481 - it("Verify transaction for the ETH via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiTransferETH); - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1482 - it("Verify transaction for the Custom tokenI via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - contract = await helper.getStringFromFile(bufferRoute + Buffer.addressMultiTransferETH); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiTransferCustomTokenI); - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: token, - l1Address: null, - symbol: "L2", - name: "L2 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1483 - it("Verify transaction for the Custom tokenII via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - const tokenL1 = await helper.getStringFromFile(bufferRoute + Buffer.L1); - token = await helper.getStringFromFile(bufferRoute + Buffer.L2deposited); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.txMultiTransferCustomTokenII); - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - return ( - request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual( - expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address }) - ) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash })) - ) - // .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: token, - l1Address: tokenL1, - symbol: "L1", - name: "L1 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual( - expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address }) - ) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))) - ); - }); - }); }); diff --git a/packages/integration-tests/tests/api/transactions/transaction.test.ts b/packages/integration-tests/tests/api/transactions/transaction.test.ts index dc39338d0e..3a2bfc13d6 100644 --- a/packages/integration-tests/tests/api/transactions/transaction.test.ts +++ b/packages/integration-tests/tests/api/transactions/transaction.test.ts @@ -36,65 +36,6 @@ describe("Transactions", () => { const result = await playbook.usePaymaster(); expect(result).toContain(Logger.txHashStartsWith); }); - - //@id1452 - it("Verify transaction through Paymaster", async () => { - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - const paymasterAddress = await helper.getStringFromFile(bufferRoute + Buffer.paymaster); - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: paymasterAddress }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: token, - l1Address: null, - symbol: "MyToken", - name: "MyToken", - decimals: 18, - }, - }) - ) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: paymasterAddress }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: paymasterAddress }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); - }); }); describe("Transaction with failed state", () => { @@ -104,21 +45,6 @@ describe("Transactions", () => { txHash = await playbook.transferFailedState(token); return [txHash, token]; }); - - //@id645 - it("Verify the transactions with failed state", async () => { - const apiRoute = `/transactions/${txHash}?page=1&limit=10`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.from).toStrictEqual(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.to).toStrictEqual(token)) - .expect((res) => expect(res.body.hash).toStrictEqual(txHash)) - .expect((res) => expect(res.body.status).toStrictEqual(TransactionsStatus.failed)); - }); }); describe("Greeter", () => { @@ -140,147 +66,5 @@ describe("Transactions", () => { const executedContract = await playbook.useGreeter(); expect(executedContract).toContain(Logger.txHashStartsWith); }); - - //@id1454 - it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}", async () => { - const apiRoute = `/transactions/${txHash}?page=1&limit=10`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); - }); - - //@id1455 - it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}/transfers", async () => { - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - }); - - describe("Transactions for the /transactions endpoint", () => { - jest.setTimeout(localConfig.extendedTimeout); - - //@id1506 - it("Verify the transaction via /transactions", async () => { - contract = await helper.getStringFromFile(bufferRoute + Buffer.greeterL2); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.executeGreeterTx); - - const apiRoute = `/transactions`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) - .expect((res) => expect(res.body.items.length).toBe(10)) - .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); - }); - - //@id1507 - it("Verify the transaction via /transactions/{transactionHash}/logs", async () => { - contract = await helper.getStringFromFile(bufferRoute + Buffer.greeterL2); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.executeGreeterTx); - - const apiRoute = `/transactions/${txHash}/logs`; - const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(Array.isArray(res.body.items[0].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[0].data).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.items[0].blockNumber).toStrictEqual("number")) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[0].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[0].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ address: contract }))) - .expect((res) => expect(Array.isArray(res.body.items[1].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[1].data).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.items[1].blockNumber).toStrictEqual("number")) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[1].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[1].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[1].timestamp).toStrictEqual("string")) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(Array.isArray(res.body.items[2].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[2].data).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.items[2].blockNumber).toStrictEqual("number")) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[2].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[2].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[2].timestamp).toStrictEqual("string")) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 3 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 3 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) - .expect((res) => - expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) - ) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) - .expect((res) => - expect(res.body.links).toStrictEqual( - expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) - ) - ); - }); }); }); From f18702fcf06e07a7233ceaf2da03e4c78f31a8e4 Mon Sep 17 00:00:00 2001 From: abilevych Date: Tue, 31 Oct 2023 17:42:54 +0200 Subject: [PATCH 05/25] chore: run lint --- .../common/endpoints/transactions-endpoints.test.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts b/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts index ea2e1ee046..bfd46dbcba 100644 --- a/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts +++ b/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts @@ -309,7 +309,7 @@ describe("Transactions", () => { ); }); - // //@id1478 + //@id1478 it("Verify transaction for the ETH via /transactions/${txHash}", async () => { // txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferETH); contract = await playbook.deployMultiTransferETH(); @@ -705,7 +705,6 @@ describe("Transactions", () => { .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); }); - // describe("Verify the multicall transactions via /transactions/${txHash}/transfers", () => { //@id1472 it("Verify transaction for the Root contract via /transactions/${txHash}/transfers", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout @@ -881,9 +880,7 @@ describe("Transactions", () => { .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); }); - // }); - // - // describe("Verify the multicall transactions via /transactions/${txHash}", () => { + //@id1464:I --> @id1468 it("Verify transaction for the Root contract via /transactions/${txHash}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout @@ -962,8 +959,7 @@ describe("Transactions", () => { .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); }); - // }); - // + //@id645 it("Verify the transactions with failed state", async () => { token = await playbook.deployERC20toL2(); From d2ea0e94eeee00a39ff53b56ee18fcf3416cee51 Mon Sep 17 00:00:00 2001 From: abilevych Date: Tue, 31 Oct 2023 17:58:47 +0200 Subject: [PATCH 06/25] test: re-structure test suites for batches, stats, blocks endpoints --- .../tests/api/common/endpoints.test.ts | 146 ------------------ .../endpoints/batches-endpoints.test.ts | 60 +++++++ .../common/endpoints/blocks-endpoints.test.ts | 68 ++++++++ .../common/endpoints/stats-endpoints.test.ts | 24 +++ .../tests/api/common/nft.test.ts | 4 - .../tests/api/common/transfers.test.ts | 6 +- .../tests/api/common/withdrawal.test.ts | 6 +- .../tests/api/transactions/multiCall.test.ts | 12 +- .../api/transactions/multiTransfer.test.ts | 9 +- .../api/transactions/transaction.test.ts | 7 +- 10 files changed, 160 insertions(+), 182 deletions(-) delete mode 100644 packages/integration-tests/tests/api/common/endpoints.test.ts create mode 100644 packages/integration-tests/tests/api/common/endpoints/batches-endpoints.test.ts create mode 100644 packages/integration-tests/tests/api/common/endpoints/blocks-endpoints.test.ts create mode 100644 packages/integration-tests/tests/api/common/endpoints/stats-endpoints.test.ts diff --git a/packages/integration-tests/tests/api/common/endpoints.test.ts b/packages/integration-tests/tests/api/common/endpoints.test.ts deleted file mode 100644 index 68bfa0f3d7..0000000000 --- a/packages/integration-tests/tests/api/common/endpoints.test.ts +++ /dev/null @@ -1,146 +0,0 @@ -import * as request from "supertest"; -import { setTimeout } from "timers/promises"; - -import { environment, localConfig } from "../../../src/config"; -// import { Buffer } from "../../../src/entities"; -// import { Helper } from "../../../src/helper"; - -describe("Endpoints", () => { - // const helper = new Helper(); - // const bufferRoute = "src/playbook/"; - - jest.setTimeout(localConfig.extendedTimeout); - - describe("/stats", () => { - //@id1515 - it("Verify the response via /stats", async () => { - const apiRoute = `/stats`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(typeof res.body.lastSealedBatch).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.lastVerifiedBatch).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.lastSealedBlock).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.lastVerifiedBlock).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.totalTransactions).toStrictEqual("number")); - }); - }); - - describe("/batches", () => { - //@id1513 - it("Verify the response via /batches", async () => { - const apiRoute = `/batches`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) - .expect((res) => expect(res.body.items.length).toBeGreaterThanOrEqual(1)) - .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); - }); - - //@id1514 - it("Verify the response via /batches/{batchNumber}", async () => { - const batches = await request(environment.blockExplorerAPI).get("/batches"); - - const batchNumber = batches.body.items[0].number; - - const apiRoute = `/batches/${batchNumber}`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.number).toStrictEqual(batchNumber)) - .expect((res) => expect(typeof res.body.timestamp).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.rootHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.executedAt).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.l1TxCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.l2TxCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.commitTxHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.committedAt).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.proveTxHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.provenAt).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.executeTxHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.l1GasPrice).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.l2FairGasPrice).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.size).toStrictEqual("number")) - .expect((res) => expect(res.body.status).toStrictEqual("verified")); - }); - }); - - describe("/blocks", () => { - //@id1511 - it("Verify the response via /blocks", async () => { - const apiRoute = `/blocks`; - - await setTimeout(localConfig.extendedPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) - .expect((res) => expect(res.body.items.length).toBeGreaterThan(1)) - .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); - }); - - //@id1512 - it("Verify the response via /blocks/{/blockNumber}", async () => { - const blocks = await request(environment.blockExplorerAPI).get("/blocks"); - - const blockNumber = blocks.body.items[0].number; - - const apiRoute = `/blocks/${blockNumber}`; - - await setTimeout(localConfig.extendedPause); //works unstable without timeout - - return ( - request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.number).toStrictEqual(blockNumber)) - .expect((res) => expect(typeof res.body.hash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.timestamp).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.gasUsed).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.l1BatchNumber).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.l1TxCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.l2TxCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.parentHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.gasLimit).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.baseFeePerGas).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.extraData).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.size).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.status).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.isL1BatchSealed).toStrictEqual("boolean")) - .expect((res) => expect(typeof res.body.commitTxHash).toStrictEqual("string")) - // .expect((res) => expect(typeof res.body.commitTxHash).toStrictEqual("string")) //unstable on a CI - .expect((res) => expect(typeof res.body.proveTxHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.committedAt).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.executedAt).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.provenAt).toStrictEqual("string")) - ); - }); - }); -}); diff --git a/packages/integration-tests/tests/api/common/endpoints/batches-endpoints.test.ts b/packages/integration-tests/tests/api/common/endpoints/batches-endpoints.test.ts new file mode 100644 index 0000000000..6df7c124e8 --- /dev/null +++ b/packages/integration-tests/tests/api/common/endpoints/batches-endpoints.test.ts @@ -0,0 +1,60 @@ +import * as request from "supertest"; +import { setTimeout } from "timers/promises"; + +import { environment } from "../../../../src/config"; +import { localConfig } from "../../../../src/config"; + +describe("/batches", () => { + jest.setTimeout(localConfig.standardTimeout); + //@id1513 + it("Verify the response via /batches", async () => { + const apiRoute = `/batches`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) + .expect((res) => expect(res.body.items.length).toBeGreaterThanOrEqual(1)) + .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); + }); + + //@id1514 + it("Verify the response via /batches/{batchNumber}", async () => { + const batches = await request(environment.blockExplorerAPI).get("/batches"); + + const batchNumber = batches.body.items[0].number; + + const apiRoute = `/batches/${batchNumber}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.number).toStrictEqual(batchNumber)) + .expect((res) => expect(typeof res.body.timestamp).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.rootHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.executedAt).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.l1TxCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.l2TxCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.commitTxHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.committedAt).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.proveTxHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.provenAt).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.executeTxHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.l1GasPrice).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.l2FairGasPrice).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.size).toStrictEqual("number")) + .expect((res) => expect(res.body.status).toStrictEqual("verified")); + }); +}); diff --git a/packages/integration-tests/tests/api/common/endpoints/blocks-endpoints.test.ts b/packages/integration-tests/tests/api/common/endpoints/blocks-endpoints.test.ts new file mode 100644 index 0000000000..36b6404a4a --- /dev/null +++ b/packages/integration-tests/tests/api/common/endpoints/blocks-endpoints.test.ts @@ -0,0 +1,68 @@ +import * as request from "supertest"; +import { setTimeout } from "timers/promises"; + +import { environment } from "../../../../src/config"; +import { localConfig } from "../../../../src/config"; + +describe("/blocks", () => { + jest.setTimeout(localConfig.standardTimeout); + + //@id1511 + it("Verify the response via /blocks", async () => { + const apiRoute = `/blocks`; + + await setTimeout(localConfig.extendedPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) + .expect((res) => expect(res.body.items.length).toBeGreaterThan(1)) + .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); + }); + + //@id1512 + it("Verify the response via /blocks/{/blockNumber}", async () => { + const blocks = await request(environment.blockExplorerAPI).get("/blocks"); + + const blockNumber = blocks.body.items[0].number; + + const apiRoute = `/blocks/${blockNumber}`; + + await setTimeout(localConfig.extendedPause); //works unstable without timeout + + return ( + request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.number).toStrictEqual(blockNumber)) + .expect((res) => expect(typeof res.body.hash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.timestamp).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.gasUsed).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.l1BatchNumber).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.l1TxCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.l2TxCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.parentHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.gasLimit).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.baseFeePerGas).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.extraData).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.size).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.status).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.isL1BatchSealed).toStrictEqual("boolean")) + .expect((res) => expect(typeof res.body.commitTxHash).toStrictEqual("string")) + // .expect((res) => expect(typeof res.body.commitTxHash).toStrictEqual("string")) //unstable on a CI + .expect((res) => expect(typeof res.body.proveTxHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.committedAt).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.executedAt).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.provenAt).toStrictEqual("string")) + ); + }); +}); diff --git a/packages/integration-tests/tests/api/common/endpoints/stats-endpoints.test.ts b/packages/integration-tests/tests/api/common/endpoints/stats-endpoints.test.ts new file mode 100644 index 0000000000..e47a9e5483 --- /dev/null +++ b/packages/integration-tests/tests/api/common/endpoints/stats-endpoints.test.ts @@ -0,0 +1,24 @@ +import * as request from "supertest"; +import { setTimeout } from "timers/promises"; + +import { environment } from "../../../../src/config"; +import { localConfig } from "../../../../src/config"; + +describe("/stats", () => { + jest.setTimeout(localConfig.standardTimeout); + //@id1515 + it("Verify the response via /stats", async () => { + const apiRoute = `/stats`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(typeof res.body.lastSealedBatch).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.lastVerifiedBatch).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.lastSealedBlock).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.lastVerifiedBlock).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.totalTransactions).toStrictEqual("number")); + }); +}); diff --git a/packages/integration-tests/tests/api/common/nft.test.ts b/packages/integration-tests/tests/api/common/nft.test.ts index f9bb62f6d3..a8b3b3786d 100644 --- a/packages/integration-tests/tests/api/common/nft.test.ts +++ b/packages/integration-tests/tests/api/common/nft.test.ts @@ -1,7 +1,3 @@ -import * as request from "supertest"; -import { setTimeout } from "timers/promises"; - -import { environment } from "../../../src/config"; import { localConfig } from "../../../src/config"; import { Logger } from "../../../src/entities"; import { Playbook } from "../../../src/playbook/playbook"; diff --git a/packages/integration-tests/tests/api/common/transfers.test.ts b/packages/integration-tests/tests/api/common/transfers.test.ts index 24506578a4..0c12904c57 100644 --- a/packages/integration-tests/tests/api/common/transfers.test.ts +++ b/packages/integration-tests/tests/api/common/transfers.test.ts @@ -1,9 +1,5 @@ -import * as request from "supertest"; -import { setTimeout } from "timers/promises"; - -import { environment } from "../../../src/config"; import { localConfig } from "../../../src/config"; -import { Buffer, Wallets } from "../../../src/entities"; +import { Buffer } from "../../../src/entities"; import { Helper } from "../../../src/helper"; import { Playbook } from "../../../src/playbook/playbook"; diff --git a/packages/integration-tests/tests/api/common/withdrawal.test.ts b/packages/integration-tests/tests/api/common/withdrawal.test.ts index 77166fb294..dc8ada4576 100644 --- a/packages/integration-tests/tests/api/common/withdrawal.test.ts +++ b/packages/integration-tests/tests/api/common/withdrawal.test.ts @@ -1,7 +1,4 @@ -import * as request from "supertest"; -import { setTimeout } from "timers/promises"; - -import { environment, localConfig } from "../../../src/config"; +import { localConfig } from "../../../src/config"; import { Buffer, Token, Wallets } from "../../../src/entities"; import { Logger } from "../../../src/entities"; import { Helper } from "../../../src/helper"; @@ -12,7 +9,6 @@ describe("Withdrawal", () => { const helper = new Helper(); const playbookRoot = "src/playbook"; const l2Token = playbookRoot + "/" + Buffer.L2deposited; - const l1Token = playbookRoot + "/" + Buffer.L1; let result: string; jest.setTimeout(localConfig.extendedTimeout); diff --git a/packages/integration-tests/tests/api/transactions/multiCall.test.ts b/packages/integration-tests/tests/api/transactions/multiCall.test.ts index c9340815ac..c09d9e251b 100644 --- a/packages/integration-tests/tests/api/transactions/multiCall.test.ts +++ b/packages/integration-tests/tests/api/transactions/multiCall.test.ts @@ -1,19 +1,11 @@ -import * as request from "supertest"; -import { setTimeout } from "timers/promises"; - -import { environment, localConfig } from "../../../src/config"; -import { Buffer, Logger, Token, TransactionsType, Wallets } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; +import { localConfig } from "../../../src/config"; +import { Logger } from "../../../src/entities"; import { Playbook } from "../../../src/playbook/playbook"; describe("Multicall transactions", () => { jest.setTimeout(localConfig.extendedTimeout); const playbook = new Playbook(); - const helper = new Helper(); - const bufferRoute = "src/playbook/"; - let txHash: string; let txMulticall: string; - let contract: string; //@id689 it("Deploy the Multicall contracts", async () => { diff --git a/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts b/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts index 9cb847b665..d7ca2a0780 100644 --- a/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts +++ b/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts @@ -1,8 +1,5 @@ -import * as request from "supertest"; -import { setTimeout } from "timers/promises"; - -import { environment, localConfig } from "../../../src/config"; -import { Buffer, Logger, Token, TransactionsType, Wallets } from "../../../src/entities"; +import { localConfig } from "../../../src/config"; +import { Buffer, Logger } from "../../../src/entities"; import { Helper } from "../../../src/helper"; import { Playbook } from "../../../src/playbook/playbook"; @@ -11,9 +8,7 @@ describe("Mulitransfer ETH", () => { const playbook = new Playbook(); const helper = new Helper(); const bufferRoute = "src/playbook/"; - let txHash: string; let txMultiTransfer: string[]; - let token: string; let contract: string; beforeEach(async () => { diff --git a/packages/integration-tests/tests/api/transactions/transaction.test.ts b/packages/integration-tests/tests/api/transactions/transaction.test.ts index 3a2bfc13d6..3a78954376 100644 --- a/packages/integration-tests/tests/api/transactions/transaction.test.ts +++ b/packages/integration-tests/tests/api/transactions/transaction.test.ts @@ -1,8 +1,5 @@ -import * as request from "supertest"; -import { setTimeout } from "timers/promises"; - -import { environment, localConfig } from "../../../src/config"; -import { Buffer, Logger, Token, TransactionsStatus, TransactionsType, Wallets } from "../../../src/entities"; +import { localConfig } from "../../../src/config"; +import { Buffer, Logger } from "../../../src/entities"; import { Helper } from "../../../src/helper"; import { Playbook } from "../../../src/playbook/playbook"; From 1730a712973f855f76cb6f869a4748adc517d3bb Mon Sep 17 00:00:00 2001 From: abilevych Date: Wed, 1 Nov 2023 17:15:15 +0200 Subject: [PATCH 07/25] chore: group the SDK-related test suites as pre-requisites --- .../tests/api/common/{ => pre-requisites}/nft.test.ts | 6 +++--- .../pre-requisites}/transactions/multiCall.test.ts | 6 +++--- .../pre-requisites}/transactions/multiTransfer.test.ts | 8 ++++---- .../pre-requisites}/transactions/transaction.test.ts | 8 ++++---- .../api/common/{ => pre-requisites}/transfers.test.ts | 8 ++++---- .../api/common/{ => pre-requisites}/withdrawal.test.ts | 10 +++++----- 6 files changed, 23 insertions(+), 23 deletions(-) rename packages/integration-tests/tests/api/common/{ => pre-requisites}/nft.test.ts (78%) rename packages/integration-tests/tests/api/{ => common/pre-requisites}/transactions/multiCall.test.ts (79%) rename packages/integration-tests/tests/api/{ => common/pre-requisites}/transactions/multiTransfer.test.ts (79%) rename packages/integration-tests/tests/api/{ => common/pre-requisites}/transactions/transaction.test.ts (89%) rename packages/integration-tests/tests/api/common/{ => pre-requisites}/transfers.test.ts (70%) rename packages/integration-tests/tests/api/common/{ => pre-requisites}/withdrawal.test.ts (86%) diff --git a/packages/integration-tests/tests/api/common/nft.test.ts b/packages/integration-tests/tests/api/common/pre-requisites/nft.test.ts similarity index 78% rename from packages/integration-tests/tests/api/common/nft.test.ts rename to packages/integration-tests/tests/api/common/pre-requisites/nft.test.ts index a8b3b3786d..54256f6ac6 100644 --- a/packages/integration-tests/tests/api/common/nft.test.ts +++ b/packages/integration-tests/tests/api/common/pre-requisites/nft.test.ts @@ -1,6 +1,6 @@ -import { localConfig } from "../../../src/config"; -import { Logger } from "../../../src/entities"; -import { Playbook } from "../../../src/playbook/playbook"; +import { localConfig } from "../../../../src/config"; +import { Logger } from "../../../../src/entities"; +import { Playbook } from "../../../../src/playbook/playbook"; describe("NFTs", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/transactions/multiCall.test.ts b/packages/integration-tests/tests/api/common/pre-requisites/transactions/multiCall.test.ts similarity index 79% rename from packages/integration-tests/tests/api/transactions/multiCall.test.ts rename to packages/integration-tests/tests/api/common/pre-requisites/transactions/multiCall.test.ts index c09d9e251b..001565ec17 100644 --- a/packages/integration-tests/tests/api/transactions/multiCall.test.ts +++ b/packages/integration-tests/tests/api/common/pre-requisites/transactions/multiCall.test.ts @@ -1,6 +1,6 @@ -import { localConfig } from "../../../src/config"; -import { Logger } from "../../../src/entities"; -import { Playbook } from "../../../src/playbook/playbook"; +import { localConfig } from "../../../../../src/config"; +import { Logger } from "../../../../../src/entities"; +import { Playbook } from "../../../../../src/playbook/playbook"; describe("Multicall transactions", () => { jest.setTimeout(localConfig.extendedTimeout); diff --git a/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts b/packages/integration-tests/tests/api/common/pre-requisites/transactions/multiTransfer.test.ts similarity index 79% rename from packages/integration-tests/tests/api/transactions/multiTransfer.test.ts rename to packages/integration-tests/tests/api/common/pre-requisites/transactions/multiTransfer.test.ts index d7ca2a0780..a04549b7d5 100644 --- a/packages/integration-tests/tests/api/transactions/multiTransfer.test.ts +++ b/packages/integration-tests/tests/api/common/pre-requisites/transactions/multiTransfer.test.ts @@ -1,7 +1,7 @@ -import { localConfig } from "../../../src/config"; -import { Buffer, Logger } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; +import { localConfig } from "../../../../../src/config"; +import { Buffer, Logger } from "../../../../../src/entities"; +import { Helper } from "../../../../../src/helper"; +import { Playbook } from "../../../../../src/playbook/playbook"; describe("Mulitransfer ETH", () => { jest.setTimeout(localConfig.extendedTimeout); diff --git a/packages/integration-tests/tests/api/transactions/transaction.test.ts b/packages/integration-tests/tests/api/common/pre-requisites/transactions/transaction.test.ts similarity index 89% rename from packages/integration-tests/tests/api/transactions/transaction.test.ts rename to packages/integration-tests/tests/api/common/pre-requisites/transactions/transaction.test.ts index 3a78954376..b2b523edd8 100644 --- a/packages/integration-tests/tests/api/transactions/transaction.test.ts +++ b/packages/integration-tests/tests/api/common/pre-requisites/transactions/transaction.test.ts @@ -1,7 +1,7 @@ -import { localConfig } from "../../../src/config"; -import { Buffer, Logger } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; +import { localConfig } from "../../../../../src/config"; +import { Buffer, Logger } from "../../../../../src/entities"; +import { Helper } from "../../../../../src/helper"; +import { Playbook } from "../../../../../src/playbook/playbook"; describe("Transactions", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/common/transfers.test.ts b/packages/integration-tests/tests/api/common/pre-requisites/transfers.test.ts similarity index 70% rename from packages/integration-tests/tests/api/common/transfers.test.ts rename to packages/integration-tests/tests/api/common/pre-requisites/transfers.test.ts index 0c12904c57..af267dc970 100644 --- a/packages/integration-tests/tests/api/common/transfers.test.ts +++ b/packages/integration-tests/tests/api/common/pre-requisites/transfers.test.ts @@ -1,7 +1,7 @@ -import { localConfig } from "../../../src/config"; -import { Buffer } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; +import { localConfig } from "../../../../src/config"; +import { Buffer } from "../../../../src/entities"; +import { Helper } from "../../../../src/helper"; +import { Playbook } from "../../../../src/playbook/playbook"; describe("Transfer", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/common/withdrawal.test.ts b/packages/integration-tests/tests/api/common/pre-requisites/withdrawal.test.ts similarity index 86% rename from packages/integration-tests/tests/api/common/withdrawal.test.ts rename to packages/integration-tests/tests/api/common/pre-requisites/withdrawal.test.ts index dc8ada4576..71f2fea000 100644 --- a/packages/integration-tests/tests/api/common/withdrawal.test.ts +++ b/packages/integration-tests/tests/api/common/pre-requisites/withdrawal.test.ts @@ -1,8 +1,8 @@ -import { localConfig } from "../../../src/config"; -import { Buffer, Token, Wallets } from "../../../src/entities"; -import { Logger } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; +import { localConfig } from "../../../../src/config"; +import { Buffer, Token, Wallets } from "../../../../src/entities"; +import { Logger } from "../../../../src/entities"; +import { Helper } from "../../../../src/helper"; +import { Playbook } from "../../../../src/playbook/playbook"; describe("Withdrawal", () => { const playbook = new Playbook(); From ca9e597a0ef5eedb6cfdd51791da182e61923a7c Mon Sep 17 00:00:00 2001 From: abilevych Date: Wed, 1 Nov 2023 18:19:41 +0200 Subject: [PATCH 08/25] chore: hooks / aligning tests suites --- packages/integration-tests/package.json | 1 + ...ss-endpoints.test.ts => addresses.test.ts} | 10 +- ...ches-endpoints.test.ts => batches.test.ts} | 4 +- .../tests/api/before-all/tokens.test.ts | 25 - ...locks-endpoints.test.ts => blocks.test.ts} | 4 +- .../endpoints/transactions-endpoints.test.ts | 980 ---------------- .../stats-endpoints.test.ts => stats.test.ts} | 4 +- ...okens-endpoints.test.ts => tokens.test.ts} | 86 +- .../tests/api/transactions.test.ts | 1004 +++++++++++++++++ .../deposit.test.ts => hooks/global.test.ts} | 31 +- .../local}/multiCall.test.ts | 6 +- .../local}/multiTransfer.test.ts | 8 +- .../local}/nft.test.ts | 6 +- .../local}/transaction.test.ts | 8 +- .../local}/transfers.test.ts | 8 +- .../local}/withdrawal.test.ts | 10 +- 16 files changed, 1109 insertions(+), 1086 deletions(-) rename packages/integration-tests/tests/api/{common/endpoints/address-endpoints.test.ts => addresses.test.ts} (97%) rename packages/integration-tests/tests/api/{common/endpoints/batches-endpoints.test.ts => batches.test.ts} (96%) delete mode 100644 packages/integration-tests/tests/api/before-all/tokens.test.ts rename packages/integration-tests/tests/api/{common/endpoints/blocks-endpoints.test.ts => blocks.test.ts} (97%) delete mode 100644 packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts rename packages/integration-tests/tests/api/{common/endpoints/stats-endpoints.test.ts => stats.test.ts} (89%) rename packages/integration-tests/tests/api/{common/endpoints/tokens-endpoints.test.ts => tokens.test.ts} (57%) create mode 100644 packages/integration-tests/tests/api/transactions.test.ts rename packages/integration-tests/tests/{api/before-all/deposit.test.ts => hooks/global.test.ts} (50%) rename packages/integration-tests/tests/{api/common/pre-requisites/transactions => hooks/local}/multiCall.test.ts (79%) rename packages/integration-tests/tests/{api/common/pre-requisites/transactions => hooks/local}/multiTransfer.test.ts (79%) rename packages/integration-tests/tests/{api/common/pre-requisites => hooks/local}/nft.test.ts (78%) rename packages/integration-tests/tests/{api/common/pre-requisites/transactions => hooks/local}/transaction.test.ts (89%) rename packages/integration-tests/tests/{api/common/pre-requisites => hooks/local}/transfers.test.ts (70%) rename packages/integration-tests/tests/{api/common/pre-requisites => hooks/local}/withdrawal.test.ts (86%) diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index 71f17b519a..044ab18274 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -10,6 +10,7 @@ "scripts": { "postinstall": "cd src/playbook && npm install", "integration-test:api": "jest --verbose --testPathPattern=tokens.test.ts && jest --verbose --testPathPattern=deposit.test.ts && jest --verbose --testPathPattern=common && jest --verbose --testPathPattern=transactions", + "hooks:global": "jest --verbose --testPathPattern=global.test.ts", "integration-test:ui": "npx playwright test", "block-explorer:start": "docker-compose up", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-pattern 'repos' --ignore-pattern 'git add .'" diff --git a/packages/integration-tests/tests/api/common/endpoints/address-endpoints.test.ts b/packages/integration-tests/tests/api/addresses.test.ts similarity index 97% rename from packages/integration-tests/tests/api/common/endpoints/address-endpoints.test.ts rename to packages/integration-tests/tests/api/addresses.test.ts index d49af7dcb6..10e11cf6e4 100644 --- a/packages/integration-tests/tests/api/common/endpoints/address-endpoints.test.ts +++ b/packages/integration-tests/tests/api/addresses.test.ts @@ -1,10 +1,10 @@ import * as request from "supertest"; import { setTimeout } from "timers/promises"; -import { environment } from "../../../../src/config"; -import { localConfig } from "../../../../src/config"; -import { Buffer, Token, Wallets } from "../../../../src/entities"; -import { Helper } from "../../../../src/helper"; +import { environment } from "../../src/config"; +import { localConfig } from "../../src/config"; +import { Buffer, Token, Wallets } from "../../src/entities"; +import { Helper } from "../../src/helper"; describe("Address", () => { jest.setTimeout(localConfig.standardTimeout); @@ -170,7 +170,7 @@ describe("Address", () => { }); }); - describe("/address/{address}/logs", () => { + describe("/address/{address}/transfers", () => { //@id1509 it("Verify the transaction via /address/{address}/transfers", async () => { contract = await helper.getStringFromFile(bufferFile + Buffer.paymaster); diff --git a/packages/integration-tests/tests/api/common/endpoints/batches-endpoints.test.ts b/packages/integration-tests/tests/api/batches.test.ts similarity index 96% rename from packages/integration-tests/tests/api/common/endpoints/batches-endpoints.test.ts rename to packages/integration-tests/tests/api/batches.test.ts index 6df7c124e8..867020bed1 100644 --- a/packages/integration-tests/tests/api/common/endpoints/batches-endpoints.test.ts +++ b/packages/integration-tests/tests/api/batches.test.ts @@ -1,8 +1,8 @@ import * as request from "supertest"; import { setTimeout } from "timers/promises"; -import { environment } from "../../../../src/config"; -import { localConfig } from "../../../../src/config"; +import { environment } from "../../src/config"; +import { localConfig } from "../../src/config"; describe("/batches", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/before-all/tokens.test.ts b/packages/integration-tests/tests/api/before-all/tokens.test.ts deleted file mode 100644 index 168f0fb396..0000000000 --- a/packages/integration-tests/tests/api/before-all/tokens.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { localConfig } from "../../../src/config"; -import { Logger } from "../../../src/entities"; -import { Playbook } from "../../../src/playbook/playbook"; - -describe("Tokens", () => { - jest.setTimeout(localConfig.standardTimeout); - - let deployedToken: string; - - describe("Deploy/check the custom ERC20 tokens", () => { - const playbook = new Playbook(); - - //@id603 - it("Deploy custom ERC20 token to L2", async () => { - deployedToken = await playbook.deployERC20toL2(); - expect(deployedToken).toContain(Logger.txHashStartsWith); - }); - - //@id657 - it("Deploy custom ERC20 token to L1", async () => { - deployedToken = await playbook.deployERC20toL1(); - expect(deployedToken).toContain(Logger.txHashStartsWith); - }); - }); -}); diff --git a/packages/integration-tests/tests/api/common/endpoints/blocks-endpoints.test.ts b/packages/integration-tests/tests/api/blocks.test.ts similarity index 97% rename from packages/integration-tests/tests/api/common/endpoints/blocks-endpoints.test.ts rename to packages/integration-tests/tests/api/blocks.test.ts index 36b6404a4a..c29f16caa5 100644 --- a/packages/integration-tests/tests/api/common/endpoints/blocks-endpoints.test.ts +++ b/packages/integration-tests/tests/api/blocks.test.ts @@ -1,8 +1,8 @@ import * as request from "supertest"; import { setTimeout } from "timers/promises"; -import { environment } from "../../../../src/config"; -import { localConfig } from "../../../../src/config"; +import { environment } from "../../src/config"; +import { localConfig } from "../../src/config"; describe("/blocks", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts b/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts deleted file mode 100644 index bfd46dbcba..0000000000 --- a/packages/integration-tests/tests/api/common/endpoints/transactions-endpoints.test.ts +++ /dev/null @@ -1,980 +0,0 @@ -import * as request from "supertest"; -import { setTimeout } from "timers/promises"; - -import { environment } from "../../../../src/config"; -import { localConfig } from "../../../../src/config"; -import { Buffer, Token, TransactionsStatus, TransactionsType, Wallets } from "../../../../src/entities"; -import { Helper } from "../../../../src/helper"; -import { Playbook } from "../../../../src/playbook/playbook"; - -describe("Transactions", () => { - jest.setTimeout(localConfig.extendedTimeout); - - const helper = new Helper(); - const bufferFile = "src/playbook/"; - const playbook = new Playbook(); - - let contract: any; - let token: string; - let txHash: any; - - //@id1447 - it("Verify transfer ETH L2-L2 via /transactions/{transactionHash}/transfers", async () => { - txHash = await playbook.transferETH("0.000001"); - const apiRoute = `/transactions/${txHash}/transfers`; - await setTimeout(localConfig.standardPause); - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[1].from).toBe(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.items[1].to).toBe(Wallets.mainWalletAddress)) - .expect((res) => expect(res.body.items[1].transactionHash).toBe(txHash)) - .expect((res) => expect(res.body.items[1].amount).toBe("1000000000000")) - .expect((res) => expect(res.body.items[1].type).toBe("transfer")); - }); - - //@id1459 - it("Verify the ETH withdrawal via /transactions/{transactionHash}/transfers", async () => { - txHash = await playbook.withdrawETH(); - - await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${txHash}/transfers`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); - }); - - //@id1460 - it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}", async () => { - txHash = await playbook.withdrawETHtoOtherAddress(); - await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.hash).toBe(txHash)) - .expect((res) => expect(res.body.to).toBe("0x000000000000000000000000000000000000800A")) - .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.value).toBe("9000000000000")); - }); - - //@id1461 - it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}/transfers", async () => { - txHash = await playbook.withdrawETHtoOtherAddress(); - - await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${txHash}/transfers`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.mainWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); - }); - - //@id1462 - it("Verify the custom token withdrawal via /transactions/{transactionHash}", async () => { - token = bufferFile + "/" + Buffer.L2deposited; - const customToken = await helper.getStringFromFile(token); - txHash = await playbook.withdrawERC20(customToken); - await setTimeout(localConfig.standardPause); //works unstable without timeout - - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.hash).toBe(txHash)) - .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)); - }); - - //@id1463 - it("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { - token = bufferFile + "/" + Buffer.L2deposited; - const l1Token = bufferFile + "/" + Buffer.L1; - const customTokenL2 = await helper.getStringFromFile(token); - const customTokenL1 = await helper.getStringFromFile(l1Token); - txHash = await playbook.withdrawERC20(customTokenL2); - const apiRoute = `/transactions/${txHash}/transfers`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_Address }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: customTokenL2, - l1Address: customTokenL1, - symbol: "L1", - name: "L1 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: customTokenL2, - l1Address: customTokenL1, - symbol: "L1", - name: "L1 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); - }); - - //@id1458 - it("Verify the ETH withdrawal via /transactions/{transactionHash}", async () => { - txHash = await playbook.withdrawETH(); - const apiRoute = `/transactions/${txHash}`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.hash).toBe(txHash)) - .expect((res) => expect(res.body.to).toBe("0x000000000000000000000000000000000000800A")) - .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.value).toBe("9000000000000")); - }); - - //@id1507 - it("Verify the transaction via /transactions/{transactionHash}/logs", async () => { - contract = await playbook.deployGreeterToL2(); - txHash = await playbook.useGreeter(); - - const apiRoute = `/transactions/${txHash}/logs`; - const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(Array.isArray(res.body.items[0].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[0].data).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.items[0].blockNumber).toStrictEqual("number")) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[0].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[0].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ address: contract }))) - .expect((res) => expect(Array.isArray(res.body.items[1].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[1].data).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.items[1].blockNumber).toStrictEqual("number")) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[1].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[1].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[1].timestamp).toStrictEqual("string")) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(Array.isArray(res.body.items[2].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[2].data).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.items[2].blockNumber).toStrictEqual("number")) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[2].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[2].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[2].timestamp).toStrictEqual("string")) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 3 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 3 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) - .expect((res) => - expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) - ) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) - .expect((res) => - expect(res.body.links).toStrictEqual( - expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) - ) - ); - }); - - //@id1478 - it("Verify transaction for the ETH via /transactions/${txHash}", async () => { - // txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferETH); - contract = await playbook.deployMultiTransferETH(); - txHash = await playbook.useMultiTransferETH(); - const apiRoute = `/transactions/${txHash[0]}`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash[0] }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); - }); - - //@id1479 - it("Verify transaction for the Custom Token I via /transactions/${txHash}", async () => { - contract = await playbook.deployERC20toL2(); - txHash = await playbook.useMultiTransferETH(); - const apiRoute = `/transactions/${txHash[1]}`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash[1] }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); - }); - - //@id1480 - it("Verify transaction for the Custom Token II via /transactions/${txHash}", async () => { - token = await playbook.deployERC20toL1(); - await setTimeout(0.9 * 1000); - await playbook.depositERC20("100", token, 18); - await setTimeout(0.9 * 1000); - contract = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); - txHash = await playbook.useMultiTransferETH(); - txHash = txHash[2]; - const apiRoute = `/transactions/${txHash}`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); - }); - - //@id1481 - it("Verify transaction for the ETH via /transactions/${txHash}/transfers", async () => { - contract = await playbook.deployMultiTransferETH(); - txHash = await playbook.useMultiTransferETH(); - txHash = txHash[0]; - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1482 - it("Verify transaction for the Custom tokenI via /transactions/${txHash}/transfers", async () => { - token = await playbook.deployERC20toL2(); - contract = await playbook.deployMultiTransferETH(); - txHash = await playbook.useMultiTransferETH(); - txHash = txHash[1]; - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: token, - l1Address: null, - symbol: "L2", - name: "L2 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1483 - it("Verify transaction for the Custom tokenII via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - const tokenL1 = await playbook.deployERC20toL1(); - await setTimeout(0.9 * 1000); - await playbook.depositERC20("100", tokenL1, 18); - await setTimeout(0.9 * 1000); - token = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); - contract = await playbook.deployMultiTransferETH(); - await setTimeout(0.9 * 1000); - txHash = await playbook.useMultiTransferETH(); - txHash = txHash[2]; - - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: token, - l1Address: tokenL1, - symbol: "L1", - name: "L1 ERC20 token", - decimals: 18, - }, - }) - ) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1452 - it("Verify transaction through Paymaster", async () => { - // const paymasterAddress = await helper.getStringFromFile(bufferFile + Buffer.paymaster); - await playbook.deployViaPaymaster(); - const paymasterAddress = await helper.getStringFromFile(bufferFile + Buffer.paymaster); - const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); - token = await helper.getStringFromFile(bufferFile + Buffer.customToken); - txHash = await playbook.usePaymaster(); - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: paymasterAddress }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ amount: "1" }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual( - expect.objectContaining({ - token: { - l2Address: token, - l1Address: null, - symbol: "MyToken", - name: "MyToken", - decimals: 18, - }, - }) - ) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: paymasterAddress }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: paymasterAddress }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1455 - it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}/transfers", async () => { - await playbook.deployGreeterToL2(); - txHash = await playbook.useGreeter(); - - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1454 - it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}", async () => { - contract = await playbook.deployGreeterToL2(); - txHash = await playbook.useGreeter(); - const apiRoute = `/transactions/${txHash}?page=1&limit=10`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); - }); - - //@id1506 - it("Verify the transaction via /transactions", async () => { - contract = await playbook.deployGreeterToL2(); - txHash = await playbook.useGreeter(); - - const apiRoute = `/transactions`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) - .expect((res) => expect(res.body.items.length).toBe(10)) - .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); - }); - - //@id1472 - it("Verify transaction for the Root contract via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - contract = await playbook.deployMultiCallContracts(); - contract = contract[0]; - await playbook.useMultiCallContracts(); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); - - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1473 - it("Verify transaction for the Middle contract via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - contract = await playbook.deployMultiCallContracts(); - contract = contract[1]; - await playbook.useMultiCallContracts(); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); - - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1474 - it("Verify transaction for the Caller contract via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - contract = await playbook.deployMultiCallContracts(); - contract = contract[2]; - await playbook.useMultiCallContracts(); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); - - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1475 - it("Verify transaction for the use multicall contract via /transactions/${txHash}/transfers", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); - - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) - ) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) - ) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) - ) - .expect((res) => - expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) - ) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); - }); - - //@id1464:I --> @id1468 - it("Verify transaction for the Root contract via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); - }); - - //@id1465:I --> @id1469 - it("Verify transaction for the Middle contract via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); - - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); - }); - - //@id1466:I --> @id1470 - it("Verify transaction for the Caller contract via /transactions/${txHash}", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout - - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); - - const apiRoute = `/transactions/${txHash}`; - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); - }); - - //@id1471 - it("Verify transaction for the use multicall contract via /transactions/${txHash}", async () => { - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); - - txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); - const apiRoute = `/transactions/${txHash}`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); - }); - - //@id645 - it("Verify the transactions with failed state", async () => { - token = await playbook.deployERC20toL2(); - txHash = await playbook.transferFailedState(token); - - const apiRoute = `/transactions/${txHash}?page=1&limit=10`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.from).toStrictEqual(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.to).toStrictEqual(token)) - .expect((res) => expect(res.body.hash).toStrictEqual(txHash)) - .expect((res) => expect(res.body.status).toStrictEqual(TransactionsStatus.failed)); - }); -}); diff --git a/packages/integration-tests/tests/api/common/endpoints/stats-endpoints.test.ts b/packages/integration-tests/tests/api/stats.test.ts similarity index 89% rename from packages/integration-tests/tests/api/common/endpoints/stats-endpoints.test.ts rename to packages/integration-tests/tests/api/stats.test.ts index e47a9e5483..c01ca23283 100644 --- a/packages/integration-tests/tests/api/common/endpoints/stats-endpoints.test.ts +++ b/packages/integration-tests/tests/api/stats.test.ts @@ -1,8 +1,8 @@ import * as request from "supertest"; import { setTimeout } from "timers/promises"; -import { environment } from "../../../../src/config"; -import { localConfig } from "../../../../src/config"; +import { environment } from "../../src/config"; +import { localConfig } from "../../src/config"; describe("/stats", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/common/endpoints/tokens-endpoints.test.ts b/packages/integration-tests/tests/api/tokens.test.ts similarity index 57% rename from packages/integration-tests/tests/api/common/endpoints/tokens-endpoints.test.ts rename to packages/integration-tests/tests/api/tokens.test.ts index b1709b56ca..9f7c4cc5cd 100644 --- a/packages/integration-tests/tests/api/common/endpoints/tokens-endpoints.test.ts +++ b/packages/integration-tests/tests/api/tokens.test.ts @@ -1,11 +1,11 @@ import * as request from "supertest"; import { setTimeout } from "timers/promises"; -import { environment } from "../../../../src/config"; -import { localConfig } from "../../../../src/config"; -import { Buffer, Token, TransactionsType, Wallets } from "../../../../src/entities"; -import { Helper } from "../../../../src/helper"; -import { Playbook } from "../../../../src/playbook/playbook"; +import { environment } from "../../src/config"; +import { localConfig } from "../../src/config"; +import { Buffer, Token, TransactionsType, Wallets } from "../../src/entities"; +import { Helper } from "../../src/helper"; +import { Playbook } from "../../src/playbook/playbook"; describe("Tokens", () => { jest.setTimeout(localConfig.standardTimeout); @@ -55,8 +55,6 @@ describe("Tokens", () => { .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); }); - }); - describe("/tokens/{tokenAddress}", () => { //@id1456 it("Verify deployed to L2 custom token via /tokens/{tokenAddress}", async () => { const apiRoute = `/tokens/${l2Token}`; @@ -76,47 +74,51 @@ describe("Tokens", () => { }) ); }); - }); - describe("/tokens/{address}/transfers", () => { - //@id1448 - it("Verify the custom ERC20 token transfer via /tokens/{address}/transfers", async () => { - const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; - const txHash = await playbook.transferERC20("0.01", l2Token, "L2"); + describe("/tokens/{address}/transfers", () => { + //@id1448 + it("Verify the custom ERC20 token transfer via /tokens/{address}/transfers", async () => { + const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; + const txHash = await playbook.transferERC20("0.01", l2Token, "L2"); - await setTimeout(localConfig.standardPause); //works unstable without timeout + await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[0].amount).toBe("10000000000000000")) - .expect((res) => expect(res.body.items[0].from).toBe(Wallets.richWalletAddress)) - .expect((res) => expect(res.body.items[0].to).toBe(Wallets.secondWalletAddress)) - .expect((res) => expect(res.body.items[0].token).toEqual(expect.objectContaining({ l2Address: l2Token }))) - .expect((res) => expect(res.body.items[0]).toEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(res.body.items[0]).toEqual(expect.objectContaining({ type: "transfer" }))); - }); + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[0].amount).toBe("10000000000000000")) + .expect((res) => expect(res.body.items[0].from).toBe(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.items[0].to).toBe(Wallets.secondWalletAddress)) + .expect((res) => expect(res.body.items[0].token).toEqual(expect.objectContaining({ l2Address: l2Token }))) + .expect((res) => expect(res.body.items[0]).toEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toEqual(expect.objectContaining({ type: "transfer" }))); + }); - //@id1451 - it("Verify the custom token includes paymaster transaction", async () => { - l2Token = await helper.getStringFromFile(bufferFile + Buffer.customToken); - const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); - const paymaster = await helper.getStringFromFile(bufferFile + Buffer.paymaster); - txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); + //@id1451 + it("Verify the custom token includes paymaster transaction via /tokens/{address}/transfers", async () => { + l2Token = await helper.getStringFromFile(bufferFile + Buffer.customToken); + const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); + const paymaster = await helper.getStringFromFile(bufferFile + Buffer.paymaster); + txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); - const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; + const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout + await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: paymaster }))) - .expect((res) => expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ l2Address: l2Token }))) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) - ); + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: paymaster }))) + .expect((res) => + expect(res.body.items[0].token).toStrictEqual(expect.objectContaining({ l2Address: l2Token })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ); + }); }); }); }); diff --git a/packages/integration-tests/tests/api/transactions.test.ts b/packages/integration-tests/tests/api/transactions.test.ts new file mode 100644 index 0000000000..16a39b4105 --- /dev/null +++ b/packages/integration-tests/tests/api/transactions.test.ts @@ -0,0 +1,1004 @@ +import * as request from "supertest"; +import { setTimeout } from "timers/promises"; + +import { environment } from "../../src/config"; +import { localConfig } from "../../src/config"; +import { Buffer, Token, TransactionsStatus, TransactionsType, Wallets } from "../../src/entities"; +import { Helper } from "../../src/helper"; +import { Playbook } from "../../src/playbook/playbook"; + +describe("Transactions", () => { + jest.setTimeout(localConfig.extendedTimeout); + + const helper = new Helper(); + const bufferFile = "src/playbook/"; + const playbook = new Playbook(); + + let contract: any; + let token: string; + let txHash: any; + + describe("/transactions/{transactionHash}/transfers", () => { + //@id1447 + it("Verify transfer ETH L2-L2 via /transactions/{transactionHash}/transfers", async () => { + txHash = await playbook.transferETH("0.000001"); + const apiRoute = `/transactions/${txHash}/transfers`; + await setTimeout(localConfig.standardPause); + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[1].from).toBe(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.items[1].to).toBe(Wallets.mainWalletAddress)) + .expect((res) => expect(res.body.items[1].transactionHash).toBe(txHash)) + .expect((res) => expect(res.body.items[1].amount).toBe("1000000000000")) + .expect((res) => expect(res.body.items[1].type).toBe("transfer")); + }); + + //@id1459 + it("Verify the ETH withdrawal via /transactions/{transactionHash}/transfers", async () => { + txHash = await playbook.withdrawETH(); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/transactions/${txHash}/transfers`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); + }); + + //@id1461 + it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}/transfers", async () => { + txHash = await playbook.withdrawETHtoOtherAddress(); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/transactions/${txHash}/transfers`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.mainWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ amount: "9000000000000" }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); + }); + + //@id1463 + it("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { + token = bufferFile + "/" + Buffer.L2deposited; + const l1Token = bufferFile + "/" + Buffer.L1; + const customTokenL2 = await helper.getStringFromFile(token); + const customTokenL1 = await helper.getStringFromFile(l1Token); + txHash = await playbook.withdrawERC20(customTokenL2); + const apiRoute = `/transactions/${txHash}/transfers`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: "fee" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_Address }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: "transfer" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: customTokenL2, + l1Address: customTokenL1, + symbol: "L1", + name: "L1 ERC20 token", + decimals: 18, + }, + }) + ) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ amount: "200000000000000000" })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: "withdrawal" }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: customTokenL2, + l1Address: customTokenL1, + symbol: "L1", + name: "L1 ERC20 token", + decimals: 18, + }, + }) + ) + ) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); + }); + }); + + describe("/transactions/{transactionHash}", () => { + //@id1460 + it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}", async () => { + txHash = await playbook.withdrawETHtoOtherAddress(); + await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.hash).toBe(txHash)) + .expect((res) => expect(res.body.to).toBe("0x000000000000000000000000000000000000800A")) + .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.value).toBe("9000000000000")); + }); + + //@id1462 + it("Verify the custom token withdrawal via /transactions/{transactionHash}", async () => { + token = bufferFile + "/" + Buffer.L2deposited; + const customToken = await helper.getStringFromFile(token); + txHash = await playbook.withdrawERC20(customToken); + await setTimeout(localConfig.standardPause); //works unstable without timeout + + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.hash).toBe(txHash)) + .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)); + }); + + //@id1458 + it("Verify the ETH withdrawal via /transactions/{transactionHash}", async () => { + txHash = await playbook.withdrawETH(); + const apiRoute = `/transactions/${txHash}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.hash).toBe(txHash)) + .expect((res) => expect(res.body.to).toBe("0x000000000000000000000000000000000000800A")) + .expect((res) => expect(res.body.from).toBe(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.value).toBe("9000000000000")); + }); + + //@id1478 + it("Verify transaction for the ETH via /transactions/{transactionHash}", async () => { + // txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferETH); + contract = await playbook.deployMultiTransferETH(); + txHash = await playbook.useMultiTransferETH(); + const apiRoute = `/transactions/${txHash[0]}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash[0] }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); + }); + + //@id1479 + it("Verify transaction for the Custom Token I via /transactions/{transactionHash}", async () => { + contract = await playbook.deployERC20toL2(); + txHash = await playbook.useMultiTransferETH(); + const apiRoute = `/transactions/${txHash[1]}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash[1] }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); + }); + + //@id1480 + it("Verify transaction for the Custom Token II via /transactions/{transactionHash}", async () => { + token = await playbook.deployERC20toL1(); + await setTimeout(0.9 * 1000); + await playbook.depositERC20("100", token, 18); + await setTimeout(0.9 * 1000); + contract = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + txHash = await playbook.useMultiTransferETH(); + txHash = txHash[2]; + const apiRoute = `/transactions/${txHash}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); + }); + + //@id1454 + it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}", async () => { + contract = await playbook.deployGreeterToL2(); + txHash = await playbook.useGreeter(); + const apiRoute = `/transactions/${txHash}?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); + }); + + //@id1464:I --> @id1468 + it("Verify transaction for the Root contract via /transactions/{transactionHash}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); + }); + + //@id1465:I --> @id1469 + it("Verify transaction for the Middle contract via /transactions/{transactionHash}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); + }); + + //@id1466:I --> @id1470 + it("Verify transaction for the Caller contract via /transactions/{transactionHash}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); + + const apiRoute = `/transactions/${txHash}`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); + }); + + //@id1471 + it("Verify transaction for the use multicall contract via /transactions/{transactionHash}", async () => { + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + + txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); + const apiRoute = `/transactions/${txHash}`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ value: "0" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ transactionIndex: 0 }))); + }); + + //@id645 + it("Verify the transactions with failed state via /transactions/{transactionHash}", async () => { + token = await playbook.deployERC20toL2(); + txHash = await playbook.transferFailedState(token); + + const apiRoute = `/transactions/${txHash}?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.from).toStrictEqual(Wallets.richWalletAddress)) + .expect((res) => expect(res.body.to).toStrictEqual(token)) + .expect((res) => expect(res.body.hash).toStrictEqual(txHash)) + .expect((res) => expect(res.body.status).toStrictEqual(TransactionsStatus.failed)); + }); + }); + + describe("/transactions/${txHash}/transfers", () => { + //@id1481 + it("Verify transaction for the ETH via /transactions/{transactionHash}/transfers", async () => { + contract = await playbook.deployMultiTransferETH(); + txHash = await playbook.useMultiTransferETH(); + txHash = txHash[0]; + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1482 + it("Verify transaction for the Custom tokenI via /transactions/{transactionHash}/transfers", async () => { + token = await playbook.deployERC20toL2(); + contract = await playbook.deployMultiTransferETH(); + txHash = await playbook.useMultiTransferETH(); + txHash = txHash[1]; + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: token, + l1Address: null, + symbol: "L2", + name: "L2 ERC20 token", + decimals: 18, + }, + }) + ) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1483 + it("Verify transaction for the Custom tokenII via /transactions/{transactionHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + const tokenL1 = await playbook.deployERC20toL1(); + await setTimeout(0.9 * 1000); + await playbook.depositERC20("100", tokenL1, 18); + await setTimeout(0.9 * 1000); + token = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + contract = await playbook.deployMultiTransferETH(); + await setTimeout(0.9 * 1000); + txHash = await playbook.useMultiTransferETH(); + txHash = txHash[2]; + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: contract }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: token, + l1Address: tokenL1, + symbol: "L1", + name: "L1 ERC20 token", + decimals: 18, + }, + }) + ) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1452 + it("Verify transaction through Paymaster via /transactions/{transactionHash}/transfers", async () => { + // const paymasterAddress = await helper.getStringFromFile(bufferFile + Buffer.paymaster); + await playbook.deployViaPaymaster(); + const paymasterAddress = await helper.getStringFromFile(bufferFile + Buffer.paymaster); + const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); + token = await helper.getStringFromFile(bufferFile + Buffer.customToken); + txHash = await playbook.usePaymaster(); + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: emptyWallet }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: paymasterAddress }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ amount: "1" }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: token }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.transfer })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual( + expect.objectContaining({ + token: { + l2Address: token, + l1Address: null, + symbol: "MyToken", + name: "MyToken", + decimals: 18, + }, + }) + ) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: paymasterAddress }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: paymasterAddress }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1455 + it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}/transfers", async () => { + await playbook.deployGreeterToL2(); + txHash = await playbook.useGreeter(); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1472 + it("Verify transaction for the Root contract via /transactions/{transactionHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + contract = await playbook.deployMultiCallContracts(); + contract = contract[0]; + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1473 + it("Verify transaction for the Middle contract via /transactions/{transactionHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + contract = await playbook.deployMultiCallContracts(); + contract = contract[1]; + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1474 + it("Verify transaction for the Caller contract via /transactions/{transactionHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + contract = await playbook.deployMultiCallContracts(); + contract = contract[2]; + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + + //@id1475 + it("Verify transaction for the use multicall contract via /transactions/{transactionHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); + + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ to: Token.ETHER_PULL_Address })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ type: TransactionsType.fee })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ from: Token.ETHER_PULL_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + ) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ tokenAddress: Token.ETHER_ERC20_Address })) + ) + .expect((res) => + expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ type: TransactionsType.refund })) + ) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ fields: null }))) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ token: null }))); + }); + }); + + //@id1507 + it("Verify the transaction via /transactions/{transactionHash}/logs", async () => { + contract = await playbook.deployGreeterToL2(); + txHash = await playbook.useGreeter(); + + const apiRoute = `/transactions/${txHash}/logs`; + const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(Array.isArray(res.body.items[0].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[0].data).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.items[0].blockNumber).toStrictEqual("number")) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[0].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[0].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ address: contract }))) + .expect((res) => expect(Array.isArray(res.body.items[1].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[1].data).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.items[1].blockNumber).toStrictEqual("number")) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[1].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[1].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[1].timestamp).toStrictEqual("string")) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(Array.isArray(res.body.items[2].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[2].data).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.items[2].blockNumber).toStrictEqual("number")) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[2].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[2].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[2].timestamp).toStrictEqual("string")) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 3 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 3 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) + .expect((res) => + expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) + ) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) + .expect((res) => + expect(res.body.links).toStrictEqual( + expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) + ) + ); + }); + + //@id1506 + it("Verify the transaction via /transactions", async () => { + contract = await playbook.deployGreeterToL2(); + txHash = await playbook.useGreeter(); + + const apiRoute = `/transactions`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) + .expect((res) => expect(res.body.items.length).toBe(10)) + .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); + }); +}); diff --git a/packages/integration-tests/tests/api/before-all/deposit.test.ts b/packages/integration-tests/tests/hooks/global.test.ts similarity index 50% rename from packages/integration-tests/tests/api/before-all/deposit.test.ts rename to packages/integration-tests/tests/hooks/global.test.ts index daaf5367f6..02c5eaf4e1 100644 --- a/packages/integration-tests/tests/api/before-all/deposit.test.ts +++ b/packages/integration-tests/tests/hooks/global.test.ts @@ -1,8 +1,29 @@ -import { localConfig } from "../../../src/config"; -import { Buffer } from "../../../src/entities"; -import { Logger } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; +import { localConfig } from "../../src/config"; +import { Buffer, Logger } from "../../src/entities"; +import { Helper } from "../../src/helper"; +import { Playbook } from "../../src/playbook/playbook"; + +describe("Tokens", () => { + jest.setTimeout(localConfig.standardTimeout); + + let deployedToken: string; + + describe("Deploy/check the custom ERC20 tokens", () => { + const playbook = new Playbook(); + + //@id603 + it("Deploy custom ERC20 token to L2", async () => { + deployedToken = await playbook.deployERC20toL2(); + expect(deployedToken).toContain(Logger.txHashStartsWith); + }); + + //@id657 + it("Deploy custom ERC20 token to L1", async () => { + deployedToken = await playbook.deployERC20toL1(); + expect(deployedToken).toContain(Logger.txHashStartsWith); + }); + }); +}); describe("Deposit", () => { const playbook = new Playbook(); diff --git a/packages/integration-tests/tests/api/common/pre-requisites/transactions/multiCall.test.ts b/packages/integration-tests/tests/hooks/local/multiCall.test.ts similarity index 79% rename from packages/integration-tests/tests/api/common/pre-requisites/transactions/multiCall.test.ts rename to packages/integration-tests/tests/hooks/local/multiCall.test.ts index 001565ec17..c09d9e251b 100644 --- a/packages/integration-tests/tests/api/common/pre-requisites/transactions/multiCall.test.ts +++ b/packages/integration-tests/tests/hooks/local/multiCall.test.ts @@ -1,6 +1,6 @@ -import { localConfig } from "../../../../../src/config"; -import { Logger } from "../../../../../src/entities"; -import { Playbook } from "../../../../../src/playbook/playbook"; +import { localConfig } from "../../../src/config"; +import { Logger } from "../../../src/entities"; +import { Playbook } from "../../../src/playbook/playbook"; describe("Multicall transactions", () => { jest.setTimeout(localConfig.extendedTimeout); diff --git a/packages/integration-tests/tests/api/common/pre-requisites/transactions/multiTransfer.test.ts b/packages/integration-tests/tests/hooks/local/multiTransfer.test.ts similarity index 79% rename from packages/integration-tests/tests/api/common/pre-requisites/transactions/multiTransfer.test.ts rename to packages/integration-tests/tests/hooks/local/multiTransfer.test.ts index a04549b7d5..d7ca2a0780 100644 --- a/packages/integration-tests/tests/api/common/pre-requisites/transactions/multiTransfer.test.ts +++ b/packages/integration-tests/tests/hooks/local/multiTransfer.test.ts @@ -1,7 +1,7 @@ -import { localConfig } from "../../../../../src/config"; -import { Buffer, Logger } from "../../../../../src/entities"; -import { Helper } from "../../../../../src/helper"; -import { Playbook } from "../../../../../src/playbook/playbook"; +import { localConfig } from "../../../src/config"; +import { Buffer, Logger } from "../../../src/entities"; +import { Helper } from "../../../src/helper"; +import { Playbook } from "../../../src/playbook/playbook"; describe("Mulitransfer ETH", () => { jest.setTimeout(localConfig.extendedTimeout); diff --git a/packages/integration-tests/tests/api/common/pre-requisites/nft.test.ts b/packages/integration-tests/tests/hooks/local/nft.test.ts similarity index 78% rename from packages/integration-tests/tests/api/common/pre-requisites/nft.test.ts rename to packages/integration-tests/tests/hooks/local/nft.test.ts index 54256f6ac6..a8b3b3786d 100644 --- a/packages/integration-tests/tests/api/common/pre-requisites/nft.test.ts +++ b/packages/integration-tests/tests/hooks/local/nft.test.ts @@ -1,6 +1,6 @@ -import { localConfig } from "../../../../src/config"; -import { Logger } from "../../../../src/entities"; -import { Playbook } from "../../../../src/playbook/playbook"; +import { localConfig } from "../../../src/config"; +import { Logger } from "../../../src/entities"; +import { Playbook } from "../../../src/playbook/playbook"; describe("NFTs", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/common/pre-requisites/transactions/transaction.test.ts b/packages/integration-tests/tests/hooks/local/transaction.test.ts similarity index 89% rename from packages/integration-tests/tests/api/common/pre-requisites/transactions/transaction.test.ts rename to packages/integration-tests/tests/hooks/local/transaction.test.ts index b2b523edd8..3a78954376 100644 --- a/packages/integration-tests/tests/api/common/pre-requisites/transactions/transaction.test.ts +++ b/packages/integration-tests/tests/hooks/local/transaction.test.ts @@ -1,7 +1,7 @@ -import { localConfig } from "../../../../../src/config"; -import { Buffer, Logger } from "../../../../../src/entities"; -import { Helper } from "../../../../../src/helper"; -import { Playbook } from "../../../../../src/playbook/playbook"; +import { localConfig } from "../../../src/config"; +import { Buffer, Logger } from "../../../src/entities"; +import { Helper } from "../../../src/helper"; +import { Playbook } from "../../../src/playbook/playbook"; describe("Transactions", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/common/pre-requisites/transfers.test.ts b/packages/integration-tests/tests/hooks/local/transfers.test.ts similarity index 70% rename from packages/integration-tests/tests/api/common/pre-requisites/transfers.test.ts rename to packages/integration-tests/tests/hooks/local/transfers.test.ts index af267dc970..0c12904c57 100644 --- a/packages/integration-tests/tests/api/common/pre-requisites/transfers.test.ts +++ b/packages/integration-tests/tests/hooks/local/transfers.test.ts @@ -1,7 +1,7 @@ -import { localConfig } from "../../../../src/config"; -import { Buffer } from "../../../../src/entities"; -import { Helper } from "../../../../src/helper"; -import { Playbook } from "../../../../src/playbook/playbook"; +import { localConfig } from "../../../src/config"; +import { Buffer } from "../../../src/entities"; +import { Helper } from "../../../src/helper"; +import { Playbook } from "../../../src/playbook/playbook"; describe("Transfer", () => { jest.setTimeout(localConfig.standardTimeout); diff --git a/packages/integration-tests/tests/api/common/pre-requisites/withdrawal.test.ts b/packages/integration-tests/tests/hooks/local/withdrawal.test.ts similarity index 86% rename from packages/integration-tests/tests/api/common/pre-requisites/withdrawal.test.ts rename to packages/integration-tests/tests/hooks/local/withdrawal.test.ts index 71f2fea000..dc8ada4576 100644 --- a/packages/integration-tests/tests/api/common/pre-requisites/withdrawal.test.ts +++ b/packages/integration-tests/tests/hooks/local/withdrawal.test.ts @@ -1,8 +1,8 @@ -import { localConfig } from "../../../../src/config"; -import { Buffer, Token, Wallets } from "../../../../src/entities"; -import { Logger } from "../../../../src/entities"; -import { Helper } from "../../../../src/helper"; -import { Playbook } from "../../../../src/playbook/playbook"; +import { localConfig } from "../../../src/config"; +import { Buffer, Token, Wallets } from "../../../src/entities"; +import { Logger } from "../../../src/entities"; +import { Helper } from "../../../src/helper"; +import { Playbook } from "../../../src/playbook/playbook"; describe("Withdrawal", () => { const playbook = new Playbook(); From 6ed24274059fb647ee0d33206d7df95d9a2b2de8 Mon Sep 17 00:00:00 2001 From: abilevych Date: Fri, 3 Nov 2023 11:22:43 +0200 Subject: [PATCH 09/25] chore: implemented a global hook for jest --- docker-compose.yaml | 1 + packages/integration-tests/jest.config.json | 1 + .../tests/hooks/global.test.ts | 52 ------------------- .../integration-tests/tests/hooks/global.ts | 23 ++++++++ 4 files changed, 25 insertions(+), 52 deletions(-) delete mode 100644 packages/integration-tests/tests/hooks/global.test.ts create mode 100644 packages/integration-tests/tests/hooks/global.ts diff --git a/docker-compose.yaml b/docker-compose.yaml index e6991b3d22..0c32b27bd3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -26,6 +26,7 @@ services: - DATABASE_PASSWORD=postgres - DATABASE_NAME=block-explorer - BLOCKCHAIN_RPC_URL=http://zksync:3050 + - BATCHES_PROCESSING_POLLING_INTERVAL=1000 ports: - '3001:3001' - '9229:9229' diff --git a/packages/integration-tests/jest.config.json b/packages/integration-tests/jest.config.json index d6589b6ee7..ec552e5f9b 100644 --- a/packages/integration-tests/jest.config.json +++ b/packages/integration-tests/jest.config.json @@ -1,5 +1,6 @@ { "moduleFileExtensions": ["js", "json", "ts"], + "setupFiles": ["/tests/hooks/global.ts"], "rootDir": ".", "testEnvironment": "node", "testRegex": ".test.ts$", diff --git a/packages/integration-tests/tests/hooks/global.test.ts b/packages/integration-tests/tests/hooks/global.test.ts deleted file mode 100644 index 02c5eaf4e1..0000000000 --- a/packages/integration-tests/tests/hooks/global.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { localConfig } from "../../src/config"; -import { Buffer, Logger } from "../../src/entities"; -import { Helper } from "../../src/helper"; -import { Playbook } from "../../src/playbook/playbook"; - -describe("Tokens", () => { - jest.setTimeout(localConfig.standardTimeout); - - let deployedToken: string; - - describe("Deploy/check the custom ERC20 tokens", () => { - const playbook = new Playbook(); - - //@id603 - it("Deploy custom ERC20 token to L2", async () => { - deployedToken = await playbook.deployERC20toL2(); - expect(deployedToken).toContain(Logger.txHashStartsWith); - }); - - //@id657 - it("Deploy custom ERC20 token to L1", async () => { - deployedToken = await playbook.deployERC20toL1(); - expect(deployedToken).toContain(Logger.txHashStartsWith); - }); - }); -}); - -describe("Deposit", () => { - const playbook = new Playbook(); - const helper = new Helper(); - const bufferRoute = "src/playbook/"; - - let result: string; - let token: string; - jest.setTimeout(localConfig.extendedTimeout); - - //@id633 - it("Make a deposit with 0.0000001 ETH ", async () => { - result = await playbook.depositETH("0.0000001"); - await expect(result).not.toBeUndefined(); - await expect(result.includes(Logger.txHashStartsWith)).toBe(true); - }); - - //@id638 - it("Make a deposit with the Custom token ", async () => { - const bufferFile = bufferRoute + Buffer.L1; - token = await helper.getStringFromFile(bufferFile); - result = await playbook.depositERC20("100", token, 18); - await expect(result).not.toBeUndefined(); - await expect(result.includes(Logger.txHashStartsWith)).toBe(true); - }); -}); diff --git a/packages/integration-tests/tests/hooks/global.ts b/packages/integration-tests/tests/hooks/global.ts new file mode 100644 index 0000000000..d2b7645016 --- /dev/null +++ b/packages/integration-tests/tests/hooks/global.ts @@ -0,0 +1,23 @@ +import { Buffer } from "../../src/entities"; +import { Helper } from "../../src/helper"; +import { Playbook } from "../../src/playbook/playbook"; + +async function globalHook() { + const playbook = new Playbook(); + const helper = new Helper(); + const bufferRoute = "src/playbook/"; + const bufferFile = bufferRoute + Buffer.L1; + const token = await helper.getStringFromFile(bufferFile); + + await playbook.deployERC20toL2(); + await playbook.deployERC20toL1(); + await playbook.depositETH("0.0000001"); + await playbook.depositERC20("100", token, 18); +} + +globalHook() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); From cb7a2374e00c5136f0271f23be7208cd5c0986ab Mon Sep 17 00:00:00 2001 From: abilevych Date: Fri, 3 Nov 2023 11:45:56 +0200 Subject: [PATCH 10/25] chore: local hooks for the addresses endpoint --- .../tests/api/addresses.test.ts | 24 +++++++++++++++++++ .../integration-tests/tests/hooks/global.ts | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/integration-tests/tests/api/addresses.test.ts b/packages/integration-tests/tests/api/addresses.test.ts index 10e11cf6e4..df7ee314a4 100644 --- a/packages/integration-tests/tests/api/addresses.test.ts +++ b/packages/integration-tests/tests/api/addresses.test.ts @@ -5,17 +5,28 @@ import { environment } from "../../src/config"; import { localConfig } from "../../src/config"; import { Buffer, Token, Wallets } from "../../src/entities"; import { Helper } from "../../src/helper"; +import { Playbook } from "../../src/playbook/playbook"; describe("Address", () => { jest.setTimeout(localConfig.standardTimeout); const helper = new Helper(); + const playbook = new Playbook(); const bufferFile = "src/playbook/"; let token: string; let contract: string; let txHash: string; describe("/address/{address}", () => { + beforeAll(async () => { + await playbook.deployNFTtoL2(); + await playbook.deployMultiCallContracts(); + await playbook.deployMultiTransferETH(); + await playbook.deployGreeterToL2(); + await playbook.useMultiCallContracts(); + await playbook.useMultiTransferETH(); + }); + //@id1457 it("Verify deployed to L2 NFT via /address/{address}", async () => { token = await helper.getStringFromFile(bufferFile + Buffer.NFTtoL2); @@ -105,6 +116,7 @@ describe("Address", () => { //@id1476 it("Verify the deployed multitransfer contract via /address/{address}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); const apiRoute = `/address/${contract}`; @@ -119,6 +131,8 @@ describe("Address", () => { //@id1449 it("Verify the deployed Greeter contract via /address/{address}", async () => { + contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); + const apiRoute = `/address/${contract}`; await setTimeout(localConfig.standardPause); //works unstable without timeout @@ -132,6 +146,11 @@ describe("Address", () => { }); describe("/address/{address}/logs", () => { + beforeAll(async () => { + await playbook.deployGreeterToL2(); + await playbook.useGreeter(); + }); + //@id1510 it("Verify the transaction via /address/{address}/logs", async () => { contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); @@ -171,6 +190,11 @@ describe("Address", () => { }); describe("/address/{address}/transfers", () => { + beforeAll(async () => { + await playbook.deployViaPaymaster(); + await playbook.usePaymaster(); + }); + //@id1509 it("Verify the transaction via /address/{address}/transfers", async () => { contract = await helper.getStringFromFile(bufferFile + Buffer.paymaster); diff --git a/packages/integration-tests/tests/hooks/global.ts b/packages/integration-tests/tests/hooks/global.ts index d2b7645016..64be34eecf 100644 --- a/packages/integration-tests/tests/hooks/global.ts +++ b/packages/integration-tests/tests/hooks/global.ts @@ -16,7 +16,9 @@ async function globalHook() { } globalHook() - .then(() => process.exit(0)) + .then(() => { + console.log("Global hook completed successfully."); + }) .catch((error) => { console.error(error); process.exit(1); From 0816c8047e661c5495e722fdc2f1b0b909b604ef Mon Sep 17 00:00:00 2001 From: abilevych Date: Fri, 3 Nov 2023 11:54:38 +0200 Subject: [PATCH 11/25] chore: local hooks for the tokens endpoint --- packages/integration-tests/tests/api/tokens.test.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/integration-tests/tests/api/tokens.test.ts b/packages/integration-tests/tests/api/tokens.test.ts index 9f7c4cc5cd..0c8561a08b 100644 --- a/packages/integration-tests/tests/api/tokens.test.ts +++ b/packages/integration-tests/tests/api/tokens.test.ts @@ -75,10 +75,15 @@ describe("Tokens", () => { ); }); describe("/tokens/{address}/transfers", () => { + beforeAll(async () => { + txHash = await playbook.transferERC20("0.01", l2Token, "L2"); + await playbook.deployViaPaymaster(); + await playbook.usePaymaster(); + }); + //@id1448 it("Verify the custom ERC20 token transfer via /tokens/{address}/transfers", async () => { const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; - const txHash = await playbook.transferERC20("0.01", l2Token, "L2"); await setTimeout(localConfig.standardPause); //works unstable without timeout From 3aa0f34b77d245a3b93b606c041f2d7b303adf35 Mon Sep 17 00:00:00 2001 From: abilevych Date: Fri, 3 Nov 2023 12:59:01 +0200 Subject: [PATCH 12/25] chore: local hooks for the transaction endpoint --- packages/integration-tests/src/entities.ts | 3 ++ .../scenarios/withdrawal/withdrawERC20.ts | 8 +++-- .../scenarios/withdrawal/withdrawETH.ts | 6 +++- .../withdrawal/withdrawETHtoOtherAddress.ts | 6 +++- .../tests/api/transactions.test.ts | 32 ++++++++++++++++--- 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/packages/integration-tests/src/entities.ts b/packages/integration-tests/src/entities.ts index 07697620fa..33274f8c1f 100644 --- a/packages/integration-tests/src/entities.ts +++ b/packages/integration-tests/src/entities.ts @@ -20,6 +20,9 @@ export enum Buffer { txMultiCallRoot = "./buffer/txmultiCallRoot.txt", txUseMultiCallContracts = "./buffer/txUseMultiCallContracts.txt", txEthTransfer = "./buffer/txEthTransfer.txt", + txERC20Withdraw = "./buffer/txERC20Withdraw.txt", + txEthWithdraw = "./buffer/txEthWithdraw.txt", + txEthWithdrawOtherAddress = "./buffer/txEthWithdrawOtherAddress.txt", txERC20Transfer = "./buffer/txERC20Transfer.txt", emptyWalletPrivateKey = "./buffer/emptyWalletPrivateKey.txt", emptyWalletAddress = "./buffer/emptyWalletAddress.txt", diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts index 27d498dda3..7bcb910033 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20.ts @@ -1,8 +1,9 @@ import * as ethers from "ethers"; +import { promises as fs } from "fs"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Logger, Wallets } from "../../../entities"; +import { Buffer, Logger, Wallets } from "../../../entities"; import { Helper } from "../../../helper"; export const withdrawERC20 = async function (tokenAddress: string, sum = "0.2") { @@ -11,6 +12,8 @@ export const withdrawERC20 = async function (tokenAddress: string, sum = "0.2") const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const bridges = await syncProvider.getDefaultBridgeAddresses(); + const playbookRoot = "src/playbook/"; + const bufferFile = playbookRoot + Buffer.txERC20Withdraw; const balance = await syncWallet.getBalance(tokenAddress); @@ -21,7 +24,7 @@ export const withdrawERC20 = async function (tokenAddress: string, sum = "0.2") amount: ethers.utils.parseEther(sum), token: tokenAddress, bridgeAddress: bridges.erc20L2, - overrides: localConfig.gasLimit, + // overrides: localConfig.gasLimit, }); const txHash = withdrawL2.hash; @@ -34,6 +37,7 @@ export const withdrawERC20 = async function (tokenAddress: string, sum = "0.2") console.log(`Your balance is ${balanceAfter.toString()}`); await helper.txHashLogger(Logger.withdraw, txHash, "Custom token"); + await fs.writeFile(bufferFile, txHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts index b5daeaa52f..5c2598a6d6 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETH.ts @@ -1,8 +1,9 @@ import * as ethers from "ethers"; +import { promises as fs } from "fs"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Logger } from "../../../entities"; +import { Buffer, Logger } from "../../../entities"; import { Helper } from "../../../helper"; export const withdrawETH = async function (sum = "0.000009") { @@ -10,6 +11,8 @@ export const withdrawETH = async function (sum = "0.000009") { const syncProvider = new zksync.Provider(localConfig.L2Network); const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); + const playbookRoot = "src/playbook/"; + const bufferFile = playbookRoot + Buffer.txEthWithdraw; const withdrawL2 = await syncWallet.withdraw({ token: zksync.utils.ETH_ADDRESS, @@ -20,6 +23,7 @@ export const withdrawETH = async function (sum = "0.000009") { await withdrawL2.waitFinalize(); await helper.txHashLogger(Logger.withdraw, txHash, "ETH"); + await fs.writeFile(bufferFile, txHash); return txHash; }; diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts index 53c217110c..6adde5510c 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawETHtoOtherAddress.ts @@ -1,8 +1,9 @@ import * as ethers from "ethers"; +import { promises as fs } from "fs"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Logger, Wallets } from "../../../entities"; +import { Buffer, Logger, Wallets } from "../../../entities"; import { Helper } from "../../../helper"; export const withdrawETHtoOtherAddress = async function (sum = "0.000009") { @@ -10,6 +11,8 @@ export const withdrawETHtoOtherAddress = async function (sum = "0.000009") { const syncProvider = new zksync.Provider(localConfig.L2Network); const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); + const playbookRoot = "src/playbook/"; + const bufferFile = playbookRoot + Buffer.txEthWithdrawOtherAddress; const withdrawL2 = await syncWallet.withdraw({ token: zksync.utils.ETH_ADDRESS, @@ -21,6 +24,7 @@ export const withdrawETHtoOtherAddress = async function (sum = "0.000009") { await withdrawL2.waitFinalize(); await helper.txHashLogger(Logger.withdraw, txHash, "ETH"); + await fs.writeFile(bufferFile, txHash); return txHash; }; diff --git a/packages/integration-tests/tests/api/transactions.test.ts b/packages/integration-tests/tests/api/transactions.test.ts index 16a39b4105..9d004a0d34 100644 --- a/packages/integration-tests/tests/api/transactions.test.ts +++ b/packages/integration-tests/tests/api/transactions.test.ts @@ -1,3 +1,4 @@ +import * as buffer from "buffer"; import * as request from "supertest"; import { setTimeout } from "timers/promises"; @@ -17,11 +18,25 @@ describe("Transactions", () => { let contract: any; let token: string; let txHash: any; + let txERC20Withdraw: string; + let customTokenL2; + + beforeAll(async () => { + // token = bufferFile + "/" + Buffer.L2deposited; + // customTokenL2 = await helper.getStringFromFile(token); + // await playbook.withdrawERC20(customTokenL2); + }); describe("/transactions/{transactionHash}/transfers", () => { + beforeAll(async () => { + await playbook.transferETH("0.000001"); + await playbook.withdrawETH(); + await playbook.withdrawETHtoOtherAddress(); + }); + //@id1447 it("Verify transfer ETH L2-L2 via /transactions/{transactionHash}/transfers", async () => { - txHash = await playbook.transferETH("0.000001"); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthTransfer); const apiRoute = `/transactions/${txHash}/transfers`; await setTimeout(localConfig.standardPause); @@ -37,7 +52,7 @@ describe("Transactions", () => { //@id1459 it("Verify the ETH withdrawal via /transactions/{transactionHash}/transfers", async () => { - txHash = await playbook.withdrawETH(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthWithdraw); await setTimeout(localConfig.standardPause); //works unstable without timeout const apiRoute = `/transactions/${txHash}/transfers`; @@ -83,7 +98,7 @@ describe("Transactions", () => { //@id1461 it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}/transfers", async () => { - txHash = await playbook.withdrawETHtoOtherAddress(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthWithdrawOtherAddress); await setTimeout(localConfig.standardPause); //works unstable without timeout const apiRoute = `/transactions/${txHash}/transfers`; @@ -127,13 +142,20 @@ describe("Transactions", () => { .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); }); - //@id1463 - it("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { + //@id1463 //failing due to unexpected l1 address after withdraw + xit("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { + // const l1Token = bufferFile + "/" + Buffer.L1; + // const customTokenL1 = await helper.getStringFromFile(l1Token); + // + // txHash = await helper.getStringFromFile(bufferFile + Buffer.txERC20Withdraw); + // + token = bufferFile + "/" + Buffer.L2deposited; const l1Token = bufferFile + "/" + Buffer.L1; const customTokenL2 = await helper.getStringFromFile(token); const customTokenL1 = await helper.getStringFromFile(l1Token); txHash = await playbook.withdrawERC20(customTokenL2); + const apiRoute = `/transactions/${txHash}/transfers`; await setTimeout(localConfig.standardPause); //works unstable without timeout From e848a0fb58d077ef2811d5bb59e4bbe3dc89cf3b Mon Sep 17 00:00:00 2001 From: abilevych Date: Mon, 6 Nov 2023 17:52:40 +0200 Subject: [PATCH 13/25] chore: add global hooks --- packages/integration-tests/jest.config.json | 2 +- packages/integration-tests/package.json | 3 +- .../transfers/transferFailedState.ts | 6 +- .../tests/api/addresses.test.ts | 22 +- .../tests/api/batches.test.ts | 10 +- .../tests/api/blocks.test.ts | 8 +- .../integration-tests/tests/api/stats.test.ts | 5 +- .../tests/api/tokens.test.ts | 18 +- .../tests/api/transactions.test.ts | 327 ++++++++---------- .../integration-tests/tests/hooks/global.ts | 17 +- .../tests/hooks/local/multiCall.test.ts | 23 -- .../tests/hooks/local/multiTransfer.test.ts | 31 -- .../tests/hooks/local/nft.test.ts | 26 -- .../tests/hooks/local/transaction.test.ts | 67 ---- .../tests/hooks/local/transfers.test.ts | 22 -- .../tests/hooks/local/withdrawal.test.ts | 53 --- 16 files changed, 193 insertions(+), 447 deletions(-) delete mode 100644 packages/integration-tests/tests/hooks/local/multiCall.test.ts delete mode 100644 packages/integration-tests/tests/hooks/local/multiTransfer.test.ts delete mode 100644 packages/integration-tests/tests/hooks/local/nft.test.ts delete mode 100644 packages/integration-tests/tests/hooks/local/transaction.test.ts delete mode 100644 packages/integration-tests/tests/hooks/local/transfers.test.ts delete mode 100644 packages/integration-tests/tests/hooks/local/withdrawal.test.ts diff --git a/packages/integration-tests/jest.config.json b/packages/integration-tests/jest.config.json index ec552e5f9b..6657349178 100644 --- a/packages/integration-tests/jest.config.json +++ b/packages/integration-tests/jest.config.json @@ -1,6 +1,6 @@ { "moduleFileExtensions": ["js", "json", "ts"], - "setupFiles": ["/tests/hooks/global.ts"], + "globalSetup": "/tests/hooks/global.ts", "rootDir": ".", "testEnvironment": "node", "testRegex": ".test.ts$", diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index 044ab18274..24ee6ad63a 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -9,8 +9,7 @@ "license": "MIT", "scripts": { "postinstall": "cd src/playbook && npm install", - "integration-test:api": "jest --verbose --testPathPattern=tokens.test.ts && jest --verbose --testPathPattern=deposit.test.ts && jest --verbose --testPathPattern=common && jest --verbose --testPathPattern=transactions", - "hooks:global": "jest --verbose --testPathPattern=global.test.ts", + "integration-test:api": "jest --verbose", "integration-test:ui": "npx playwright test", "block-explorer:start": "docker-compose up", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-pattern 'repos' --ignore-pattern 'git add .'" diff --git a/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts b/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts index 77bf391107..c798cf6a61 100644 --- a/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts +++ b/packages/integration-tests/src/playbook/scenarios/transfers/transferFailedState.ts @@ -1,8 +1,9 @@ import * as ethers from "ethers"; +import { promises as fs } from "fs"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Logger } from "../../../entities"; +import { Buffer, Logger } from "../../../entities"; import { Helper } from "../../../helper"; export const transferFailedState = async function (tokenAddress: string, tokenName?: string) { @@ -11,6 +12,8 @@ export const transferFailedState = async function (tokenAddress: string, tokenNa const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const amount = ethers.utils.parseEther("1.0"); + const playbookRoot = "src/playbook/"; + const bufferFile = playbookRoot + Buffer.failedState; const transfer = await syncWallet.transfer({ to: "0x0000000000000000000000000000000000000000", @@ -21,6 +24,7 @@ export const transferFailedState = async function (tokenAddress: string, tokenNa const txHash = transfer.hash; await helper.txHashLogger(Logger.txFailedState, txHash, tokenName); + await fs.writeFile(bufferFile, txHash); return txHash; }; diff --git a/packages/integration-tests/tests/api/addresses.test.ts b/packages/integration-tests/tests/api/addresses.test.ts index df7ee314a4..599648e1c5 100644 --- a/packages/integration-tests/tests/api/addresses.test.ts +++ b/packages/integration-tests/tests/api/addresses.test.ts @@ -29,9 +29,9 @@ describe("Address", () => { //@id1457 it("Verify deployed to L2 NFT via /address/{address}", async () => { - token = await helper.getStringFromFile(bufferFile + Buffer.NFTtoL2); - await setTimeout(localConfig.extendedPause); + + token = await helper.getStringFromFile(bufferFile + Buffer.NFTtoL2); const apiRoute = `/address/${token}`; return request(environment.blockExplorerAPI) @@ -56,6 +56,7 @@ describe("Address", () => { //@id1464 it("Verify the deployed Root contract via /address/{address}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallRoot); txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); @@ -76,6 +77,7 @@ describe("Address", () => { //@id1465 it("Verify the deployed Middle contract via /address/{address}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallMiddle); txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); @@ -96,6 +98,7 @@ describe("Address", () => { //@id1466 it("Verify the deployed Caller contract via /address/{address}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallCaller); txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); @@ -116,8 +119,8 @@ describe("Address", () => { //@id1476 it("Verify the deployed multitransfer contract via /address/{address}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout - contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); const apiRoute = `/address/${contract}`; return request(environment.blockExplorerAPI) @@ -131,12 +134,11 @@ describe("Address", () => { //@id1449 it("Verify the deployed Greeter contract via /address/{address}", async () => { - contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); + await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); const apiRoute = `/address/${contract}`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -153,14 +155,14 @@ describe("Address", () => { //@id1510 it("Verify the transaction via /address/{address}/logs", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); const apiRoute = `/address/${contract}/logs`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); - await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -197,6 +199,8 @@ describe("Address", () => { //@id1509 it("Verify the transaction via /address/{address}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.paymaster); const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); @@ -205,8 +209,6 @@ describe("Address", () => { const apiRoute = `/address/${contract}/transfers`; const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); - await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) diff --git a/packages/integration-tests/tests/api/batches.test.ts b/packages/integration-tests/tests/api/batches.test.ts index 867020bed1..e934783919 100644 --- a/packages/integration-tests/tests/api/batches.test.ts +++ b/packages/integration-tests/tests/api/batches.test.ts @@ -8,10 +8,10 @@ describe("/batches", () => { jest.setTimeout(localConfig.standardTimeout); //@id1513 it("Verify the response via /batches", async () => { - const apiRoute = `/batches`; - await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/batches`; + return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -29,15 +29,15 @@ describe("/batches", () => { }); //@id1514 - it("Verify the response via /batches/{batchNumber}", async () => { + xit("Verify the response via /batches/{batchNumber}", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + const batches = await request(environment.blockExplorerAPI).get("/batches"); const batchNumber = batches.body.items[0].number; const apiRoute = `/batches/${batchNumber}`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) diff --git a/packages/integration-tests/tests/api/blocks.test.ts b/packages/integration-tests/tests/api/blocks.test.ts index c29f16caa5..a11e97011e 100644 --- a/packages/integration-tests/tests/api/blocks.test.ts +++ b/packages/integration-tests/tests/api/blocks.test.ts @@ -9,10 +9,10 @@ describe("/blocks", () => { //@id1511 it("Verify the response via /blocks", async () => { - const apiRoute = `/blocks`; - await setTimeout(localConfig.extendedPause); //works unstable without timeout + const apiRoute = `/blocks`; + return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -31,14 +31,14 @@ describe("/blocks", () => { //@id1512 it("Verify the response via /blocks/{/blockNumber}", async () => { + await setTimeout(localConfig.standardTimeout); //works unstable without timeout + const blocks = await request(environment.blockExplorerAPI).get("/blocks"); const blockNumber = blocks.body.items[0].number; const apiRoute = `/blocks/${blockNumber}`; - await setTimeout(localConfig.extendedPause); //works unstable without timeout - return ( request(environment.blockExplorerAPI) .get(apiRoute) diff --git a/packages/integration-tests/tests/api/stats.test.ts b/packages/integration-tests/tests/api/stats.test.ts index c01ca23283..e432b7d434 100644 --- a/packages/integration-tests/tests/api/stats.test.ts +++ b/packages/integration-tests/tests/api/stats.test.ts @@ -5,13 +5,12 @@ import { environment } from "../../src/config"; import { localConfig } from "../../src/config"; describe("/stats", () => { - jest.setTimeout(localConfig.standardTimeout); //@id1515 it("Verify the response via /stats", async () => { - const apiRoute = `/stats`; - await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/stats`; + return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) diff --git a/packages/integration-tests/tests/api/tokens.test.ts b/packages/integration-tests/tests/api/tokens.test.ts index 0c8561a08b..4a89c5150c 100644 --- a/packages/integration-tests/tests/api/tokens.test.ts +++ b/packages/integration-tests/tests/api/tokens.test.ts @@ -23,12 +23,12 @@ describe("Tokens", () => { describe("/tokens", () => { //@id1508 it("Verify the response via /tokens", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + const l2DepositedToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); const l1Token = await helper.getStringFromFile(bufferFile + Buffer.L1); const apiRoute = `/tokens`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -57,10 +57,10 @@ describe("Tokens", () => { }); //@id1456 it("Verify deployed to L2 custom token via /tokens/{tokenAddress}", async () => { - const apiRoute = `/tokens/${l2Token}`; - await setTimeout(localConfig.extendedPause); //works unstable without timeout + const apiRoute = `/tokens/${l2Token}`; + return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -74,6 +74,7 @@ describe("Tokens", () => { }) ); }); + describe("/tokens/{address}/transfers", () => { beforeAll(async () => { txHash = await playbook.transferERC20("0.01", l2Token, "L2"); @@ -83,10 +84,10 @@ describe("Tokens", () => { //@id1448 it("Verify the custom ERC20 token transfer via /tokens/{address}/transfers", async () => { - const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; + return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -100,15 +101,14 @@ describe("Tokens", () => { //@id1451 it("Verify the custom token includes paymaster transaction via /tokens/{address}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout + l2Token = await helper.getStringFromFile(bufferFile + Buffer.customToken); const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); const paymaster = await helper.getStringFromFile(bufferFile + Buffer.paymaster); txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); - const apiRoute = `/tokens/${l2Token}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) diff --git a/packages/integration-tests/tests/api/transactions.test.ts b/packages/integration-tests/tests/api/transactions.test.ts index 9d004a0d34..8a9c553a51 100644 --- a/packages/integration-tests/tests/api/transactions.test.ts +++ b/packages/integration-tests/tests/api/transactions.test.ts @@ -1,4 +1,3 @@ -import * as buffer from "buffer"; import * as request from "supertest"; import { setTimeout } from "timers/promises"; @@ -18,20 +17,23 @@ describe("Transactions", () => { let contract: any; let token: string; let txHash: any; - let txERC20Withdraw: string; - let customTokenL2; beforeAll(async () => { - // token = bufferFile + "/" + Buffer.L2deposited; - // customTokenL2 = await helper.getStringFromFile(token); - // await playbook.withdrawERC20(customTokenL2); + const customToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + await playbook.withdrawETHtoOtherAddress(); + await playbook.withdrawERC20(customToken); + await playbook.withdrawETH(); + await playbook.deployMultiTransferETH(); + await playbook.useMultiTransferETH(); + await playbook.deployGreeterToL2(); + await playbook.useGreeter(); + await playbook.deployMultiCallContracts(); + await playbook.useMultiCallContracts(); }); describe("/transactions/{transactionHash}/transfers", () => { beforeAll(async () => { await playbook.transferETH("0.000001"); - await playbook.withdrawETH(); - await playbook.withdrawETHtoOtherAddress(); }); //@id1447 @@ -142,24 +144,18 @@ describe("Transactions", () => { .expect((res) => expect(res.body.items[3]).toStrictEqual(expect.objectContaining({ type: "refund" }))); }); - //@id1463 //failing due to unexpected l1 address after withdraw - xit("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { - // const l1Token = bufferFile + "/" + Buffer.L1; - // const customTokenL1 = await helper.getStringFromFile(l1Token); - // - // txHash = await helper.getStringFromFile(bufferFile + Buffer.txERC20Withdraw); - // + //@id1463 + it("Verify the custom token withdrawal via /transactions/{transactionHash}/transfers", async () => { + await setTimeout(localConfig.standardPause); //works unstable without timeout - token = bufferFile + "/" + Buffer.L2deposited; const l1Token = bufferFile + "/" + Buffer.L1; - const customTokenL2 = await helper.getStringFromFile(token); const customTokenL1 = await helper.getStringFromFile(l1Token); - txHash = await playbook.withdrawERC20(customTokenL2); + const l2Token = bufferFile + "/" + Buffer.L2deposited; + const customTokenL2 = await helper.getStringFromFile(l2Token); + txHash = await playbook.withdrawERC20toOtherAddress(customTokenL2); const apiRoute = `/transactions/${txHash}/transfers`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -197,7 +193,7 @@ describe("Transactions", () => { expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress })) ) .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress })) + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ to: Wallets.mainWalletAddress })) ) .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) .expect((res) => @@ -229,9 +225,14 @@ describe("Transactions", () => { }); describe("/transactions/{transactionHash}", () => { + beforeAll(async () => { + const customToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + await playbook.transferFailedState(customToken); + }); + //@id1460 it("Verify the ETH withdrawal to the other address via /transactions/{transactionHash}", async () => { - txHash = await playbook.withdrawETHtoOtherAddress(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthWithdrawOtherAddress); await setTimeout(localConfig.standardPause); //works unstable without timeout const apiRoute = `/transactions/${txHash}`; @@ -246,9 +247,7 @@ describe("Transactions", () => { //@id1462 it("Verify the custom token withdrawal via /transactions/{transactionHash}", async () => { - token = bufferFile + "/" + Buffer.L2deposited; - const customToken = await helper.getStringFromFile(token); - txHash = await playbook.withdrawERC20(customToken); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txERC20Withdraw); await setTimeout(localConfig.standardPause); //works unstable without timeout const apiRoute = `/transactions/${txHash}`; @@ -262,7 +261,7 @@ describe("Transactions", () => { //@id1458 it("Verify the ETH withdrawal via /transactions/{transactionHash}", async () => { - txHash = await playbook.withdrawETH(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txEthWithdraw); const apiRoute = `/transactions/${txHash}`; await setTimeout(localConfig.standardPause); //works unstable without timeout @@ -278,17 +277,16 @@ describe("Transactions", () => { //@id1478 it("Verify transaction for the ETH via /transactions/{transactionHash}", async () => { - // txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferETH); - contract = await playbook.deployMultiTransferETH(); - txHash = await playbook.useMultiTransferETH(); - const apiRoute = `/transactions/${txHash[0]}`; + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferETH); + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); + const apiRoute = `/transactions/${txHash}`; await setTimeout(localConfig.standardPause); //works unstable without timeout return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash[0] }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); @@ -296,16 +294,16 @@ describe("Transactions", () => { //@id1479 it("Verify transaction for the Custom Token I via /transactions/{transactionHash}", async () => { - contract = await playbook.deployERC20toL2(); - txHash = await playbook.useMultiTransferETH(); - const apiRoute = `/transactions/${txHash[1]}`; + contract = await helper.getStringFromFile(bufferFile + Buffer.L2); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCustomTokenI); + const apiRoute = `/transactions/${txHash}`; await setTimeout(localConfig.standardPause); //works unstable without timeout return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash[1] }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ hash: txHash }))) .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ to: contract }))) .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ from: Wallets.richWalletAddress }))) .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ isL1Originated: false }))); @@ -313,13 +311,8 @@ describe("Transactions", () => { //@id1480 it("Verify transaction for the Custom Token II via /transactions/{transactionHash}", async () => { - token = await playbook.deployERC20toL1(); - await setTimeout(0.9 * 1000); - await playbook.depositERC20("100", token, 18); - await setTimeout(0.9 * 1000); contract = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); - txHash = await playbook.useMultiTransferETH(); - txHash = txHash[2]; + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCustomTokenII); const apiRoute = `/transactions/${txHash}`; await setTimeout(localConfig.standardPause); //works unstable without timeout @@ -335,8 +328,8 @@ describe("Transactions", () => { //@id1454 it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}", async () => { - contract = await playbook.deployGreeterToL2(); - txHash = await playbook.useGreeter(); + contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); + txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); const apiRoute = `/transactions/${txHash}?page=1&limit=10`; await setTimeout(localConfig.standardPause); //works unstable without timeout @@ -354,8 +347,6 @@ describe("Transactions", () => { it("Verify transaction for the Root contract via /transactions/{transactionHash}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); const apiRoute = `/transactions/${txHash}`; @@ -373,8 +364,6 @@ describe("Transactions", () => { it("Verify transaction for the Middle contract via /transactions/{transactionHash}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); const apiRoute = `/transactions/${txHash}`; @@ -393,8 +382,6 @@ describe("Transactions", () => { it("Verify transaction for the Caller contract via /transactions/{transactionHash}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); const apiRoute = `/transactions/${txHash}`; @@ -411,14 +398,11 @@ describe("Transactions", () => { //@id1471 it("Verify transaction for the use multicall contract via /transactions/{transactionHash}", async () => { - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); + await setTimeout(localConfig.standardPause); //works unstable without timeout txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); const apiRoute = `/transactions/${txHash}`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -431,12 +415,12 @@ describe("Transactions", () => { //@id645 it("Verify the transactions with failed state via /transactions/{transactionHash}", async () => { - token = await playbook.deployERC20toL2(); - txHash = await playbook.transferFailedState(token); + await setTimeout(localConfig.standardPause); //works unstable without timeout - const apiRoute = `/transactions/${txHash}?page=1&limit=10`; + token = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); + txHash = await helper.getStringFromFile(bufferFile + Buffer.failedState); - await setTimeout(localConfig.standardPause); //works unstable without timeout + const apiRoute = `/transactions/${txHash}?page=1&limit=10`; return request(environment.blockExplorerAPI) .get(apiRoute) @@ -448,16 +432,20 @@ describe("Transactions", () => { }); }); - describe("/transactions/${txHash}/transfers", () => { + describe("/transactions/{transactionHash}/transfers", () => { + beforeAll(async () => { + await playbook.deployViaPaymaster(); + await playbook.usePaymaster(); + }); + //@id1481 it("Verify transaction for the ETH via /transactions/{transactionHash}/transfers", async () => { - contract = await playbook.deployMultiTransferETH(); - txHash = await playbook.useMultiTransferETH(); - txHash = txHash[0]; - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferETH); + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -508,14 +496,13 @@ describe("Transactions", () => { //@id1482 it("Verify transaction for the Custom tokenI via /transactions/{transactionHash}/transfers", async () => { - token = await playbook.deployERC20toL2(); - contract = await playbook.deployMultiTransferETH(); - txHash = await playbook.useMultiTransferETH(); - txHash = txHash[1]; - const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout + token = await helper.getStringFromFile(bufferFile + Buffer.L2); + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCustomTokenI); + const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; + return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -577,15 +564,11 @@ describe("Transactions", () => { it("Verify transaction for the Custom tokenII via /transactions/{transactionHash}/transfers", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout - const tokenL1 = await playbook.deployERC20toL1(); - await setTimeout(0.9 * 1000); - await playbook.depositERC20("100", tokenL1, 18); - await setTimeout(0.9 * 1000); + const tokenL1 = await helper.getStringFromFile(bufferFile + Buffer.L1); + token = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); - contract = await playbook.deployMultiTransferETH(); - await setTimeout(0.9 * 1000); - txHash = await playbook.useMultiTransferETH(); - txHash = txHash[2]; + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiTransferETH); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCustomTokenII); const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; @@ -650,16 +633,14 @@ describe("Transactions", () => { //@id1452 it("Verify transaction through Paymaster via /transactions/{transactionHash}/transfers", async () => { - // const paymasterAddress = await helper.getStringFromFile(bufferFile + Buffer.paymaster); - await playbook.deployViaPaymaster(); + await setTimeout(localConfig.standardPause); //works unstable without timeout + const paymasterAddress = await helper.getStringFromFile(bufferFile + Buffer.paymaster); const emptyWallet = await helper.getStringFromFile(bufferFile + Buffer.emptyWalletAddress); token = await helper.getStringFromFile(bufferFile + Buffer.customToken); - txHash = await playbook.usePaymaster(); + txHash = await helper.getStringFromFile(bufferFile + Buffer.paymasterTx); const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout - return request(environment.blockExplorerAPI) .get(apiRoute) .expect(200) @@ -715,11 +696,11 @@ describe("Transactions", () => { //@id1455 it("Verify the transaction after SetGreeting execution via transactions/{transactionHash}/transfers", async () => { - await playbook.deployGreeterToL2(); - txHash = await playbook.useGreeter(); + await setTimeout(localConfig.standardPause); //works unstable without timeout + + txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout return request(environment.blockExplorerAPI) .get(apiRoute) @@ -760,9 +741,7 @@ describe("Transactions", () => { it("Verify transaction for the Root contract via /transactions/{transactionHash}/transfers", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout - contract = await playbook.deployMultiCallContracts(); - contract = contract[0]; - await playbook.useMultiCallContracts(); + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallRoot); txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallRoot); const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; @@ -806,9 +785,7 @@ describe("Transactions", () => { it("Verify transaction for the Middle contract via /transactions/{transactionHash}/transfers", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout - contract = await playbook.deployMultiCallContracts(); - contract = contract[1]; - await playbook.useMultiCallContracts(); + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallRoot); txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; @@ -852,10 +829,8 @@ describe("Transactions", () => { it("Verify transaction for the Caller contract via /transactions/{transactionHash}/transfers", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout - contract = await playbook.deployMultiCallContracts(); - contract = contract[2]; - await playbook.useMultiCallContracts(); - txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallMiddle); + contract = await helper.getStringFromFile(bufferFile + Buffer.addressMultiCallRoot); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiCallCaller); const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; @@ -898,12 +873,9 @@ describe("Transactions", () => { it("Verify transaction for the use multicall contract via /transactions/{transactionHash}/transfers", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout - await playbook.deployMultiCallContracts(); - await playbook.useMultiCallContracts(); txHash = await helper.getStringFromFile(bufferFile + Buffer.txUseMultiCallContracts); const apiRoute = `/transactions/${txHash}/transfers?page=1&limit=10`; - await setTimeout(localConfig.standardPause); //works unstable without timeout return request(environment.blockExplorerAPI) .get(apiRoute) @@ -941,86 +913,87 @@ describe("Transactions", () => { }); }); - //@id1507 - it("Verify the transaction via /transactions/{transactionHash}/logs", async () => { - contract = await playbook.deployGreeterToL2(); - txHash = await playbook.useGreeter(); - - const apiRoute = `/transactions/${txHash}/logs`; - const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => - expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(Array.isArray(res.body.items[0].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[0].data).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.items[0].blockNumber).toStrictEqual("number")) - .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[0].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[0].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ address: contract }))) - .expect((res) => expect(Array.isArray(res.body.items[1].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[1].data).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.items[1].blockNumber).toStrictEqual("number")) - .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[1].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[1].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[1].timestamp).toStrictEqual("string")) - .expect((res) => - expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) - ) - .expect((res) => expect(Array.isArray(res.body.items[2].topics)).toStrictEqual(true)) - .expect((res) => expect(typeof res.body.items[2].data).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.items[2].blockNumber).toStrictEqual("number")) - .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) - .expect((res) => expect(typeof res.body.items[2].transactionIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[2].logIndex).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.items[2].timestamp).toStrictEqual("string")) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 3 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 3 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) - .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) - .expect((res) => - expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) - ) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) - .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) - .expect((res) => - expect(res.body.links).toStrictEqual( - expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) - ) - ); + describe("/transactions/${txHash}/logs", () => { + //@id1507 + it("Verify the transaction via /transactions/{transactionHash}/logs", async () => { + contract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2); + txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx); + + const apiRoute = `/transactions/${txHash}/logs`; + const decapitalizedAddress = apiRoute.slice(1).toLowerCase(); + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => + expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(Array.isArray(res.body.items[0].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[0].data).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.items[0].blockNumber).toStrictEqual("number")) + .expect((res) => expect(res.body.items[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[0].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[0].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[0].timestamp).toStrictEqual("string")) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ address: contract }))) + .expect((res) => expect(Array.isArray(res.body.items[1].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[1].data).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.items[1].blockNumber).toStrictEqual("number")) + .expect((res) => expect(res.body.items[1]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[1].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[1].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[1].timestamp).toStrictEqual("string")) + .expect((res) => + expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ address: Token.ETHER_ERC20_Address })) + ) + .expect((res) => expect(Array.isArray(res.body.items[2].topics)).toStrictEqual(true)) + .expect((res) => expect(typeof res.body.items[2].data).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.items[2].blockNumber).toStrictEqual("number")) + .expect((res) => expect(res.body.items[2]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }))) + .expect((res) => expect(typeof res.body.items[2].transactionIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[2].logIndex).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.items[2].timestamp).toStrictEqual("string")) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalItems: 3 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemCount: 3 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ itemsPerPage: 10 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ totalPages: 1 }))) + .expect((res) => expect(res.body.meta).toStrictEqual(expect.objectContaining({ currentPage: 1 }))) + .expect((res) => + expect(res.body.links).toStrictEqual(expect.objectContaining({ first: `${decapitalizedAddress}?limit=10` })) + ) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ previous: "" }))) + .expect((res) => expect(res.body.links).toStrictEqual(expect.objectContaining({ next: "" }))) + .expect((res) => + expect(res.body.links).toStrictEqual( + expect.objectContaining({ last: `${decapitalizedAddress}?page=1&limit=10` }) + ) + ); + }); }); - //@id1506 - it("Verify the transaction via /transactions", async () => { - contract = await playbook.deployGreeterToL2(); - txHash = await playbook.useGreeter(); - - const apiRoute = `/transactions`; - - await setTimeout(localConfig.standardPause); //works unstable without timeout - - return request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) - .expect((res) => expect(res.body.items.length).toBe(10)) - .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) - .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); + describe("/transactions", () => { + //@id1506 + it("Verify the transaction via /transactions", async () => { + const apiRoute = `/transactions`; + + await setTimeout(localConfig.standardPause); //works unstable without timeout + + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) + .expect((res) => expect(res.body.items.length).toBe(10)) + .expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) + .expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); + }); }); }); diff --git a/packages/integration-tests/tests/hooks/global.ts b/packages/integration-tests/tests/hooks/global.ts index 64be34eecf..2512d8878f 100644 --- a/packages/integration-tests/tests/hooks/global.ts +++ b/packages/integration-tests/tests/hooks/global.ts @@ -2,24 +2,15 @@ import { Buffer } from "../../src/entities"; import { Helper } from "../../src/helper"; import { Playbook } from "../../src/playbook/playbook"; -async function globalHook() { +export default async () => { const playbook = new Playbook(); const helper = new Helper(); const bufferRoute = "src/playbook/"; - const bufferFile = bufferRoute + Buffer.L1; - const token = await helper.getStringFromFile(bufferFile); await playbook.deployERC20toL2(); await playbook.deployERC20toL1(); await playbook.depositETH("0.0000001"); + const bufferFile = bufferRoute + Buffer.L1; + const token = await helper.getStringFromFile(bufferFile); await playbook.depositERC20("100", token, 18); -} - -globalHook() - .then(() => { - console.log("Global hook completed successfully."); - }) - .catch((error) => { - console.error(error); - process.exit(1); - }); +}; diff --git a/packages/integration-tests/tests/hooks/local/multiCall.test.ts b/packages/integration-tests/tests/hooks/local/multiCall.test.ts deleted file mode 100644 index c09d9e251b..0000000000 --- a/packages/integration-tests/tests/hooks/local/multiCall.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { localConfig } from "../../../src/config"; -import { Logger } from "../../../src/entities"; -import { Playbook } from "../../../src/playbook/playbook"; - -describe("Multicall transactions", () => { - jest.setTimeout(localConfig.extendedTimeout); - const playbook = new Playbook(); - let txMulticall: string; - - //@id689 - it("Deploy the Multicall contracts", async () => { - const contract: string[] = await playbook.deployMultiCallContracts(); - expect(contract[0]).toContain(Logger.txHashStartsWith); - expect(contract[1]).toContain(Logger.txHashStartsWith); - expect(contract[2]).toContain(Logger.txHashStartsWith); - }); - - //@id690:I --> @id1467 - it("Use the multicall contracts", async () => { - txMulticall = await playbook.useMultiCallContracts(); - expect(txMulticall).toContain(Logger.txHashStartsWith); - }); -}); diff --git a/packages/integration-tests/tests/hooks/local/multiTransfer.test.ts b/packages/integration-tests/tests/hooks/local/multiTransfer.test.ts deleted file mode 100644 index d7ca2a0780..0000000000 --- a/packages/integration-tests/tests/hooks/local/multiTransfer.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { localConfig } from "../../../src/config"; -import { Buffer, Logger } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; - -describe("Mulitransfer ETH", () => { - jest.setTimeout(localConfig.extendedTimeout); - const playbook = new Playbook(); - const helper = new Helper(); - const bufferRoute = "src/playbook/"; - let txMultiTransfer: string[]; - let contract: string; - - beforeEach(async () => { - contract = await helper.getStringFromFile(bufferRoute + Buffer.addressMultiTransferETH); - }); - - //@id690 - it("Deploy the multitransfer ETH contract to the L2", async () => { - contract = await playbook.deployMultiTransferETH(); - expect(contract).toContain(Logger.txHashStartsWith); - }); - - //@id690 --> //@id1477 - it("Call the multitransfer contract to the L2", async () => { - txMultiTransfer = await playbook.useMultiTransferETH(); - expect(txMultiTransfer[0]).toContain(Logger.txHashStartsWith); - expect(txMultiTransfer[1]).toContain(Logger.txHashStartsWith); - expect(txMultiTransfer[2]).toContain(Logger.txHashStartsWith); - }); -}); diff --git a/packages/integration-tests/tests/hooks/local/nft.test.ts b/packages/integration-tests/tests/hooks/local/nft.test.ts deleted file mode 100644 index a8b3b3786d..0000000000 --- a/packages/integration-tests/tests/hooks/local/nft.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { localConfig } from "../../../src/config"; -import { Logger } from "../../../src/entities"; -import { Playbook } from "../../../src/playbook/playbook"; - -describe("NFTs", () => { - jest.setTimeout(localConfig.standardTimeout); - - let deployedToken: string; - - describe("Deploy/check the NFT", () => { - jest.setTimeout(localConfig.standardTimeout); - const playbook = new Playbook(); - - //@id672 - it("Deploy the NFT to L1", async () => { - deployedToken = await playbook.deployNFTtoL1(); - expect(deployedToken).toContain(Logger.txHashStartsWith); - }); - - //@id671 - it("Deploy the NFT to L2", async () => { - deployedToken = await playbook.deployNFTtoL2(); - expect(deployedToken).toContain(Logger.txHashStartsWith); - }); - }); -}); diff --git a/packages/integration-tests/tests/hooks/local/transaction.test.ts b/packages/integration-tests/tests/hooks/local/transaction.test.ts deleted file mode 100644 index 3a78954376..0000000000 --- a/packages/integration-tests/tests/hooks/local/transaction.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { localConfig } from "../../../src/config"; -import { Buffer, Logger } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; - -describe("Transactions", () => { - jest.setTimeout(localConfig.standardTimeout); - const playbook = new Playbook(); - const helper = new Helper(); - const bufferRoute = "src/playbook/"; - let txHash: string; - let token: string; - let contract: string; - let emptyWallet: string; - - describe("Paymaster", () => { - jest.setTimeout(localConfig.extendedTimeout); - - beforeEach(async () => { - token = await helper.getStringFromFile(bufferRoute + Buffer.customToken); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.paymasterTx); - emptyWallet = await helper.getStringFromFile(bufferRoute + Buffer.emptyWalletAddress); - }); - - //@id1450 - it("Deploy contract via Paymaster", async () => { - const result = await playbook.deployViaPaymaster(); - expect(result[0]).toContain(Logger.txHashStartsWith); - }); - - //@id644 - it("Transaction via Paymaster usage", async () => { - const result = await playbook.usePaymaster(); - expect(result).toContain(Logger.txHashStartsWith); - }); - }); - - describe("Transaction with failed state", () => { - beforeAll(async () => { - const bufferFile = bufferRoute + Buffer.L2; - token = await helper.getStringFromFile(bufferFile); - txHash = await playbook.transferFailedState(token); - return [txHash, token]; - }); - }); - - describe("Greeter", () => { - jest.setTimeout(localConfig.extendedTimeout); - - beforeEach(async () => { - contract = await helper.getStringFromFile(bufferRoute + Buffer.greeterL2); - txHash = await helper.getStringFromFile(bufferRoute + Buffer.executeGreeterTx); - }); - - //@id597 - it("Deploy the Greeter contract to the L2", async () => { - contract = await playbook.deployGreeterToL2(); - expect(contract).toContain(Logger.txHashStartsWith); - }); - - //@id604 - it("Use the Greeter contract - execute SetGreeting", async () => { - const executedContract = await playbook.useGreeter(); - expect(executedContract).toContain(Logger.txHashStartsWith); - }); - }); -}); diff --git a/packages/integration-tests/tests/hooks/local/transfers.test.ts b/packages/integration-tests/tests/hooks/local/transfers.test.ts deleted file mode 100644 index 0c12904c57..0000000000 --- a/packages/integration-tests/tests/hooks/local/transfers.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { localConfig } from "../../../src/config"; -import { Buffer } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; - -describe("Transfer", () => { - jest.setTimeout(localConfig.standardTimeout); - const helper = new Helper(); - const playbook = new Playbook(); - const bufferFile = "src/playbook/" + Buffer.L2; - let txHashEth: string; - let txHashCust: string; - let token: string; - - beforeAll(async () => { - token = await helper.getStringFromFile(bufferFile); - txHashEth = await playbook.transferETH("0.000001"); - txHashCust = await playbook.transferERC20("0.01", token, "L2"); - - return [txHashCust, txHashEth]; - }); -}); diff --git a/packages/integration-tests/tests/hooks/local/withdrawal.test.ts b/packages/integration-tests/tests/hooks/local/withdrawal.test.ts deleted file mode 100644 index dc8ada4576..0000000000 --- a/packages/integration-tests/tests/hooks/local/withdrawal.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { localConfig } from "../../../src/config"; -import { Buffer, Token, Wallets } from "../../../src/entities"; -import { Logger } from "../../../src/entities"; -import { Helper } from "../../../src/helper"; -import { Playbook } from "../../../src/playbook/playbook"; - -describe("Withdrawal", () => { - const playbook = new Playbook(); - const helper = new Helper(); - const playbookRoot = "src/playbook"; - const l2Token = playbookRoot + "/" + Buffer.L2deposited; - - let result: string; - jest.setTimeout(localConfig.extendedTimeout); - - describe("Withdrawal ETH to the own address", () => { - //@id639 - it("Make a withdrawal to the own address with 0.0000001 ETH ", async () => { - result = await playbook.withdrawETH(); - await expect(result).not.toBeUndefined(); - await expect(result.includes(Logger.txHashStartsWith)).toBe(true); - }); - }); - - describe("Withdrawal ETH to the other address", () => { - //@id640 - it("Make a withdrawal to the other address with 0.0000001 ETH ", async () => { - result = await playbook.withdrawETHtoOtherAddress(); - await expect(result).not.toBeUndefined(); - await expect(result.includes(Logger.txHashStartsWith)).toBe(true); - }); - }); - - describe("Withdrawal the custom token to the own address", () => { - //@id641 - it("Make the custom token withdrawal to the own address", async () => { - const customToken = await helper.getStringFromFile(l2Token); - result = await playbook.withdrawERC20(customToken); - await expect(result).not.toBeUndefined(); - await expect(result.includes(Logger.txHashStartsWith)).toBe(true); - }); - }); - - describe("Withdrawal the custom token to the other address", () => { - //@id643 - it("Make the custom token withdrawal to the other address", async () => { - const customToken = await helper.getStringFromFile(l2Token); - result = await playbook.withdrawERC20toOtherAddress(customToken); - await expect(result).not.toBeUndefined(); - await expect(result.includes(Logger.txHashStartsWith)).toBe(true); - }); - }); -}); From 4064634171871b953c63985ecb8facb6ec09376e Mon Sep 17 00:00:00 2001 From: abilevych Date: Mon, 6 Nov 2023 18:16:58 +0200 Subject: [PATCH 14/25] chore: fix after lint --- packages/integration-tests/tests/api/batches.test.ts | 3 ++- packages/integration-tests/tests/api/blocks.test.ts | 2 +- packages/integration-tests/tests/api/stats.test.ts | 4 +++- packages/integration-tests/tests/api/transactions.test.ts | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/integration-tests/tests/api/batches.test.ts b/packages/integration-tests/tests/api/batches.test.ts index e934783919..3a8326a8ec 100644 --- a/packages/integration-tests/tests/api/batches.test.ts +++ b/packages/integration-tests/tests/api/batches.test.ts @@ -6,6 +6,7 @@ import { localConfig } from "../../src/config"; describe("/batches", () => { jest.setTimeout(localConfig.standardTimeout); + //@id1513 it("Verify the response via /batches", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout @@ -29,7 +30,7 @@ describe("/batches", () => { }); //@id1514 - xit("Verify the response via /batches/{batchNumber}", async () => { + it("Verify the response via /batches/{batchNumber}", async () => { await setTimeout(localConfig.standardPause); //works unstable without timeout const batches = await request(environment.blockExplorerAPI).get("/batches"); diff --git a/packages/integration-tests/tests/api/blocks.test.ts b/packages/integration-tests/tests/api/blocks.test.ts index a11e97011e..989c07bf9f 100644 --- a/packages/integration-tests/tests/api/blocks.test.ts +++ b/packages/integration-tests/tests/api/blocks.test.ts @@ -31,7 +31,7 @@ describe("/blocks", () => { //@id1512 it("Verify the response via /blocks/{/blockNumber}", async () => { - await setTimeout(localConfig.standardTimeout); //works unstable without timeout + await setTimeout(localConfig.extendedPause); //works unstable without timeout const blocks = await request(environment.blockExplorerAPI).get("/blocks"); diff --git a/packages/integration-tests/tests/api/stats.test.ts b/packages/integration-tests/tests/api/stats.test.ts index e432b7d434..970e947af4 100644 --- a/packages/integration-tests/tests/api/stats.test.ts +++ b/packages/integration-tests/tests/api/stats.test.ts @@ -5,9 +5,11 @@ import { environment } from "../../src/config"; import { localConfig } from "../../src/config"; describe("/stats", () => { + jest.setTimeout(localConfig.standardTimeout); //works unstable without timeout + //@id1515 it("Verify the response via /stats", async () => { - await setTimeout(localConfig.standardPause); //works unstable without timeout + await setTimeout(localConfig.extendedPause); //works unstable without timeout const apiRoute = `/stats`; diff --git a/packages/integration-tests/tests/api/transactions.test.ts b/packages/integration-tests/tests/api/transactions.test.ts index 8a9c553a51..9f446fcd7a 100644 --- a/packages/integration-tests/tests/api/transactions.test.ts +++ b/packages/integration-tests/tests/api/transactions.test.ts @@ -14,9 +14,9 @@ describe("Transactions", () => { const bufferFile = "src/playbook/"; const playbook = new Playbook(); - let contract: any; + let contract: string; let token: string; - let txHash: any; + let txHash: string; beforeAll(async () => { const customToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); From 88cf5b37875f3bd3253773add5c3dad4ce4c0483 Mon Sep 17 00:00:00 2001 From: abilevych Date: Tue, 7 Nov 2023 10:54:14 +0200 Subject: [PATCH 15/25] chore: changed timeouts in addresses api suite --- packages/integration-tests/tests/api/addresses.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integration-tests/tests/api/addresses.test.ts b/packages/integration-tests/tests/api/addresses.test.ts index 599648e1c5..3cca3980e1 100644 --- a/packages/integration-tests/tests/api/addresses.test.ts +++ b/packages/integration-tests/tests/api/addresses.test.ts @@ -8,7 +8,7 @@ import { Helper } from "../../src/helper"; import { Playbook } from "../../src/playbook/playbook"; describe("Address", () => { - jest.setTimeout(localConfig.standardTimeout); + jest.setTimeout(localConfig.extendedTimeout); const helper = new Helper(); const playbook = new Playbook(); From e1ecfa49f49dc50b6d1c1236248e7536d37e2c6e Mon Sep 17 00:00:00 2001 From: abilevych Date: Tue, 7 Nov 2023 11:17:10 +0200 Subject: [PATCH 16/25] chore: optimized addresses/transactions test suites --- packages/integration-tests/src/entities.ts | 1 + .../scenarios/withdrawal/withdrawERC20toOtherAddress.ts | 6 +++++- packages/integration-tests/tests/api/addresses.test.ts | 1 - packages/integration-tests/tests/api/transactions.test.ts | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/integration-tests/src/entities.ts b/packages/integration-tests/src/entities.ts index 33274f8c1f..4bf2a48e8a 100644 --- a/packages/integration-tests/src/entities.ts +++ b/packages/integration-tests/src/entities.ts @@ -21,6 +21,7 @@ export enum Buffer { txUseMultiCallContracts = "./buffer/txUseMultiCallContracts.txt", txEthTransfer = "./buffer/txEthTransfer.txt", txERC20Withdraw = "./buffer/txERC20Withdraw.txt", + txERC20WithdrawOtherAddress = "./buffer/txERC20WithdrawOtherAddress.txt", txEthWithdraw = "./buffer/txEthWithdraw.txt", txEthWithdrawOtherAddress = "./buffer/txEthWithdrawOtherAddress.txt", txERC20Transfer = "./buffer/txERC20Transfer.txt", diff --git a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts index ab92a9c326..cf377733b6 100644 --- a/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts +++ b/packages/integration-tests/src/playbook/scenarios/withdrawal/withdrawERC20toOtherAddress.ts @@ -1,8 +1,9 @@ import * as ethers from "ethers"; +import { promises as fs } from "fs"; import * as zksync from "zksync-web3"; import { localConfig } from "../../../config"; -import { Logger, Wallets } from "../../../entities"; +import { Buffer, Logger, Wallets } from "../../../entities"; import { Helper } from "../../../helper"; export const withdrawERC20toOtherAddress = async function (tokenAddress: string, sum = "0.2") { @@ -11,6 +12,8 @@ export const withdrawERC20toOtherAddress = async function (tokenAddress: string, const ethProvider = ethers.getDefaultProvider(localConfig.L1Network); const syncWallet = new zksync.Wallet(localConfig.privateKey, syncProvider, ethProvider); const bridges = await syncProvider.getDefaultBridgeAddresses(); + const playbookRoot = "src/playbook/"; + const bufferFile = playbookRoot + Buffer.txERC20WithdrawOtherAddress; const balance = await syncWallet.getBalance(tokenAddress); @@ -34,6 +37,7 @@ export const withdrawERC20toOtherAddress = async function (tokenAddress: string, console.log(`Your balance is ${balanceAfter.toString()}`); await helper.txHashLogger(Logger.withdraw, txHash, "Custom token"); + await fs.writeFile(bufferFile, txHash); return txHash; }; diff --git a/packages/integration-tests/tests/api/addresses.test.ts b/packages/integration-tests/tests/api/addresses.test.ts index 3cca3980e1..2fb5edca53 100644 --- a/packages/integration-tests/tests/api/addresses.test.ts +++ b/packages/integration-tests/tests/api/addresses.test.ts @@ -149,7 +149,6 @@ describe("Address", () => { describe("/address/{address}/logs", () => { beforeAll(async () => { - await playbook.deployGreeterToL2(); await playbook.useGreeter(); }); diff --git a/packages/integration-tests/tests/api/transactions.test.ts b/packages/integration-tests/tests/api/transactions.test.ts index 9f446fcd7a..c6562bd36e 100644 --- a/packages/integration-tests/tests/api/transactions.test.ts +++ b/packages/integration-tests/tests/api/transactions.test.ts @@ -22,6 +22,7 @@ describe("Transactions", () => { const customToken = await helper.getStringFromFile(bufferFile + Buffer.L2deposited); await playbook.withdrawETHtoOtherAddress(); await playbook.withdrawERC20(customToken); + await playbook.withdrawERC20toOtherAddress(customToken); await playbook.withdrawETH(); await playbook.deployMultiTransferETH(); await playbook.useMultiTransferETH(); @@ -152,7 +153,7 @@ describe("Transactions", () => { const customTokenL1 = await helper.getStringFromFile(l1Token); const l2Token = bufferFile + "/" + Buffer.L2deposited; const customTokenL2 = await helper.getStringFromFile(l2Token); - txHash = await playbook.withdrawERC20toOtherAddress(customTokenL2); + txHash = await helper.getStringFromFile(bufferFile + Buffer.txERC20WithdrawOtherAddress); const apiRoute = `/transactions/${txHash}/transfers`; From 96bce3722c9b008210e1105d748c8b7c4cc0985f Mon Sep 17 00:00:00 2001 From: pcheremu Date: Wed, 8 Nov 2023 14:04:14 +0100 Subject: [PATCH 17/25] test: fix git runner and test issues --- .github/workflows/app-e2e.yml | 18 +++++------------- .github/workflows/release.yml | 2 +- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/app-e2e.yml b/.github/workflows/app-e2e.yml index 42842c52cd..f9b5416559 100644 --- a/.github/workflows/app-e2e.yml +++ b/.github/workflows/app-e2e.yml @@ -33,7 +33,7 @@ env: jobs: e2e: - runs-on: [self-hosted, ci-runner] + runs-on: [matterlabs-ci-runner] permissions: contents: read defaults: @@ -64,22 +64,14 @@ jobs: with: fetch-depth: 0 - - name: Cache node modules - id: cache-nodemodules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules + - name: Setup Node.js + uses: actions/setup-node@v3 with: - path: node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + node-version: '18' + cache: 'npm' - name: Install dependencies working-directory: ./ - if: steps.cache-nodemodules.outputs.cache-hit != 'true' run: | npm pkg delete scripts.prepare npm ci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 441cab4269..4c9060f634 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,7 +55,7 @@ jobs: deployBackendToStaging: name: Deploy Block Explorer backend to staging - runs-on: [self-hosted, ci-runner] + runs-on: [matterlabs-ci-runner] permissions: contents: read needs: createReleaseVersion From cf1859800d07ac5b9c54701ab4374d7898580387 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 9 Nov 2023 01:07:05 +0100 Subject: [PATCH 18/25] test: test with a cache --- .github/workflows/app-deploy-feature-branch.yml | 8 ++++---- .github/workflows/app-e2e.yml | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/app-deploy-feature-branch.yml b/.github/workflows/app-deploy-feature-branch.yml index 5b862b4edd..7801779b65 100644 --- a/.github/workflows/app-deploy-feature-branch.yml +++ b/.github/workflows/app-deploy-feature-branch.yml @@ -36,11 +36,11 @@ jobs: run: | npm run lint -- --no-fix --max-warnings 0 - - name: Test - run: npm run test:ci + # - name: Test + # run: npm run test:ci - - name: Type check - run: npm run typecheck + # - name: Type check + # run: npm run typecheck - name: Build run: | diff --git a/.github/workflows/app-e2e.yml b/.github/workflows/app-e2e.yml index f9b5416559..114499f4bc 100644 --- a/.github/workflows/app-e2e.yml +++ b/.github/workflows/app-e2e.yml @@ -70,8 +70,24 @@ jobs: node-version: '18' cache: 'npm' + - name: Cache node modules + id: cache-nodemodules + uses: actions/cache@v3 + env: + cache-name: cache-node-modules + # Workaround for bug https://github.com/typicode/husky/issues/991 + HUSKY: 0 + with: + path: node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Install dependencies working-directory: ./ + if: steps.cache-nodemodules.outputs.cache-hit != 'true' run: | npm pkg delete scripts.prepare npm ci From d15df2c358b78c2dee73d713a9b745fe63bb7b85 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 9 Nov 2023 01:42:23 +0100 Subject: [PATCH 19/25] test: test with a node --- .github/workflows/app-e2e.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/app-e2e.yml b/.github/workflows/app-e2e.yml index 114499f4bc..7642608e40 100644 --- a/.github/workflows/app-e2e.yml +++ b/.github/workflows/app-e2e.yml @@ -64,11 +64,11 @@ jobs: with: fetch-depth: 0 - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - cache: 'npm' + # - name: Setup Node.js + # uses: actions/setup-node@v3 + # with: + # node-version: '18' + # cache: 'npm' - name: Cache node modules id: cache-nodemodules From 43ba8464453131a3c71b08b89ddd5d28fa3259d4 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 9 Nov 2023 01:55:33 +0100 Subject: [PATCH 20/25] test: test with a cleaned cache in advance --- .github/workflows/app-deploy-feature-branch.yml | 8 ++++---- .github/workflows/app-e2e.yml | 6 ------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/app-deploy-feature-branch.yml b/.github/workflows/app-deploy-feature-branch.yml index 7801779b65..5b862b4edd 100644 --- a/.github/workflows/app-deploy-feature-branch.yml +++ b/.github/workflows/app-deploy-feature-branch.yml @@ -36,11 +36,11 @@ jobs: run: | npm run lint -- --no-fix --max-warnings 0 - # - name: Test - # run: npm run test:ci + - name: Test + run: npm run test:ci - # - name: Type check - # run: npm run typecheck + - name: Type check + run: npm run typecheck - name: Build run: | diff --git a/.github/workflows/app-e2e.yml b/.github/workflows/app-e2e.yml index 7642608e40..6ea8d996c5 100644 --- a/.github/workflows/app-e2e.yml +++ b/.github/workflows/app-e2e.yml @@ -64,12 +64,6 @@ jobs: with: fetch-depth: 0 - # - name: Setup Node.js - # uses: actions/setup-node@v3 - # with: - # node-version: '18' - # cache: 'npm' - - name: Cache node modules id: cache-nodemodules uses: actions/cache@v3 From 9c990c09669857ccac369739777397579b6c8a02 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 9 Nov 2023 02:08:27 +0100 Subject: [PATCH 21/25] test: test with a node --- .github/workflows/app-e2e.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/app-e2e.yml b/.github/workflows/app-e2e.yml index 6ea8d996c5..51cde34503 100644 --- a/.github/workflows/app-e2e.yml +++ b/.github/workflows/app-e2e.yml @@ -57,13 +57,19 @@ jobs: name: '${{ matrix.tags }}' container: - image: mcr.microsoft.com/playwright:v1.27.0-focal + image: mcr.microsoft.com/playwright:v1.39.0-jammy options: --user root steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + - name: Cache node modules id: cache-nodemodules uses: actions/cache@v3 From 3b0693e2c295877b98c51b3909ab05a99a2d2de0 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 9 Nov 2023 02:26:28 +0100 Subject: [PATCH 22/25] test: test with a cache --- .github/workflows/app-deploy-feature-branch.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/app-deploy-feature-branch.yml b/.github/workflows/app-deploy-feature-branch.yml index 5b862b4edd..f2523a13e3 100644 --- a/.github/workflows/app-deploy-feature-branch.yml +++ b/.github/workflows/app-deploy-feature-branch.yml @@ -26,8 +26,24 @@ jobs: node-version: '18' cache: 'npm' + - name: Cache node modules + id: cache-nodemodules + uses: actions/cache@v3 + env: + cache-name: cache-node-modules + # Workaround for bug https://github.com/typicode/husky/issues/991 + HUSKY: 0 + with: + path: node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Install dependencies working-directory: ./ + if: steps.cache-nodemodules.outputs.cache-hit != 'true' run: | npm pkg delete scripts.prepare npm ci From 19e525140f84d8cdeba0d5bf8928d53183d57391 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 9 Nov 2023 02:40:55 +0100 Subject: [PATCH 23/25] test: refactoring --- .github/workflows/app-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/app-e2e.yml b/.github/workflows/app-e2e.yml index 51cde34503..ff75de8c83 100644 --- a/.github/workflows/app-e2e.yml +++ b/.github/workflows/app-e2e.yml @@ -57,7 +57,7 @@ jobs: name: '${{ matrix.tags }}' container: - image: mcr.microsoft.com/playwright:v1.39.0-jammy + image: mcr.microsoft.com/playwright:v1.27.0-focal options: --user root steps: - uses: actions/checkout@v3 From 8831d1b4aacb3527bc1b26171694f57295f5896f Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 9 Nov 2023 02:53:31 +0100 Subject: [PATCH 24/25] test: refactoring --- .github/workflows/app-deploy-feature-branch.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/app-deploy-feature-branch.yml b/.github/workflows/app-deploy-feature-branch.yml index f2523a13e3..5b862b4edd 100644 --- a/.github/workflows/app-deploy-feature-branch.yml +++ b/.github/workflows/app-deploy-feature-branch.yml @@ -26,24 +26,8 @@ jobs: node-version: '18' cache: 'npm' - - name: Cache node modules - id: cache-nodemodules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - # Workaround for bug https://github.com/typicode/husky/issues/991 - HUSKY: 0 - with: - path: node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Install dependencies working-directory: ./ - if: steps.cache-nodemodules.outputs.cache-hit != 'true' run: | npm pkg delete scripts.prepare npm ci From 427d64a14a1a4c31448443ac6dc325a2e1602015 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Thu, 9 Nov 2023 12:41:03 +0100 Subject: [PATCH 25/25] test: remove an issue workaround for husky --- .github/workflows/app-e2e.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/app-e2e.yml b/.github/workflows/app-e2e.yml index ff75de8c83..5ca7ad825d 100644 --- a/.github/workflows/app-e2e.yml +++ b/.github/workflows/app-e2e.yml @@ -75,8 +75,6 @@ jobs: uses: actions/cache@v3 env: cache-name: cache-node-modules - # Workaround for bug https://github.com/typicode/husky/issues/991 - HUSKY: 0 with: path: node_modules key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}