/
endpoint.test.ts
59 lines (51 loc) 路 2.09 KB
/
endpoint.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import chaiAsPromised from "chai-as-promised";
import chai, {expect} from "chai";
import {createIBeaconConfig, IChainConfig} from "@lodestar/config";
import {chainConfig as chainConfigDef} from "@lodestar/config/default";
import {getClient} from "@lodestar/api";
import {getDevBeaconNode} from "../../utils/node/beacon.js";
import {LogLevel, testLogger, TestLoggerOpts} from "../../utils/logger.js";
chai.use(chaiAsPromised);
/* eslint-disable @typescript-eslint/naming-convention */
describe("lodestar / sync", function () {
const SECONDS_PER_SLOT = 2;
const ALTAIR_FORK_EPOCH = 0;
const validatorCount = 1;
const restPort = 9596;
const chainConfig: IChainConfig = {...chainConfigDef, SECONDS_PER_SLOT, ALTAIR_FORK_EPOCH};
const genesisValidatorsRoot = Buffer.alloc(32, 0xaa);
const config = createIBeaconConfig(chainConfig, genesisValidatorsRoot);
const testLoggerOpts: TestLoggerOpts = {logLevel: LogLevel.info};
const loggerNodeA = testLogger("Node-A", testLoggerOpts);
describe("/eth/v1/node/syncing", function () {
const testParams: Pick<IChainConfig, "SECONDS_PER_SLOT"> = {
SECONDS_PER_SLOT: 2,
};
const afterEachCallbacks: (() => Promise<unknown> | void)[] = [];
afterEach(async () => {
while (afterEachCallbacks.length > 0) {
const callback = afterEachCallbacks.pop();
if (callback) await callback();
}
});
it("getSyncingStatus", async function () {
this.timeout("10 min");
const bn = await getDevBeaconNode({
params: testParams,
options: {
sync: {isSingleNode: true},
api: {rest: {enabled: true, port: restPort}},
chain: {blsVerifyAllMainThread: true},
},
validatorCount,
logger: loggerNodeA,
});
afterEachCallbacks.push(() => bn.close());
const client = getClient({baseUrl: "http://127.0.0.1:9596"}, {config}).node;
// expect headSlot and syncDistance to be string
await expect(client.getSyncingStatus()).to.eventually.be.deep.equal({
data: {headSlot: "0", syncDistance: "0", isSyncing: false},
});
});
});
});