-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathlogs.test.ts
62 lines (57 loc) · 3.37 KB
/
logs.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { localConfig } from "../../src/config";
import { Buffer } from "../../src/entities";
import { Helper } from "../../src/helper";
import { Playbook } from "../../src/playbook/playbook";
describe("API module: Logs", () => {
jest.setTimeout(localConfig.standardTimeout); //works unstable without timeout
const helper = new Helper();
const bufferFile = "src/playbook/";
const playbook = new Playbook();
let apiRoute: string;
let contractAddress: string;
let response;
let txHash: string;
describe("/api?module=logs&action=getLogs", () => {
beforeAll(async () => {
await playbook.deployGreeterToL2();
await playbook.useGreeter();
});
//@id1808
it("Verify /api?module=logs&action=getLogs&page={page}&offset={offset}0&toBlock={toBlock}&fromBlock={fromBlock}&address={address} response", async () => {
await helper.retryTestAction(async () => {
contractAddress = await helper.getStringFromFile(bufferFile + Buffer.greeterL2);
txHash = await helper.getStringFromFile(bufferFile + Buffer.executeGreeterTx);
apiRoute = `/api?module=logs&action=getLogs&page=1&offset=10&toBlock=10000&fromBlock=1&address=${contractAddress}`;
response = await helper.performGETrequest(apiRoute);
expect(response.status).toBe(200);
expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ address: contractAddress }));
expect(Array.isArray(response.body.result[0].topics)).toStrictEqual(true);
expect(typeof response.body.result[0].topics[0]).toStrictEqual("string");
expect(response.body.result[0].topics[0].startsWith("0x")).toBe(true);
expect(response.body.result[0].topics[0].length).toBe(66);
expect(typeof response.body.result[0].data).toStrictEqual("string");
expect(response.body.result[0].data.startsWith("0x")).toBe(true);
expect(response.body.result[0].data.length).toBe(194);
expect(typeof response.body.result[0].blockNumber).toStrictEqual("string");
expect(response.body.result[0].blockNumber.startsWith("0x")).toBe(true);
expect(response.body.result[0].blockNumber.length).toBe(3);
expect(typeof response.body.result[0].timeStamp).toStrictEqual("string");
expect(response.body.result[0].timeStamp.startsWith("0x")).toBe(true);
expect(response.body.result[0].timeStamp.length).toBe(10);
expect(typeof response.body.result[0].gasPrice).toStrictEqual("string");
expect(response.body.result[0].gasPrice.startsWith("0x")).toBe(true);
expect(response.body.result[0].gasPrice.length).toBe(9);
expect(typeof response.body.result[0].gasUsed).toStrictEqual("string");
expect(response.body.result[0].gasUsed.startsWith("0x")).toBe(true);
expect(response.body.result[0].gasUsed.length).toBe(7);
expect(typeof response.body.result[0].logIndex).toStrictEqual("string");
expect(response.body.result[0].logIndex.startsWith("0x")).toBe(true);
expect(response.body.result[0].logIndex.length).toBe(3);
expect(response.body.result[0]).toStrictEqual(expect.objectContaining({ transactionHash: txHash }));
expect(typeof response.body.result[0].transactionIndex).toStrictEqual("string");
expect(response.body.result[0].transactionIndex.startsWith("0x")).toBe(true);
expect(response.body.result[0].transactionIndex.length).toBe(3);
});
});
});
});