-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: re-structure test suites for batches, stats, blocks endpoints
- Loading branch information
Showing
10 changed files
with
160 additions
and
182 deletions.
There are no files selected for viewing
146 changes: 0 additions & 146 deletions
146
packages/integration-tests/tests/api/common/endpoints.test.ts
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
packages/integration-tests/tests/api/common/endpoints/batches-endpoints.test.ts
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,60 @@ | ||
import * as request from "supertest"; | ||
import { setTimeout } from "timers/promises"; | ||
|
||
import { environment } from "../../../../src/config"; | ||
import { localConfig } from "../../../../src/config"; | ||
|
||
describe("/batches", () => { | ||
jest.setTimeout(localConfig.standardTimeout); | ||
//@id1513 | ||
it("Verify the response via /batches", async () => { | ||
const apiRoute = `/batches`; | ||
|
||
await setTimeout(localConfig.standardPause); //works unstable without timeout | ||
|
||
return request(environment.blockExplorerAPI) | ||
.get(apiRoute) | ||
.expect(200) | ||
.expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) | ||
.expect((res) => expect(res.body.items.length).toBeGreaterThanOrEqual(1)) | ||
.expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); | ||
}); | ||
|
||
//@id1514 | ||
it("Verify the response via /batches/{batchNumber}", async () => { | ||
const batches = await request(environment.blockExplorerAPI).get("/batches"); | ||
|
||
const batchNumber = batches.body.items[0].number; | ||
|
||
const apiRoute = `/batches/${batchNumber}`; | ||
|
||
await setTimeout(localConfig.standardPause); //works unstable without timeout | ||
|
||
return request(environment.blockExplorerAPI) | ||
.get(apiRoute) | ||
.expect(200) | ||
.expect((res) => expect(res.body.number).toStrictEqual(batchNumber)) | ||
.expect((res) => expect(typeof res.body.timestamp).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.rootHash).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.executedAt).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.l1TxCount).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.l2TxCount).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.commitTxHash).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.committedAt).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.proveTxHash).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.provenAt).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.executeTxHash).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.l1GasPrice).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.l2FairGasPrice).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.size).toStrictEqual("number")) | ||
.expect((res) => expect(res.body.status).toStrictEqual("verified")); | ||
}); | ||
}); |
68 changes: 68 additions & 0 deletions
68
packages/integration-tests/tests/api/common/endpoints/blocks-endpoints.test.ts
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,68 @@ | ||
import * as request from "supertest"; | ||
import { setTimeout } from "timers/promises"; | ||
|
||
import { environment } from "../../../../src/config"; | ||
import { localConfig } from "../../../../src/config"; | ||
|
||
describe("/blocks", () => { | ||
jest.setTimeout(localConfig.standardTimeout); | ||
|
||
//@id1511 | ||
it("Verify the response via /blocks", async () => { | ||
const apiRoute = `/blocks`; | ||
|
||
await setTimeout(localConfig.extendedPause); //works unstable without timeout | ||
|
||
return request(environment.blockExplorerAPI) | ||
.get(apiRoute) | ||
.expect(200) | ||
.expect((res) => expect(Array.isArray(res.body.items)).toStrictEqual(true)) | ||
.expect((res) => expect(res.body.items.length).toBeGreaterThan(1)) | ||
.expect((res) => expect(typeof res.body.meta.totalItems).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.meta.itemCount).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.meta.itemsPerPage).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.meta.totalPages).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.meta.currentPage).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.links.first).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.links.previous).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.links.next).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.links.last).toStrictEqual("string")); | ||
}); | ||
|
||
//@id1512 | ||
it("Verify the response via /blocks/{/blockNumber}", async () => { | ||
const blocks = await request(environment.blockExplorerAPI).get("/blocks"); | ||
|
||
const blockNumber = blocks.body.items[0].number; | ||
|
||
const apiRoute = `/blocks/${blockNumber}`; | ||
|
||
await setTimeout(localConfig.extendedPause); //works unstable without timeout | ||
|
||
return ( | ||
request(environment.blockExplorerAPI) | ||
.get(apiRoute) | ||
.expect(200) | ||
.expect((res) => expect(res.body.number).toStrictEqual(blockNumber)) | ||
.expect((res) => expect(typeof res.body.hash).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.timestamp).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.gasUsed).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.l1BatchNumber).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.l1TxCount).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.l2TxCount).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.parentHash).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.gasLimit).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.baseFeePerGas).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.extraData).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.size).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.status).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.isL1BatchSealed).toStrictEqual("boolean")) | ||
.expect((res) => expect(typeof res.body.commitTxHash).toStrictEqual("string")) | ||
// .expect((res) => expect(typeof res.body.commitTxHash).toStrictEqual("string")) //unstable on a CI | ||
.expect((res) => expect(typeof res.body.proveTxHash).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.committedAt).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.executedAt).toStrictEqual("string")) | ||
.expect((res) => expect(typeof res.body.provenAt).toStrictEqual("string")) | ||
); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/integration-tests/tests/api/common/endpoints/stats-endpoints.test.ts
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,24 @@ | ||
import * as request from "supertest"; | ||
import { setTimeout } from "timers/promises"; | ||
|
||
import { environment } from "../../../../src/config"; | ||
import { localConfig } from "../../../../src/config"; | ||
|
||
describe("/stats", () => { | ||
jest.setTimeout(localConfig.standardTimeout); | ||
//@id1515 | ||
it("Verify the response via /stats", async () => { | ||
const apiRoute = `/stats`; | ||
|
||
await setTimeout(localConfig.standardPause); //works unstable without timeout | ||
|
||
return request(environment.blockExplorerAPI) | ||
.get(apiRoute) | ||
.expect(200) | ||
.expect((res) => expect(typeof res.body.lastSealedBatch).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.lastVerifiedBatch).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.lastSealedBlock).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.lastVerifiedBlock).toStrictEqual("number")) | ||
.expect((res) => expect(typeof res.body.totalTransactions).toStrictEqual("number")); | ||
}); | ||
}); |
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
12 changes: 2 additions & 10 deletions
12
packages/integration-tests/tests/api/transactions/multiCall.test.ts
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
7 changes: 2 additions & 5 deletions
7
packages/integration-tests/tests/api/transactions/transaction.test.ts
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