Skip to content

Commit

Permalink
test: comment logs test
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Dec 13, 2023
1 parent 1c76418 commit 74226c9
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions packages/integration-tests/tests/api/logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Buffer } from "../../src/entities";
import { Helper } from "../../src/helper";
import { Playbook } from "../../src/playbook/playbook";

describe("Logs API", () => {
xdescribe("Logs API", () => {
jest.setTimeout(localConfig.standardTimeout); //works unstable without timeout
const helper = new Helper();
const bufferFile = "src/playbook/";
Expand All @@ -23,42 +23,44 @@ describe("Logs API", () => {
//@id1808
it("Verify the response via /api?module=logs&action=getLogs&page={page}&offset={offset}0&toBlock={toBlock}&fromBlock={fromBlock}&address={address}", async () => {
contractAddress = await helper.getStringFromFile(bufferFile + Buffer.greeterL2);
// txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx);
txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx);

const apiRoute = `/api?module=logs&action=getLogs&page=1&offset=10&toBlock=10000&fromBlock=1&address=${contractAddress}`;

return request(environment.blockExplorerAPI)
.get(apiRoute)
.expect(200)
.expect((res) => expect(typeof res.body.status).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.message).toStrictEqual("string"));
// .expect((res) => expect(res.body.result[0]).toStrictEqual(expect.objectContaining({ address: contractAddress })))
// .expect((res) => expect(Array.isArray(res.body.result[0].topics)).toStrictEqual(true))
// .expect((res) => expect(typeof res.body.result[0].topics[0]).toStrictEqual("string"))
// .expect((res) => expect(res.body.result[0].topics[0].startsWith("0x")).toBe(true))
// .expect((res) => expect(res.body.result[0].topics[0].length).toBe(66))
// .expect((res) => expect(typeof res.body.result[0].data).toStrictEqual("string"))
// .expect((res) => expect(res.body.result[0].data.startsWith("0x")).toBe(true))
// .expect((res) => expect(res.body.result[0].data.length).toBe(194))
// .expect((res) => expect(typeof res.body.result[0].blockNumber).toStrictEqual("string"))
// .expect((res) => expect(res.body.result[0].blockNumber.startsWith("0x")).toBe(true))
// .expect((res) => expect(res.body.result[0].blockNumber.length).toBe(5))
// .expect((res) => expect(typeof res.body.result[0].timeStamp).toStrictEqual("string"))
// .expect((res) => expect(res.body.result[0].timeStamp.startsWith("0x")).toBe(true))
// .expect((res) => expect(res.body.result[0].timeStamp.length).toBe(10))
// .expect((res) => expect(typeof res.body.result[0].gasPrice).toStrictEqual("string"))
// .expect((res) => expect(res.body.result[0].gasPrice.startsWith("0x")).toBe(true))
// .expect((res) => expect(res.body.result[0].gasPrice.length).toBe(9))
// .expect((res) => expect(typeof res.body.result[0].gasUsed).toStrictEqual("string"))
// .expect((res) => expect(res.body.result[0].gasUsed.startsWith("0x")).toBe(true))
// .expect((res) => expect(res.body.result[0].gasUsed.length).toBe(7))
// .expect((res) => expect(typeof res.body.result[0].logIndex).toStrictEqual("string"))
// .expect((res) => expect(res.body.result[0].logIndex.startsWith("0x")).toBe(true))
// .expect((res) => expect(res.body.result[0].logIndex.length).toBe(3))
// .expect((res) => expect(res.body.result[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash })))
// .expect((res) => expect(typeof res.body.result[0].transactionIndex).toStrictEqual("string"))
// .expect((res) => expect(res.body.result[0].transactionIndex.startsWith("0x")).toBe(true))
// .expect((res) => expect(res.body.result[0].transactionIndex.length).toBe(3));
.expect((res) => expect(typeof res.body.message).toStrictEqual("string"))
.expect((res) =>
expect(res.body.result[0]).toStrictEqual(expect.objectContaining({ address: contractAddress }))
)
.expect((res) => expect(Array.isArray(res.body.result[0].topics)).toStrictEqual(true))
.expect((res) => expect(typeof res.body.result[0].topics[0]).toStrictEqual("string"))
.expect((res) => expect(res.body.result[0].topics[0].startsWith("0x")).toBe(true))
.expect((res) => expect(res.body.result[0].topics[0].length).toBe(66))
.expect((res) => expect(typeof res.body.result[0].data).toStrictEqual("string"))
.expect((res) => expect(res.body.result[0].data.startsWith("0x")).toBe(true))
.expect((res) => expect(res.body.result[0].data.length).toBe(194))
.expect((res) => expect(typeof res.body.result[0].blockNumber).toStrictEqual("string"))
.expect((res) => expect(res.body.result[0].blockNumber.startsWith("0x")).toBe(true))
.expect((res) => expect(res.body.result[0].blockNumber.length).toBe(5))
.expect((res) => expect(typeof res.body.result[0].timeStamp).toStrictEqual("string"))
.expect((res) => expect(res.body.result[0].timeStamp.startsWith("0x")).toBe(true))
.expect((res) => expect(res.body.result[0].timeStamp.length).toBe(10))
.expect((res) => expect(typeof res.body.result[0].gasPrice).toStrictEqual("string"))
.expect((res) => expect(res.body.result[0].gasPrice.startsWith("0x")).toBe(true))
.expect((res) => expect(res.body.result[0].gasPrice.length).toBe(9))
.expect((res) => expect(typeof res.body.result[0].gasUsed).toStrictEqual("string"))
.expect((res) => expect(res.body.result[0].gasUsed.startsWith("0x")).toBe(true))
.expect((res) => expect(res.body.result[0].gasUsed.length).toBe(7))
.expect((res) => expect(typeof res.body.result[0].logIndex).toStrictEqual("string"))
.expect((res) => expect(res.body.result[0].logIndex.startsWith("0x")).toBe(true))
.expect((res) => expect(res.body.result[0].logIndex.length).toBe(3))
.expect((res) => expect(res.body.result[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash })))
.expect((res) => expect(typeof res.body.result[0].transactionIndex).toStrictEqual("string"))
.expect((res) => expect(res.body.result[0].transactionIndex.startsWith("0x")).toBe(true))
.expect((res) => expect(res.body.result[0].transactionIndex.length).toBe(3));
});
});
});

0 comments on commit 74226c9

Please sign in to comment.