-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
debug_getHistoricalSummaries
endpoint (#7245)
* feat: add new getHistoricalSummaries endpoint to debug namespace * Add JSON response * Restructure to use stateId and add proof to response * add test scaffolding * Address feedback * Move getHistoricalSummaries to lodestar namespace * add lodestar namespace unit test * update route name to lodestar namespace * cast state object as Capella state * Lint * json properties need to be lower case * Make it v1 since it's now part of lodestar namespace * Group with other /lodestar endpoints * Simplify beacon node impl * Rename return type * Update test description * Fix variable name --------- Co-authored-by: Nico Flaig <[email protected]>
- Loading branch information
Showing
5 changed files
with
126 additions
and
5 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
53 changes: 53 additions & 0 deletions
53
packages/api/test/unit/beacon/genericServerTest/lodestar.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,53 @@ | ||
import {config} from "@lodestar/config/default"; | ||
import {FastifyInstance} from "fastify"; | ||
import {afterAll, beforeAll, describe, expect, it, vi} from "vitest"; | ||
import {getClient} from "../../../../src/beacon/client/lodestar.js"; | ||
import {Endpoints, getDefinitions} from "../../../../src/beacon/routes/lodestar.js"; | ||
import {getRoutes} from "../../../../src/beacon/server/lodestar.js"; | ||
import {HttpClient} from "../../../../src/utils/client/httpClient.js"; | ||
import {AnyEndpoint} from "../../../../src/utils/codecs.js"; | ||
import {FastifyRoute} from "../../../../src/utils/server/index.js"; | ||
import {WireFormat} from "../../../../src/utils/wireFormat.js"; | ||
import {getMockApi, getTestServer} from "../../../utils/utils.js"; | ||
|
||
describe("beacon / lodestar", () => { | ||
describe("get HistoricalSummaries as json", () => { | ||
const mockApi = getMockApi<Endpoints>(getDefinitions(config)); | ||
let baseUrl: string; | ||
let server: FastifyInstance; | ||
|
||
beforeAll(async () => { | ||
const res = getTestServer(); | ||
server = res.server; | ||
for (const route of Object.values(getRoutes(config, mockApi))) { | ||
server.route(route as FastifyRoute<AnyEndpoint>); | ||
} | ||
baseUrl = await res.start(); | ||
}); | ||
|
||
afterAll(async () => { | ||
if (server !== undefined) await server.close(); | ||
}); | ||
|
||
it("getHistoricalSummaries", async () => { | ||
mockApi.getHistoricalSummaries.mockResolvedValue({ | ||
data: { | ||
historicalSummaries: [], | ||
proof: [], | ||
}, | ||
}); | ||
|
||
const httpClient = new HttpClient({baseUrl}); | ||
const client = getClient(config, httpClient); | ||
|
||
const res = await client.getHistoricalSummaries({stateId: "head"}, {responseWireFormat: WireFormat.json}); | ||
|
||
expect(res.ok).toBe(true); | ||
expect(res.wireFormat()).toBe(WireFormat.json); | ||
expect(res.json().data).toStrictEqual({ | ||
historical_summaries: [], | ||
proof: [], | ||
}); | ||
}); | ||
}); | ||
}); |
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