Skip to content

Commit

Permalink
test: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Jan 5, 2024
1 parent f9f98a3 commit 3a0f377
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions packages/integration-tests/tests/api/accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,40 +88,38 @@ describe("Accounts API", () => {

await setTimeout(localConfig.extendedPause); //works unstable without timeout

return (
request(environment.blockExplorerAPI)
.get(apiRoute)
.expect(200)
.expect((res) => expect(res.body.result.length).toBeGreaterThan(1))
.expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ status: "1" })))
.expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ message: "OK" })))
.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].hash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].nonce).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].blockHash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].transactionIndex).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].from).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].to).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].value).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].gas).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].gasPrice).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].isError).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].txreceipt_status).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].input).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].contractAddress).toBeTruthy()) // can be null
.expect((res) => expect(typeof res.body.result[0].cumulativeGasUsed).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].gasUsed).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].confirmations).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].fee).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].commitTxHash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].proveTxHash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].executeTxHash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].isL1Originated).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].l1BatchNumber).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].methodId).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].functionName).toStrictEqual("string"))
);
return request(environment.blockExplorerAPI)
.get(apiRoute)
.expect(200)
.expect((res) => expect(res.body.result.length).toBeGreaterThan(1))
.expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ status: "1" })))
.expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ message: "OK" })))
.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].hash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].nonce).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].blockHash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].transactionIndex).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].from).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].to).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].value).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].gas).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].gasPrice).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].isError).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].txreceipt_status).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].input).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].contractAddress).toBeTruthy()) // can be null
.expect((res) => expect(typeof res.body.result[0].cumulativeGasUsed).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].gasUsed).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].confirmations).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].fee).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].commitTxHash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].proveTxHash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].executeTxHash).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].isL1Originated).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].l1BatchNumber).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].methodId).toStrictEqual("string"))
.expect((res) => expect(typeof res.body.result[0].functionName).toStrictEqual("string"));
}
);
});

0 comments on commit 3a0f377

Please sign in to comment.