Skip to content

Commit

Permalink
fix: mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Amuhar committed Dec 6, 2023
1 parent c14bc1e commit 4e73aad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/contracts/deposit/deposit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
VerifiedDepositEventsCacheHeaders,
VerifiedDepositEventGroup,
} from './interfaces';
import { OneAtTime } from 'common/decorators';
import { RepositoryService } from 'contracts/repository';
import { CacheService } from 'cache';
import { BlockTag } from 'provider';
Expand Down Expand Up @@ -335,7 +334,6 @@ export class DepositService {

const mergedEvents = cachedEvents.data.concat(freshEvents);

// TODO: Why we don't cache freshEvents?
return {
events: mergedEvents,
startBlock: cachedEvents.headers.startBlock,
Expand Down
1 change: 0 additions & 1 deletion src/guardian/guardian.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ describe('GuardianService', () => {
guardianService.handleNewBlock(),
]);

// expect(getStakingModulesMock).toBeCalledTimes(1);
expect(getBlockGuardServiceMock).toBeCalledTimes(1);
});
});
31 changes: 23 additions & 8 deletions test/helpers/mockKeysApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { toHexString } from '@chainsafe/ssz';

import { KeysApiService } from '../../src/keys-api/keys-api.service';
import { NOP_REGISTRY, pk } from './../constants';
import { RegistryOperator } from 'keys-api/interfaces/RegistryOperator';

export const mockKeysApi = (
sig: Uint8Array[],
Expand Down Expand Up @@ -36,20 +37,34 @@ export const mockKeysApi = (
operatorIndex: 0,
used,
index: 0,
moduleAddress: NOP_REGISTRY,
}));

jest.spyOn(keysApiService, 'getModulesList').mockImplementation(async () => ({
data: [mockedModule],
elBlockSnapshot: mockedMeta,
const mockedOperators: RegistryOperator[] = [
{
name: 'Dev team',
rewardAddress: '0x6D725DAe055287f913661ee0b79dE6B21F12A459',
stakingLimit: 11,
stoppedValidators: 0,
totalSigningKeys: 10,
usedSigningKeys: 10,
index: 0,
active: true,
moduleAddress: '0x595F64Ddc3856a3b5Ff4f4CC1d1fb4B46cFd2bAC',
},
];

jest.spyOn(keysApiService, 'getUnusedKeys').mockImplementation(async () => ({
data: mockedKeys,
meta: {
elBlockSnapshot: mockedMeta,
},
}));

jest
.spyOn(keysApiService, 'getUnusedModuleKeys')
.spyOn(keysApiService, 'getOperatorListWithModule')
.mockImplementation(async () => ({
data: {
keys: mockedKeys,
module: mockedModule,
},
data: [{ operators: mockedOperators, module: mockedModule }],
meta: {
elBlockSnapshot: mockedMeta,
},
Expand Down

0 comments on commit 4e73aad

Please sign in to comment.