diff --git a/packages/cli/test/utils/keymanagerTestRunners.ts b/packages/cli/test/utils/keymanagerTestRunners.ts index b8736ed28d2..ce470c93ac0 100644 --- a/packages/cli/test/utils/keymanagerTestRunners.ts +++ b/packages/cli/test/utils/keymanagerTestRunners.ts @@ -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 = { @@ -78,7 +78,8 @@ export function getKeymanagerTestRunner({args: {spawnCli}, afterEachCallbacks, d export async function expectKeys(keymanagerClient: Api, expectedPubkeys: string[], message: string): Promise { 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 diff --git a/packages/cli/test/utils/runUtils.ts b/packages/cli/test/utils/runUtils.ts index 7f7ba4222cb..7050460be2b 100644 --- a/packages/cli/test/utils/runUtils.ts +++ b/packages/cli/test/utils/runUtils.ts @@ -20,6 +20,13 @@ export function expectDeepEquals(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(a: T[], b: T[], message: string): void { + expect(a).to.have.deep.members(b, message); +} + export type DoneCb = (err?: Error) => void; /**