-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: covering Contract API and Logs API endpoints
- Loading branch information
1 parent
f7ddfe6
commit 682dba5
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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 { Helper } from "../../src/helper"; | ||
|
||
describe("Contracts", () => { | ||
jest.setTimeout(localConfig.standardTimeout); | ||
|
||
const helper = new Helper(); | ||
const bufferFile = "src/playbook/"; | ||
let paymasterContract: string; | ||
let paymasterTx: string; | ||
|
||
beforeAll(async () => { | ||
paymasterContract = await helper.getStringFromFile(bufferFile + Buffer.paymaster); | ||
paymasterTx = await helper.getStringFromFile(bufferFile + Buffer.paymasterDeployTx); | ||
}); | ||
|
||
describe("/api?module=contract&action=getcontractcreation", () => { | ||
jest.setTimeout(localConfig.standardTimeout); //works unstable without timeout | ||
|
||
//@id1696 | ||
it("Verify the response via /api?module=contract&action=getcontractcreation", async () => { | ||
await setTimeout(localConfig.extendedPause); //works unstable without timeout | ||
const apiRoute = `/api?module=contract&action=getcontractcreation&contractaddresses=${paymasterContract}`; | ||
return request(environment.blockExplorerAPI) | ||
.get(apiRoute) | ||
.expect(200) | ||
.expect((res) => | ||
expect(res.body.result[0]).toStrictEqual(expect.objectContaining({ contractAddress: paymasterContract })) | ||
) | ||
.expect((res) => | ||
expect(res.body.result[0]).toStrictEqual( | ||
expect.objectContaining({ contractCreator: Wallets.richWalletAddress }) | ||
) | ||
) | ||
.expect((res) => expect(res.body.result[0]).toStrictEqual(expect.objectContaining({ txHash: paymasterTx }))); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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 { Helper } from "../../src/helper"; | ||
|
||
describe("Logs", () => { | ||
jest.setTimeout(localConfig.standardTimeout); //works unstable without timeout | ||
const helper = new Helper(); | ||
const bufferFile = "src/playbook/"; | ||
let contractAddress: string; | ||
|
||
beforeAll(async () => { | ||
contractAddress = await helper.getStringFromFile(bufferFile + Buffer.customToken); | ||
}); | ||
|
||
describe("/api?module=logs&action=getLogs", () => { | ||
//@id1808 | ||
it("Verify the response via /api?module=logs&action=getLogs", async () => { | ||
await setTimeout(localConfig.extendedPause); //works unstable without timeout | ||
|
||
const apiRoute = `/api?module=logs&action=getLogs&page=1&offset=1&toBlock=1000&fromBlock=1&address=${contractAddress}`; | ||
|
||
return request(environment.blockExplorerAPI) | ||
.get(apiRoute) | ||
.expect(200) | ||
.expect((res) => | ||
expect(res.body.result[0]).toStrictEqual(expect.objectContaining({ address: contractAddress })) | ||
) | ||
.expect((res) => expect(typeof res.body.result[0].topics[0]).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.result[0].data).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.result[0].blockNumber).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.result[0].timeStamp).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.result[0].gasPrice).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.result[0].gasUsed).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.result[0].logIndex).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.result[0].transactionHash).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.result[0].transactionIndex).toStrictEqual("string")); | ||
}); | ||
}); | ||
}); |