diff --git a/packages/pusher/src/heartbeat/heartbeat.test.ts b/packages/pusher/src/heartbeat/heartbeat.test.ts index b7764188..8e159d3d 100644 --- a/packages/pusher/src/heartbeat/heartbeat.test.ts +++ b/packages/pusher/src/heartbeat/heartbeat.test.ts @@ -1,8 +1,11 @@ +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; + import * as promiseUtilsModule from '@api3/promise-utils'; import { config, parseHeartbeatLog } from '../../test/fixtures'; import * as stateModule from '../state'; -import { loadRawConfig } from '../validation/config'; +import * as configModule from '../validation/config'; import { heartbeatLogger } from './logger'; @@ -24,11 +27,13 @@ describe(logHeartbeat.name, () => { '0.1.0', '1674172803', '1674172800', - '0x6d4306f70c5fe9d8608b4e0c1d72e06a366e6f60b8461a6a9a0833a7401f5778', - '0x6e6379a42b89bdc78286efd6f6ad94142765930c4843784f49ba955ea95c1cb64c432b41aecc1b220dc90d616332bbf7bdc7242a16eb0e31306dac96a6d6ee821b', + '0x126e768ba244efdb790d63a76821047e163dfc502ace09b2546a93075594c286', + '0x14f123ec1006bace8f8971cd8c94eb022b9bb0e1364e88ae4e8562a5f02de43e35dd4ecdefc976595eba5fec3d04222a0249e876453599b27847e85e14ff77601b', ].join(' - '); it('sends the correct heartbeat log', async () => { + const rawConfig = JSON.parse(readFileSync(join(__dirname, '../../config/pusher.example.json'), 'utf8')); + jest.spyOn(configModule, 'loadRawConfig').mockReturnValue(rawConfig); const state = stateModule.getInitialState(config); jest.spyOn(stateModule, 'getState').mockReturnValue(state); jest.spyOn(heartbeatLogger, 'info').mockImplementation(); @@ -40,16 +45,17 @@ describe(logHeartbeat.name, () => { }); it('the heartbeat log can be parsed', () => { - const rawConfig = loadRawConfig(); + const rawConfig = JSON.parse(readFileSync(join(__dirname, '../../config/pusher.example.json'), 'utf8')); + jest.spyOn(configModule, 'loadRawConfig').mockReturnValue(rawConfig); const expectedHeartbeatPayload = { airnodeAddress: '0xbF3137b0a7574563a23a8fC8badC6537F98197CC', stage: 'test', nodeVersion: '0.1.0', heartbeatTimestamp: '1674172803', deploymentTimestamp: '1674172800', - configHash: '0x6d4306f70c5fe9d8608b4e0c1d72e06a366e6f60b8461a6a9a0833a7401f5778', + configHash: '0x126e768ba244efdb790d63a76821047e163dfc502ace09b2546a93075594c286', signature: - '0x6e6379a42b89bdc78286efd6f6ad94142765930c4843784f49ba955ea95c1cb64c432b41aecc1b220dc90d616332bbf7bdc7242a16eb0e31306dac96a6d6ee821b', + '0x14f123ec1006bace8f8971cd8c94eb022b9bb0e1364e88ae4e8562a5f02de43e35dd4ecdefc976595eba5fec3d04222a0249e876453599b27847e85e14ff77601b', }; const heartbeatPayload = parseHeartbeatLog(expectedLogMessage);