Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Siegrift committed Oct 31, 2023
1 parent 6397183 commit 433bb95
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/pusher/src/heartbeat/heartbeat.test.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 433bb95

Please sign in to comment.