From eaf74cda4c43a83ebc184d096e08a599420754b9 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Mon, 2 Oct 2023 21:18:32 +0200 Subject: [PATCH] Update tests to ensure correct epoch is provided --- packages/validator/test/unit/services/doppelganger.test.ts | 6 ++++-- packages/validator/test/utils/slashingProtectionMock.ts | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/validator/test/unit/services/doppelganger.test.ts b/packages/validator/test/unit/services/doppelganger.test.ts index d21c41eda12c..f3507be690f6 100644 --- a/packages/validator/test/unit/services/doppelganger.test.ts +++ b/packages/validator/test/unit/services/doppelganger.test.ts @@ -148,12 +148,14 @@ describe("doppelganger service", () => { indicesService.pubkey2index.set(pubkeyHex, index); // Initial epoch must be > 0 else doppelganger detection is skipped due to pre-genesis - const initialEpoch = 1; + const initialEpoch = 10; const clock = new ClockMockMsToSlot(initialEpoch); const slashingProtection = new SlashingProtectionMock(); // Attestation from previous epoch exists in slashing protection db - slashingProtection.hasAttestedInEpoch = async () => true; + slashingProtection.hasAttestedInEpoch = async (_, epoch: Epoch) => { + return epoch === initialEpoch - 1; + }; const doppelganger = new DoppelgangerService( logger, diff --git a/packages/validator/test/utils/slashingProtectionMock.ts b/packages/validator/test/utils/slashingProtectionMock.ts index 6a714a404f81..ec83fae742cc 100644 --- a/packages/validator/test/utils/slashingProtectionMock.ts +++ b/packages/validator/test/utils/slashingProtectionMock.ts @@ -1,3 +1,4 @@ +import {BLSPubkey, Epoch} from "@lodestar/types"; import {ISlashingProtection} from "../../src/index.js"; /** @@ -10,7 +11,7 @@ export class SlashingProtectionMock implements ISlashingProtection { async checkAndInsertAttestation(): Promise { // } - async hasAttestedInEpoch(): Promise { + async hasAttestedInEpoch(_p: BLSPubkey, _e: Epoch): Promise { return false; } async importInterchange(): Promise {