Skip to content

Commit

Permalink
Update the validator optional case
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Aug 15, 2023
1 parent a55fa29 commit 99f00b3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions packages/cli/test/utils/simulation/SimulationEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class SimulationEnvironment {
}

await Promise.all(this.nodes.map((node) => node.beacon.job.start()));
await Promise.all(this.nodes.map((node) => node.validator.job.start()));
await Promise.all(this.nodes.map((node) => node.validator?.job.start()));

if (this.nodes.some((node) => node.validator?.keys.type === "remote")) {
console.log("Starting external signer...");
Expand Down Expand Up @@ -201,7 +201,7 @@ export class SimulationEnvironment {
process.removeAllListeners("SIGINT");
console.log(`Simulation environment "${this.options.id}" is stopping: ${message}`);
await this.tracker.stop();
await Promise.all(this.nodes.map((node) => node.validator.job.stop()));
await Promise.all(this.nodes.map((node) => node.validator?.job.stop()));
await Promise.all(this.nodes.map((node) => node.beacon.job.stop()));
await Promise.all(this.nodes.map((node) => node.execution.job.stop()));
await this.externalSigner.stop();
Expand Down Expand Up @@ -282,6 +282,11 @@ export class SimulationEnvironment {
paths: getNodePaths({id, logsDir: this.options.logsDir, client: beaconType, root: this.options.rootDir}),
});

if (keys.type === "no-keys") {
this.nodePairCount += 1;
return {id, execution: executionNode, beacon: beaconNode};
}

// If no validator configuration is specified we will consider that beacon type is also same as validator type
const validatorType =
typeof validator === "object"
Expand Down
11 changes: 8 additions & 3 deletions packages/cli/test/utils/simulation/assertions/nodeAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ export const nodeAssertion: SimulationAssertion<"node", {health: number; keyMana
match: neverMatcher,
capture: async ({node}) => {
const {status: health} = await node.beacon.api.node.getHealth();
let keyManagerKeys: string[];
if (!node.validator) {
return {health, keyManagerKeys: []};
}

let keyManagerKeys: string[];
// There is an authentication issue with the lighthouse keymanager client
if (node.beacon.client == BeaconClient.Lighthouse || getAllKeys(node.validator.keys).length === 0) {
keyManagerKeys = [];
} else {
const res = await node.validator?.keyManager.listKeys();
const res = await node.validator.keyManager.listKeys();
ApiError.assert(res);
keyManagerKeys = res.response.data.map((k) => k.validatingPubkey);
}
Expand All @@ -36,7 +39,9 @@ export const nodeAssertion: SimulationAssertion<"node", {health: number; keyMana
errors.push(["node health is neither READY or SYNCING", {node: node.beacon.id}]);
}

const expectedPublicKeys = getAllKeys(node.validator?.keys).map((k) => k.toPublicKey().toHex());
const expectedPublicKeys = node.validator
? getAllKeys(node.validator.keys).map((k) => k.toPublicKey().toHex())
: [];

if (!arrayEquals(keyManagerKeys.sort(), expectedPublicKeys.sort())) {
errors.push([
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/utils/simulation/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export interface NodePair {
readonly id: string;
readonly beacon: BeaconNode;
readonly execution: ExecutionNode;
readonly validator: ValidatorNode;
readonly validator?: ValidatorNode;
}

export type BeaconNodeGenerator<C extends BeaconClient> = (
Expand Down

0 comments on commit 99f00b3

Please sign in to comment.