Skip to content

Commit

Permalink
Update the endpoint test
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Jul 13, 2023
1 parent bb7a1c0 commit 4949901
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expect} from "chai";
import {createBeaconConfig} from "@lodestar/config";
import {chainConfig as chainConfigDef} from "@lodestar/config/default";
import {Api, getClient} from "@lodestar/api/beacon";
import {Api, getClient, routes} from "@lodestar/api/beacon";
import {ApiError} from "@lodestar/api";
import {LogLevel, testLogger} from "../../../../../utils/logger.js";
import {getDevBeaconNode} from "../../../../../utils/node/beacon.js";
Expand Down Expand Up @@ -41,12 +41,18 @@ describe("beacon node api", function () {
await bn.close();
});

describe("getSyncingStatus", async () => {
describe.only("getSyncingStatus", () => {
it("should return valid syncing status", async () => {
const res = await client.node.getSyncingStatus();
ApiError.assert(res);

expect(res.response.data).to.include.keys("headSlot", "syncDistance", "isSyncing", "isOptimistic", "elOffline");
expect(res.response.data).to.eql({
headSlot: "0",
syncDistance: "0",
isSyncing: false,
isOptimistic: false,
elOffline: true,
});
});

it("should return 'elOffline' as 'true' for default dev node", async () => {
Expand All @@ -64,7 +70,6 @@ describe("beacon node api", function () {
options: {
sync: {isSingleNode: true},
network: {allowPublishToZeroPeers: true},
eth1: {enabled: true},
executionEngine: {mode: "mock"},
api: {
rest: {
Expand All @@ -77,6 +82,16 @@ describe("beacon node api", function () {
validatorCount,
logger: testLogger("Node-A", {level: LogLevel.info}),
});

// Wait for a block to be produced, so that node can have communication with execution engine
await new Promise((resolve) => {
bn.chain.emitter.on(routes.events.EventType.head, async (head) => {
if (head.slot > 0) {
resolve(head);
}
});
});

const res = await client.node.getSyncingStatus();
ApiError.assert(res);

Expand Down

0 comments on commit 4949901

Please sign in to comment.