Skip to content

Commit

Permalink
Replace hardcoded deploymentId values in airnode-node tests (#1653)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcroote authored and amarthadan committed Apr 10, 2023
1 parent 4502238 commit 0a16769
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-actors-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@api3/airnode-node': patch
---

Replace hardcoded deploymentId values in tests
10 changes: 9 additions & 1 deletion packages/airnode-node/src/handlers/start-coordinator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import * as fixtures from '../../test/fixtures';
import * as calls from '../coordinator/calls';
import { buildAggregatedRegularApiCall, buildConfig } from '../../test/fixtures';
import { BLOCK_COUNT_HISTORY_LIMIT } from '../constants';
import { DEPLOYMENT_ID_LENGTH } from '../workers';

const deploymentIdRegex = RegExp(`local[0-9a-f]{${DEPLOYMENT_ID_LENGTH}}`);

describe('startCoordinator', () => {
jest.setTimeout(30_000);
Expand Down Expand Up @@ -172,7 +175,12 @@ describe('startCoordinator', () => {
await startCoordinator(config, coordinatorId);

// cached requests should not trigger an API call
expect(callApisSpy).toHaveBeenCalledWith([], expect.objectContaining({ deploymentId: 'localdd59d6d0' }));
expect(callApisSpy).toHaveBeenCalledWith(
[],
expect.objectContaining({
deploymentId: expect.stringMatching(deploymentIdRegex),
})
);

expect(blockWithTransactionsSpy).toHaveBeenCalled();
// API call was submitted
Expand Down
7 changes: 5 additions & 2 deletions packages/airnode-node/src/providers/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import * as providers from './actions';
import * as fixtures from '../../test/fixtures';
import { GroupedRequests } from '../types';
import { ChainConfig } from '../config';
import { DEPLOYMENT_ID_LENGTH } from '../workers';

const deploymentIdRegex = RegExp(`local[0-9a-f]{${DEPLOYMENT_ID_LENGTH}}`);

const chainProviderName1 = 'Pocket Ethereum Mainnet';
const chainProviderName3 = 'Infura Sepolia';
Expand Down Expand Up @@ -124,7 +127,7 @@ describe('initialize', () => {
},
settings: {
airnodeAddress: '0xA30CA71Ba54E83127214D3271aEA8F5D6bD4Dace',
deploymentId: 'localdd59d6d0',
deploymentId: expect.stringMatching(deploymentIdRegex),
authorizers: {
requesterEndpointAuthorizers: [ethers.constants.AddressZero],
crossChainRequesterAuthorizers: [],
Expand Down Expand Up @@ -179,7 +182,7 @@ describe('initialize', () => {
},
settings: {
airnodeAddress: '0xA30CA71Ba54E83127214D3271aEA8F5D6bD4Dace',
deploymentId: 'localdd59d6d0',
deploymentId: expect.stringMatching(deploymentIdRegex),
authorizers: {
requesterEndpointAuthorizers: [ethers.constants.AddressZero],
crossChainRequesterAuthorizers: [],
Expand Down
7 changes: 5 additions & 2 deletions packages/airnode-node/src/providers/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import * as fixtures from '../../test/fixtures';
import { BLOCK_MIN_CONFIRMATIONS } from '../constants';
import { EVMProviderState, ProviderState } from '../types';
import { ChainConfig } from '../config';
import { DEPLOYMENT_ID_LENGTH } from '../workers';

const deploymentIdRegex = RegExp(`local[0-9a-f]{${DEPLOYMENT_ID_LENGTH}}`);

describe('create', () => {
fixtures.setEnvVariables({ AIRNODE_WALLET_PRIVATE_KEY: fixtures.getAirnodeWalletPrivateKey() });
Expand Down Expand Up @@ -54,7 +57,7 @@ describe('create', () => {
},
settings: {
airnodeAddress: '0xA30CA71Ba54E83127214D3271aEA8F5D6bD4Dace',
deploymentId: 'localdd59d6d0',
deploymentId: expect.stringMatching(deploymentIdRegex),
authorizers: {
requesterEndpointAuthorizers: [ethers.constants.AddressZero],
crossChainRequesterAuthorizers: [],
Expand Down Expand Up @@ -150,7 +153,7 @@ describe('create', () => {
},
settings: {
airnodeAddress: '0xA30CA71Ba54E83127214D3271aEA8F5D6bD4Dace',
deploymentId: 'localdd59d6d0',
deploymentId: expect.stringMatching(deploymentIdRegex),
authorizers: {
requesterEndpointAuthorizers: [ethers.constants.AddressZero],
crossChainRequesterAuthorizers: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/airnode-node/src/workers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as localHandlers from './local-handlers';
import { WorkerParameters, WorkerResponse } from '../types';
import { LocalOrCloudProvider } from '../config';

const DEPLOYMENT_ID_LENGTH = 8;
export const DEPLOYMENT_ID_LENGTH = 8;

export function spawn(params: WorkerParameters): Promise<WorkerResponse> {
switch (params.cloudProvider.type) {
Expand Down

0 comments on commit 0a16769

Please sign in to comment.