Skip to content

Commit

Permalink
test: create autotest for Accounts tc1854
Browse files Browse the repository at this point in the history
  • Loading branch information
amelnytskyi committed Feb 27, 2024
1 parent d8d0a70 commit ebe0656
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/integration-tests/src/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum Buffer {
paymasterTx = "./buffer/paymasterTx.txt",
addressMultiTransferETH = "./buffer/multiTransferETH.txt",
txMultiTransferETH = "./buffer/txMultiTransferETH.txt",
txMultiTransferCall = "./buffer/txMultiTransferCall.txt",
txMultiTransferCustomTokenI = "./buffer/txMultiTransferCustomTokenI.txt",
txMultiTransferCustomTokenII = "./buffer/txMultiTransferCustomTokenII.txt",
addressMultiCallMiddle = "./buffer/multiCallMiddle.txt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen
);
if (transferFromContract) {
console.log(`Contract transfer to us!`);
const transferReceipt = await transferFromContract.wait(1);
console.log(`Contract transfer transaction hash: ${transferReceipt.transactionHash}`);
await fs.writeFile(Buffer.txMultiTransferCall, transferReceipt.transactionHash);
} else {
console.error(`Contract said something unexpected: ${transferFromContract}`);
}
Expand Down
34 changes: 33 additions & 1 deletion packages/integration-tests/tests/api/accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Helper } from "../../src/helper";
import { Playbook } from "../../src/playbook/playbook";

describe("API module: Account", () => {
jest.setTimeout(localConfig.standardTimeout);
jest.setTimeout(localConfig.extendedTimeout);

const helper = new Helper();
const bufferFile = "src/playbook/";
Expand Down Expand Up @@ -259,5 +259,37 @@ describe("API module: Account", () => {
expect(typeof response.body.result[0].blockReward).toStrictEqual("string");
});
});

//id1854
it("Verify /api?module=account&action=txlistinternal&txhash=", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
const txHash = await helper.getStringFromFile(bufferFile + Buffer.txMultiTransferCall);
apiRoute = `/api?module=account&action=txlistinternal&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&txhash=${txHash}`;
response = await helper.performGETrequest(apiRoute);

expect(response.status).toBe(200);
expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" }));
expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ hash: txHash }));
expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ to: Wallets.richWalletAddress }));
expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ type: "call" }));
expect(typeof response.body.result[0].blockNumber).toStrictEqual("string");
expect(typeof response.body.result[0].timeStamp).toStrictEqual("string");
expect(typeof response.body.result[0].from).toStrictEqual("string");
expect(typeof response.body.result[0].value).toStrictEqual("string");
expect(typeof response.body.result[0].gas).toStrictEqual("string");
expect(typeof response.body.result[0].input).toStrictEqual("string");
expect(typeof response.body.result[0].contractAddress).toBeTruthy();
expect(typeof response.body.result[0].gasUsed).toStrictEqual("string");
expect(typeof response.body.result[0].fee).toStrictEqual("string");
expect(typeof response.body.result[0].l1BatchNumber).toStrictEqual("string");
expect(typeof response.body.result[0].traceId).toBeTruthy();
expect(typeof response.body.result[0].transactionType).toStrictEqual("string");
expect(typeof response.body.result[0].isError).toStrictEqual("string");
expect(typeof response.body.result[0].errCode).toStrictEqual("string");
});
});
});
});

0 comments on commit ebe0656

Please sign in to comment.