diff --git a/src/services/rpc-provider/rpc-provider.service.spec.ts b/src/services/rpc-provider/rpc-provider.service.spec.ts index d0f3aab22b..4adb4589d6 100644 --- a/src/services/rpc-provider/rpc-provider.service.spec.ts +++ b/src/services/rpc-provider/rpc-provider.service.spec.ts @@ -1,11 +1,9 @@ -import { JsonRpcProvider } from '@ethersproject/providers'; - import RpcProviderService from '@/services/rpc-provider/rpc-provider.service'; import { StaticJsonRpcBatchProvider } from './static-json-rpc-batch-provider'; -vi.mock('@ethersproject/providers', () => { +vi.mock('./static-json-rpc-batch-provider', () => { return { - JsonRpcProvider: vi.fn().mockImplementation(() => { + StaticJsonRpcBatchProvider: vi.fn().mockImplementation(() => { return { once: vi.fn(), }; @@ -13,23 +11,13 @@ vi.mock('@ethersproject/providers', () => { }; }); -vi.mock('./static-json-rpc-batch-provider', () => { - return { - StaticJsonRpcBatchProvider: vi.fn().mockImplementation(() => { - return {}; - }), - }; -}); - describe('RPC provider service', () => { - const MockedJsonRpcProvider = vi.mocked(JsonRpcProvider, true); const MockedStaticJsonRpcBatchProvider = vi.mocked( StaticJsonRpcBatchProvider, true ); beforeEach(() => { - MockedJsonRpcProvider.mockClear(); MockedStaticJsonRpcBatchProvider.mockClear(); }); @@ -42,9 +30,4 @@ describe('RPC provider service', () => { new RpcProviderService(); expect(MockedStaticJsonRpcBatchProvider).toHaveBeenCalledTimes(1); }); - - it('Calls the WebSocketProvider', () => { - new RpcProviderService().initBlockListener(() => ({})); - expect(MockedJsonRpcProvider).toHaveBeenCalledTimes(1); - }); }); diff --git a/src/services/rpc-provider/rpc-provider.service.ts b/src/services/rpc-provider/rpc-provider.service.ts index c22f410ed5..87dd47f720 100644 --- a/src/services/rpc-provider/rpc-provider.service.ts +++ b/src/services/rpc-provider/rpc-provider.service.ts @@ -15,8 +15,7 @@ export default class RpcProviderService { ) {} public initBlockListener(newBlockHandler: NewBlockHandler): void { - const blockProvider = new JsonRpcProvider(this.config.rpc); - blockProvider.once('block', newBlockNumber => { + this.jsonProvider.once('block', newBlockNumber => { let currentBlockNumber = newBlockNumber; newBlockHandler(currentBlockNumber); setInterval(() => {