Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Capture the npm_package_version #3198

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "root",
"version": "0.60.0-SNAPSHOT",
quiet-node marked this conversation as resolved.
Show resolved Hide resolved
"devDependencies": {
"@hashgraph/hedera-local": "^2.31.0",
"@open-rpc/schema-utils-js": "^1.16.1",
Expand Down Expand Up @@ -45,7 +46,7 @@
"acceptancetest:api_batch1": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@api-batch-1' --exit",
"acceptancetest:api_batch2": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@api-batch-2' --exit",
"acceptancetest:api_batch3": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@api-batch-3' --exit",
"acceptancetest:erc20": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@erc20' --exit",
"acceptancetest:erc20": "npm_package_version=0.0.1 nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@erc20' --exit",
"acceptancetest:ratelimiter": "nyc ts-mocha packages/ws-server/tests/acceptance/index.spec.ts -g '@web-socket-ratelimiter' --exit && ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@ratelimiter' --exit",
"acceptancetest:hbarlimiter_batch1": "HBAR_RATE_LIMIT_BASIC=1000000000 HBAR_RATE_LIMIT_EXTENDED=1500000000 HBAR_RATE_LIMIT_PRIVILEGED=2000000000 nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@hbarlimiter-batch1' --exit",
"acceptancetest:hbarlimiter_batch2": "HBAR_RATE_LIMIT_BASIC=1000000000 HBAR_RATE_LIMIT_EXTENDED=1500000000 HBAR_RATE_LIMIT_PRIVILEGED=2000000000 nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@hbarlimiter-batch2' --exit",
Expand Down
5 changes: 3 additions & 2 deletions packages/config-service/src/services/globalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,11 @@ export class GlobalConfig {
required: false,
defaultValue: null,
},
NPM_PACKAGE_VERSION: {
// the actual env var in the node process is npm_package_version
npm_package_version: {
envName: 'npm_package_version',
type: 'string',
required: false,
required: true,
defaultValue: null,
},
OPERATOR_ID_ETH_SENDRAWTRANSACTION: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { GlobalConfig } from '../../../dist/services/globalConfig';
import { ValidationService } from '../../../dist/services/validationService';
import { overrideEnvsInMochaDescribe } from '../../../../relay/tests/helpers';

chai.use(chaiAsPromised);

Expand All @@ -31,6 +32,7 @@ describe('ValidationService tests', async function () {
CHAIN_ID: '0x12a',
HEDERA_NETWORK: '{"127.0.0.1:50211":"0.0.3"}',
MIRROR_NODE_URL: 'http://127.0.0.1:5551',
npm_package_version: '1.0.0',
OPERATOR_ID_MAIN: '0.0.1002',
OPERATOR_KEY_MAIN:
'302000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
Expand All @@ -55,6 +57,30 @@ describe('ValidationService tests', async function () {
});
});

describe('package-version', () => {
overrideEnvsInMochaDescribe({
npm_package_version: undefined,
});

const mandatoryStartUpFields = {
CHAIN_ID: '0x12a',
HEDERA_NETWORK: '{"127.0.0.1:50211":"0.0.3"}',
MIRROR_NODE_URL: 'http://127.0.0.1:5551',
OPERATOR_ID_MAIN: '0.0.1002',
OPERATOR_KEY_MAIN:
'302000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
SERVER_PORT: '7546',
};

it('should fail fast if npm_package_version is not set', async () => {
expect(() =>
ValidationService.startUp({
...mandatoryStartUpFields,
}),
).to.throw('npm_package_version is a mandatory and the relay cannot operate without its value.');
});
});

describe('typeCasting', () => {
it('should be able to use default value for missing env if default value is set', async () => {
const castedEnvs = ValidationService.typeCasting({});
Expand Down
3 changes: 0 additions & 3 deletions packages/server/tests/acceptance/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ global.relayIsLocal = RELAY_URL === LOCAL_RELAY_URL;
describe('RPC Server Acceptance Tests', function () {
this.timeout(240 * 1000); // 240 seconds

let relayServer; // Relay Server
let socketServer;

global.servicesNode = new ServicesClient(
NETWORK,
OPERATOR_ID,
Expand Down
Loading