Skip to content

Commit

Permalink
Merge fd24e60 into 1bf4ea7
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored Jun 13, 2023
2 parents 1bf4ea7 + fd24e60 commit 5e54353
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/cli/test/utils/keymanagerTestRunners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Api, getClient} from "@lodestar/api/keymanager";
import {config} from "@lodestar/config/default";
import {ApiError} from "@lodestar/api";
import {getMockBeaconApiServer} from "./mockBeaconApiServer.js";
import {AfterEachCallback, expectDeepEquals, findApiToken, itDone} from "./runUtils.js";
import {AfterEachCallback, expectDeepEqualsUnordered, findApiToken, itDone} from "./runUtils.js";
import {DescribeArgs} from "./childprocRunner.js";

type TestContext = {
Expand Down Expand Up @@ -78,7 +78,8 @@ export function getKeymanagerTestRunner({args: {spawnCli}, afterEachCallbacks, d
export async function expectKeys(keymanagerClient: Api, expectedPubkeys: string[], message: string): Promise<void> {
const keys = await keymanagerClient.listKeys();
ApiError.assert(keys);
expectDeepEquals(
// The order of keys isn't always deterministic so we can't use deep equal
expectDeepEqualsUnordered(
keys.response.data,
expectedPubkeys.map((pubkey) => ({validatingPubkey: pubkey, derivationPath: "", readonly: false})),
message
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/test/utils/runUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export function expectDeepEquals<T>(a: T, b: T, message: string): void {
expect(a).deep.equals(b, message);
}

/**
* Similar to `expectDeepEquals` but only checks presence of all elements in array, irrespective of their order.
*/
export function expectDeepEqualsUnordered<T>(a: T[], b: T[], message: string): void {
expect(a).to.have.deep.members(b, message);
}

export type DoneCb = (err?: Error) => void;

/**
Expand Down

0 comments on commit 5e54353

Please sign in to comment.