Skip to content

Commit

Permalink
Merge pull request #1727 from api3dao/backport-fixes
Browse files Browse the repository at this point in the history
v0.10 - Fix hardcoded `deploymentId` in tests & prettier behavior
  • Loading branch information
amarthadan authored Apr 11, 2023
2 parents 4502238 + 1239a26 commit fbb4b60
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .changeset/dirty-feet-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
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
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV appDir="/app" \
CI="true"

RUN apk add --update --no-cache git rsync docker $([ $(arch) == "aarch64" ] && echo "python3 make g++") && \
yarn global add npm && \
yarn global add npm@8.19.4 && \
# Download both solidity compilers as per: https://github.com/nomiclabs/hardhat/issues/1280#issuecomment-949822371
mkdir -p /root/.cache/hardhat-nodejs/compilers/wasm && \
wget -O /root/.cache/hardhat-nodejs/compilers/wasm/soljson-v0.8.9+commit.e5eed63a.js https://solc-bin.ethereum.org/wasm/soljson-v0.8.9+commit.e5eed63a.js && \
Expand Down
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
3 changes: 2 additions & 1 deletion scripts/update-config-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readFileSync, writeFileSync } from 'fs';
import fg from 'fast-glob';
import { format } from 'prettier';
import { version as packageVersion } from '../packages/airnode-node/package.json';

const configPatterns = ['./packages/**/*config.example.json', './packages/**/*config.valid.json'];
Expand All @@ -13,7 +14,7 @@ configPatterns.forEach((pattern) => {

// eslint-disable-next-line no-console
console.log(`Updating "${f}" to version ${packageVersion}`);
writeFileSync(f, JSON.stringify(config, null, 2) + '\n');
writeFileSync(f, format(JSON.stringify(config, null, 2), { parser: 'json', printWidth: 120 }));
});
});

Expand Down

0 comments on commit fbb4b60

Please sign in to comment.