Skip to content

Commit

Permalink
fix: acceptance tests
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Yanev <[email protected]>
  • Loading branch information
victor-yanev committed Dec 17, 2024
1 parent 222ca25 commit 39bd04b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 54 deletions.
8 changes: 4 additions & 4 deletions packages/config-service/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import dotenv from 'dotenv';
import findConfig from 'find-config';
import pino from 'pino';

import { LoggerService } from './loggerService';
import { ValidationService } from './validationService';

Expand Down Expand Up @@ -61,13 +62,12 @@ export class ConfigService {
private constructor() {
const configPath = findConfig(ConfigService.envFileName);

if (!configPath) {
if (configPath) {
dotenv.config({ path: configPath });
} else {
logger.warn('No .env file is found. The relay cannot operate without valid .env.');
}

// @ts-ignore
dotenv.config({ path: configPath });

// validate mandatory fields
ValidationService.startUp(process.env);

Expand Down
49 changes: 25 additions & 24 deletions packages/server/tests/acceptance/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,32 @@ import { AliasAccount } from '../types/AliasAccount';

chai.use(chaiAsPromised);

const testLogger = pino({
name: 'hedera-json-rpc-relay',
level: ConfigService.get('LOG_LEVEL') || 'trace',
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: true,
},
},
});
const logger = testLogger.child({ name: 'rpc-acceptance-test' });

const NETWORK = ConfigService.get('HEDERA_NETWORK') as string;
const OPERATOR_KEY = ConfigService.get('OPERATOR_KEY_MAIN') as string;
const OPERATOR_ID = ConfigService.get('OPERATOR_ID_MAIN') as string;
const MIRROR_NODE_URL = ConfigService.get('MIRROR_NODE_URL') as string;
const LOCAL_RELAY_URL = 'http://localhost:7546';
const RELAY_URL = ConfigService.get('E2E_RELAY_HOST') || LOCAL_RELAY_URL;
const CHAIN_ID = ConfigService.get('CHAIN_ID') || '0x12a';
const INITIAL_BALANCE = ConfigService.get('INITIAL_BALANCE') || '5000000000';
let startOperatorBalance: Hbar;
global.relayIsLocal = RELAY_URL === LOCAL_RELAY_URL;

describe('RPC Server Acceptance Tests', function () {
this.timeout(240 * 1000); // 240 seconds

const testLogger = pino({
name: 'hedera-json-rpc-relay',
level: (ConfigService.get('LOG_LEVEL') as string) || 'trace',
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: true,
},
},
});
const logger = testLogger.child({ name: 'rpc-acceptance-test' });

const NETWORK = ConfigService.get('HEDERA_NETWORK') as string;
const OPERATOR_KEY = ConfigService.get('OPERATOR_KEY_MAIN') as string;
const OPERATOR_ID = ConfigService.get('OPERATOR_ID_MAIN') as string;
const MIRROR_NODE_URL = ConfigService.get('MIRROR_NODE_URL') as string;
const LOCAL_RELAY_URL = 'http://localhost:7546';
const RELAY_URL = ConfigService.get('E2E_RELAY_HOST') || LOCAL_RELAY_URL;
const CHAIN_ID = ConfigService.get('CHAIN_ID') || '0x12a';
const INITIAL_BALANCE = ConfigService.get('INITIAL_BALANCE') || '5000000000';

global.relayIsLocal = RELAY_URL === LOCAL_RELAY_URL;
global.servicesNode = new ServicesClient(
NETWORK,
OPERATOR_ID,
Expand All @@ -104,6 +103,8 @@ describe('RPC Server Acceptance Tests', function () {
Utils.captureMemoryLeaks(new GCProfiler());
}

let startOperatorBalance: Hbar;

before(async () => {
// configuration details
logger.info('Acceptance Tests Configurations successfully loaded');
Expand Down
51 changes: 25 additions & 26 deletions packages/ws-server/tests/acceptance/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { Server } from 'node:http';

import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import constants from '@hashgraph/json-rpc-relay/dist/lib/constants';
import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types';
import { setServerTimeout } from '@hashgraph/json-rpc-server/dist/koaJsonRpc/lib/utils';
import app from '@hashgraph/json-rpc-server/dist/server';
import MirrorClient from '@hashgraph/json-rpc-server/tests/clients/mirrorClient';
Expand All @@ -44,33 +43,31 @@ import pino from 'pino';

chai.use(chaiAsPromised);

const testLogger = pino({
name: 'hedera-json-rpc-relay',
level: ConfigService.get('LOG_LEVEL') || 'trace',
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: true,
},
},
});
const logger = testLogger.child({ name: 'rpc-acceptance-test' });

const NETWORK = ConfigService.get('HEDERA_NETWORK') as string;
const OPERATOR_KEY = ConfigService.get('OPERATOR_KEY_MAIN') as string;
const OPERATOR_ID = ConfigService.get('OPERATOR_ID_MAIN') as string;
const MIRROR_NODE_URL = ConfigService.get('MIRROR_NODE_URL') as string;
const LOCAL_RELAY_URL = 'http://localhost:7546';
const RELAY_URL = ConfigService.get('E2E_RELAY_HOST') || LOCAL_RELAY_URL;
const CHAIN_ID = ConfigService.get('CHAIN_ID') || '0x12a';
let startOperatorBalance: Hbar;
global.relayIsLocal = RELAY_URL === LOCAL_RELAY_URL;

describe('RPC Server Acceptance Tests', function () {
this.timeout(240 * 1000); // 240 seconds

const requestDetails = new RequestDetails({ requestId: 'rpc_batch1Test', ipAddress: '0.0.0.0' });
const testLogger = pino({
name: 'hedera-json-rpc-relay',
level: (ConfigService.get('LOG_LEVEL') as string) || 'trace',
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: true,
},
},
});
const logger = testLogger.child({ name: 'rpc-acceptance-test' });

const NETWORK = ConfigService.get('HEDERA_NETWORK') as string;
const OPERATOR_KEY = ConfigService.get('OPERATOR_KEY_MAIN') as string;
const OPERATOR_ID = ConfigService.get('OPERATOR_ID_MAIN') as string;
const MIRROR_NODE_URL = ConfigService.get('MIRROR_NODE_URL') as string;
const LOCAL_RELAY_URL = 'http://localhost:7546';
const RELAY_URL = ConfigService.get('E2E_RELAY_HOST') || LOCAL_RELAY_URL;
const CHAIN_ID = ConfigService.get('CHAIN_ID') || '0x12a';

global.relayIsLocal = RELAY_URL === LOCAL_RELAY_URL;
global.servicesNode = new ServicesClient(
NETWORK,
OPERATOR_ID,
Expand All @@ -81,6 +78,8 @@ describe('RPC Server Acceptance Tests', function () {
global.relay = new RelayClient(RELAY_URL, logger.child({ name: `relay-test-client` }));
global.logger = logger;

let startOperatorBalance: Hbar;

before(async () => {
// configuration details
logger.info('Acceptance Tests Configurations successfully loaded');
Expand All @@ -104,7 +103,7 @@ describe('RPC Server Acceptance Tests', function () {
);

global.accounts = new Array<AliasAccount>(initialAccount);
await global.mirrorNode.get(`/accounts/${initialAccount.address}`, requestDetails);
await global.mirrorNode.get(`/accounts/${initialAccount.address}`, Utils.generateRequestId());
});

after(async function () {
Expand Down

0 comments on commit 39bd04b

Please sign in to comment.