Add config spec tests

Signed-off-by: James Taylor <jamest@uk.ibm.com>
This commit is contained in:
James Taylor 2021-08-09 16:13:51 +01:00
parent e81a7a8b46
commit f904adbf6f
8 changed files with 572 additions and 64 deletions

View file

@ -190,3 +190,19 @@ export default {
// Whether to use watchman for file crawling
// watchman: true,
};
// Required environment variable values for the config.ts file
process.env = Object.assign(process.env, {
HLF_CONNECTION_PROFILE_ORG1: '{"name":"mock-profile-org1"}',
HLF_CERTIFICATE_ORG1:
'"-----BEGIN CERTIFICATE-----\\nMOCK\\n-----END CERTIFICATE-----\\n"',
HLF_PRIVATE_KEY_ORG1:
'"-----BEGIN PRIVATE KEY-----\\nMOCK\\n-----END PRIVATE KEY-----\\n"',
HLF_CONNECTION_PROFILE_ORG2: '{"name":"mock-profile-org2"}',
HLF_CERTIFICATE_ORG2:
'"-----BEGIN CERTIFICATE-----\\nMOCK\\n-----END CERTIFICATE-----\\n"',
HLF_PRIVATE_KEY_ORG2:
'"-----BEGIN PRIVATE KEY-----\\nMOCK\\n-----END PRIVATE KEY-----\\n"',
ORG1_APIKEY: 'ORG1MOCKAPIKEY',
ORG2_APIKEY: 'ORG2MOCKAPIKEY',
});

View file

@ -1275,9 +1275,9 @@
"dev": true
},
"@types/node": {
"version": "15.12.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.4.tgz",
"integrity": "sha512-zrNj1+yqYF4WskCMOHwN+w9iuD12+dGm0rQ35HLl9/Ouuq52cEtd0CH9qMgrdNmi5ejC1/V7vKEXYubB+65DkA=="
"version": "15.14.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.14.7.tgz",
"integrity": "sha512-FA45p37/mLhpebgbPWWCKfOisTjxGK9lwcHlJ6XVLfu3NgfcazOJHdYUZCWPMK8QX4LhNZdmfo6iMz9FqpUbaw=="
},
"@types/passport": {
"version": "1.0.7",

View file

@ -22,7 +22,7 @@
"@types/express": "^4.17.12",
"@types/ioredis": "^4.26.4",
"@types/jest": "^26.0.24",
"@types/node": "^15.12.4",
"@types/node": "^15.14.7",
"@types/passport": "^1.0.7",
"@types/pino": "^6.3.8",
"@types/pino-http": "^5.4.1",

View file

@ -1,56 +0,0 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
export const logLevel = 'info';
export const port = '3000';
export const retryDelay = '3000';
export const maxRetryCount = 5;
export const asLocalHost = true;
export const identityNameOrg1 = 'Org1';
export const identityNameOrg2 = 'Org2';
export const mspIdOrg1 = 'Org1MSP';
export const mspIdOrg2 = 'Org2MSP';
export const channelName = 'mychannel';
export const chaincodeName = 'basic';
export const commitTimeout = '3000';
export const endorseTimeout = '30';
export const connectionProfileOrg1 = '{"name":"mock-profile-org1"}';
export const certificateOrg1 =
'"-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----\\n"';
export const privateKeyOrg1 =
'"-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n"';
export const connectionProfileOrg2 = '{"name":"mock-profile-org2"}';
export const certificateOrg2 =
'"-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----\\n"';
export const privateKeyOrg2 =
'"-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n"';
export const redisHost = 'localhost';
export const redisPort = '6379';
export const redisUsername = '';
export const redisPassword = '';
export const org1ApiKey = '123';
export const org2ApiKey = '456';

View file

@ -6,7 +6,6 @@ import { createServer } from '../server';
import { Application } from 'express';
import request from 'supertest';
jest.mock('../config');
jest.mock('fabric-network');
jest.mock('ioredis');

View file

@ -0,0 +1,465 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
/* eslint-disable @typescript-eslint/no-var-requires */
describe('Config values', () => {
const ORIGINAL_ENV = process.env;
beforeEach(async () => {
jest.resetModules();
process.env = { ...ORIGINAL_ENV };
});
afterAll(() => {
process.env = { ...ORIGINAL_ENV };
});
describe('logLevel', () => {
it('defaults to "info"', () => {
const config = require('./config');
expect(config.logLevel).toBe('info');
});
it('can be configured using the "LOG_LEVEL" environment variable', () => {
process.env.LOG_LEVEL = 'debug';
const config = require('./config');
expect(config.logLevel).toBe('debug');
});
it('throws an error when the "LOG_LEVEL" environment variable has an invalid log level', () => {
process.env.LOG_LEVEL = 'ludicrous';
expect(() => {
require('./config');
}).toThrow(
'env-var: "LOG_LEVEL" should be one of [fatal, error, warn, info, debug, trace, silent]'
);
});
});
describe('port', () => {
it('defaults to "3000"', () => {
const config = require('./config');
expect(config.port).toBe(3000);
});
it('can be configured using the "PORT" environment variable', () => {
process.env.PORT = '8000';
const config = require('./config');
expect(config.port).toBe(8000);
});
it('throws an error when the "PORT" environment variable has an invalid port number', () => {
process.env.PORT = '65536';
expect(() => {
require('./config');
}).toThrow(
'env-var: "PORT" cannot assign a port number greater than 65535. An example of a valid value would be: 3000'
);
});
});
describe('retryDelay', () => {
it('defaults to "3000"', () => {
const config = require('./config');
expect(config.retryDelay).toBe(3000);
});
it('can be configured using the "RETRY_DELAY" environment variable', () => {
process.env.RETRY_DELAY = '9999';
const config = require('./config');
expect(config.retryDelay).toBe(9999);
});
it('throws an error when the "RETRY_DELAY" environment variable has an invalid number', () => {
process.env.RETRY_DELAY = 'short';
expect(() => {
require('./config');
}).toThrow(
'env-var: "RETRY_DELAY" should be a valid integer. An example of a valid value would be: 3000'
);
});
});
describe('maxRetryCount', () => {
it('defaults to "5"', () => {
const config = require('./config');
expect(config.maxRetryCount).toBe(5);
});
it('can be configured using the "MAX_RETRY_COUNT" environment variable', () => {
process.env.MAX_RETRY_COUNT = '9999';
const config = require('./config');
expect(config.maxRetryCount).toBe(9999);
});
it('throws an error when the "MAX_RETRY_COUNT" environment variable has an invalid number', () => {
process.env.MAX_RETRY_COUNT = 'lots';
expect(() => {
require('./config');
}).toThrow(
'env-var: "MAX_RETRY_COUNT" should be a valid integer. An example of a valid value would be: 5'
);
});
});
describe('asLocalhost', () => {
it('defaults to "true"', () => {
const config = require('./config');
expect(config.asLocalhost).toBe(true);
});
it('can be configured using the "AS_LOCAL_HOST" environment variable', () => {
process.env.AS_LOCAL_HOST = 'false';
const config = require('./config');
expect(config.asLocalhost).toBe(false);
});
it('throws an error when the "AS_LOCAL_HOST" environment variable has an invalid boolean value', () => {
process.env.AS_LOCAL_HOST = '11';
expect(() => {
require('./config');
}).toThrow(
'env-var: "AS_LOCAL_HOST" should be either "true", "false", "TRUE", or "FALSE". An example of a valid value would be: true'
);
});
});
describe('mspIdOrg1', () => {
it('defaults to "Org1MSP"', () => {
const config = require('./config');
expect(config.mspIdOrg1).toBe('Org1MSP');
});
it('can be configured using the "HLF_MSP_ID_ORG1" environment variable', () => {
process.env.HLF_MSP_ID_ORG1 = 'Test1MSP';
const config = require('./config');
expect(config.mspIdOrg1).toBe('Test1MSP');
});
});
describe('mspIdOrg2', () => {
it('defaults to "Org2MSP"', () => {
const config = require('./config');
expect(config.mspIdOrg2).toBe('Org2MSP');
});
it('can be configured using the "HLF_MSP_ID_ORG2" environment variable', () => {
process.env.HLF_MSP_ID_ORG2 = 'Test2MSP';
const config = require('./config');
expect(config.mspIdOrg2).toBe('Test2MSP');
});
});
describe('channelName', () => {
it('defaults to "mychannel"', () => {
const config = require('./config');
expect(config.channelName).toBe('mychannel');
});
it('can be configured using the "HLF_CHANNEL_NAME" environment variable', () => {
process.env.HLF_CHANNEL_NAME = 'testchannel';
const config = require('./config');
expect(config.channelName).toBe('testchannel');
});
});
describe('chaincodeName', () => {
it('defaults to "basic"', () => {
const config = require('./config');
expect(config.chaincodeName).toBe('basic');
});
it('can be configured using the "HLF_CHAINCODE_NAME" environment variable', () => {
process.env.HLF_CHAINCODE_NAME = 'testcc';
const config = require('./config');
expect(config.chaincodeName).toBe('testcc');
});
});
describe('commitTimeout', () => {
it('defaults to "3000"', () => {
const config = require('./config');
expect(config.commitTimeout).toBe(3000);
});
it('can be configured using the "HLF_COMMIT_TIMEOUT" environment variable', () => {
process.env.HLF_COMMIT_TIMEOUT = '9999';
const config = require('./config');
expect(config.commitTimeout).toBe(9999);
});
it('throws an error when the "HLF_COMMIT_TIMEOUT" environment variable has an invalid number', () => {
process.env.HLF_COMMIT_TIMEOUT = 'short';
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_COMMIT_TIMEOUT" should be a valid integer. An example of a valid value would be: 3000'
);
});
});
describe('endorseTimeout', () => {
it('defaults to "30"', () => {
const config = require('./config');
expect(config.endorseTimeout).toBe(30);
});
it('can be configured using the "HLF_ENDORSE_TIMEOUT" environment variable', () => {
process.env.HLF_ENDORSE_TIMEOUT = '9999';
const config = require('./config');
expect(config.endorseTimeout).toBe(9999);
});
it('throws an error when the "HLF_ENDORSE_TIMEOUT" environment variable has an invalid number', () => {
process.env.HLF_ENDORSE_TIMEOUT = 'short';
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_ENDORSE_TIMEOUT" should be a valid integer. An example of a valid value would be: 30'
);
});
});
describe('queryTimeout', () => {
it('defaults to "3"', () => {
const config = require('./config');
expect(config.queryTimeout).toBe(3);
});
it('can be configured using the "HLF_QUERY_TIMEOUT" environment variable', () => {
process.env.HLF_QUERY_TIMEOUT = '9999';
const config = require('./config');
expect(config.queryTimeout).toBe(9999);
});
it('throws an error when the "HLF_QUERY_TIMEOUT" environment variable has an invalid number', () => {
process.env.HLF_QUERY_TIMEOUT = 'long';
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_QUERY_TIMEOUT" should be a valid integer. An example of a valid value would be: 3'
);
});
});
describe('connectionProfileOrg1', () => {
it('throws an error when the "HLF_CONNECTION_PROFILE_ORG1" environment variable is not set', () => {
delete process.env.HLF_CONNECTION_PROFILE_ORG1;
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_CONNECTION_PROFILE_ORG1" is a required variable, but it was not set. An example of a valid value would be: {"name":"test-network-org1","version":"1.0.0","client":{"organization":"Org1" ... }'
);
});
it('can be configured using the "HLF_CONNECTION_PROFILE_ORG1" environment variable', () => {
process.env.HLF_CONNECTION_PROFILE_ORG1 = '{"name":"test-network-org1"}';
const config = require('./config');
expect(config.connectionProfileOrg1).toStrictEqual({
name: 'test-network-org1',
});
});
it('throws an error when the "HLF_CONNECTION_PROFILE_ORG1" environment variable is set to invalid json', () => {
process.env.HLF_CONNECTION_PROFILE_ORG1 = 'testing';
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_CONNECTION_PROFILE_ORG1" should be valid (parseable) JSON. An example of a valid value would be: {"name":"test-network-org1","version":"1.0.0","client":{"organization":"Org1" ... }'
);
});
});
describe('certificateOrg1', () => {
it('throws an error when the "HLF_CERTIFICATE_ORG1" environment variable is not set', () => {
delete process.env.HLF_CERTIFICATE_ORG1;
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_CERTIFICATE_ORG1" is a required variable, but it was not set. An example of a valid value would be: "-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----\\n"'
);
});
it('can be configured using the "HLF_CERTIFICATE_ORG1" environment variable', () => {
process.env.HLF_CERTIFICATE_ORG1 = 'ORG1CERT';
const config = require('./config');
expect(config.certificateOrg1).toBe('ORG1CERT');
});
});
describe('privateKeyOrg1', () => {
it('throws an error when the "HLF_PRIVATE_KEY_ORG1" environment variable is not set', () => {
delete process.env.HLF_PRIVATE_KEY_ORG1;
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_PRIVATE_KEY_ORG1" is a required variable, but it was not set. An example of a valid value would be: "-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n"'
);
});
it('can be configured using the "HLF_PRIVATE_KEY_ORG1" environment variable', () => {
process.env.HLF_PRIVATE_KEY_ORG1 = 'ORG1PK';
const config = require('./config');
expect(config.privateKeyOrg1).toBe('ORG1PK');
});
});
describe('connectionProfileOrg2', () => {
it('throws an error when the "HLF_CONNECTION_PROFILE_ORG2" environment variable is not set', () => {
delete process.env.HLF_CONNECTION_PROFILE_ORG2;
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_CONNECTION_PROFILE_ORG2" is a required variable, but it was not set. An example of a valid value would be: {"name":"test-network-org2","version":"1.0.0","client":{"organization":"Org2" ... }'
);
});
it('can be configured using the "HLF_CONNECTION_PROFILE_ORG2" environment variable', () => {
process.env.HLF_CONNECTION_PROFILE_ORG2 = '{"name":"test-network-org2"}';
const config = require('./config');
expect(config.connectionProfileOrg2).toStrictEqual({
name: 'test-network-org2',
});
});
it('throws an error when the "HLF_CONNECTION_PROFILE_ORG2" environment variable is set to invalid json', () => {
process.env.HLF_CONNECTION_PROFILE_ORG2 = 'testing';
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_CONNECTION_PROFILE_ORG2" should be valid (parseable) JSON. An example of a valid value would be: {"name":"test-network-org2","version":"1.0.0","client":{"organization":"Org2" ... }'
);
});
});
describe('certificateOrg2', () => {
it('throws an error when the "HLF_CERTIFICATE_ORG2" environment variable is not set', () => {
delete process.env.HLF_CERTIFICATE_ORG2;
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_CERTIFICATE_ORG2" is a required variable, but it was not set. An example of a valid value would be: "-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----\\n"'
);
});
it('can be configured using the "HLF_CERTIFICATE_ORG2" environment variable', () => {
process.env.HLF_CERTIFICATE_ORG2 = 'ORG2CERT';
const config = require('./config');
expect(config.certificateOrg2).toBe('ORG2CERT');
});
});
describe('privateKeyOrg2', () => {
it('throws an error when the "HLF_PRIVATE_KEY_ORG2" environment variable is not set', () => {
delete process.env.HLF_PRIVATE_KEY_ORG2;
expect(() => {
require('./config');
}).toThrow(
'env-var: "HLF_PRIVATE_KEY_ORG2" is a required variable, but it was not set. An example of a valid value would be: "-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n"'
);
});
it('can be configured using the "HLF_PRIVATE_KEY_ORG2" environment variable', () => {
process.env.HLF_PRIVATE_KEY_ORG2 = 'ORG2PK';
const config = require('./config');
expect(config.privateKeyOrg2).toBe('ORG2PK');
});
});
describe('redisHost', () => {
it('defaults to "localhost"', () => {
const config = require('./config');
expect(config.redisHost).toBe('localhost');
});
it('can be configured using the "REDIS_HOST" environment variable', () => {
process.env.REDIS_HOST = 'redis.example.org';
const config = require('./config');
expect(config.redisHost).toBe('redis.example.org');
});
});
describe('redisPort', () => {
it('defaults to "6379"', () => {
const config = require('./config');
expect(config.redisPort).toBe(6379);
});
it('can be configured with a valid port number using the "REDIS_PORT" environment variable', () => {
process.env.REDIS_PORT = '9736';
const config = require('./config');
expect(config.redisPort).toBe(9736);
});
it('throws an error when the "REDIS_PORT" environment variable has an invalid port number', () => {
process.env.REDIS_PORT = '65536';
expect(() => {
require('./config');
}).toThrow(
'env-var: "REDIS_PORT" cannot assign a port number greater than 65535. An example of a valid value would be: 6379'
);
});
});
describe('redisUsername', () => {
it('has no default value', () => {
const config = require('./config');
expect(config.redisUsername).toBeUndefined();
});
it('can be configured using the "REDIS_USERNAME" environment variable', () => {
process.env.REDIS_USERNAME = 'test';
const config = require('./config');
expect(config.redisUsername).toBe('test');
});
});
describe('redisPassword', () => {
it('has no default value', () => {
const config = require('./config');
expect(config.redisPassword).toBeUndefined();
});
it('can be configured using the "REDIS_PASSWORD" environment variable', () => {
process.env.REDIS_PASSWORD = 'testpw';
const config = require('./config');
expect(config.redisPassword).toBe('testpw');
});
});
describe('org1ApiKey', () => {
it('throws an error when the "ORG1_APIKEY" environment variable is not set', () => {
delete process.env.ORG1_APIKEY;
expect(() => {
require('./config');
}).toThrow(
'env-var: "ORG1_APIKEY" is a required variable, but it was not set. An example of a valid value would be: 123'
);
});
it('can be configured using the "ORG1_APIKEY" environment variable', () => {
process.env.ORG1_APIKEY = 'org1ApiKey';
const config = require('./config');
expect(config.org1ApiKey).toBe('org1ApiKey');
});
});
describe('org2ApiKey', () => {
it('throws an error when the "ORG1_APIKEY" environment variable is not set', () => {
delete process.env.ORG2_APIKEY;
expect(() => {
require('./config');
}).toThrow(
'env-var: "ORG2_APIKEY" is a required variable, but it was not set. An example of a valid value would be: 456'
);
});
it('can be configured using the "ORG1_APIKEY" environment variable', () => {
process.env.ORG2_APIKEY = 'org2ApiKey';
const config = require('./config');
expect(config.org2ApiKey).toBe('org2ApiKey');
});
});
});

View file

@ -4,75 +4,124 @@
import * as env from 'env-var';
/*
* Log level for the REST server
*/
export const logLevel = env
.get('LOG_LEVEL')
.default('info')
.asEnum(['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent']);
/*
* The port to start the REST server on
*/
export const port = env
.get('PORT')
.default('3000')
.example('3000')
.asPortNumber();
/*
* The delay between each retry attempt in milliseconds
*/
export const retryDelay = env
.get('RETRY_DELAY')
.default('3000')
.example('3000')
.asIntPositive();
/*
* The maximum number of times to retry a failing transaction
*/
export const maxRetryCount = env
.get('MAX_RETRY_COUNT')
.default('5')
.example('5')
.asIntPositive();
export const asLocalHost = env
/*
* Whether to convert discovered host addresses to be 'localhost'
* This should be set to 'true' when running a docker composed fabric network on the
* local system, e.g. using the test network; otherwise should it should be 'false'
*/
export const asLocalhost = env
.get('AS_LOCAL_HOST')
.default('true')
.example('true')
.asBoolStrict();
// TODO delete this and use mspIdOrg1
export const identityNameOrg1 = 'Org1';
// TODO delete this and use mspIdOrg2
export const identityNameOrg2 = 'Org2';
/*
* The Org1 MSP ID
*/
export const mspIdOrg1 = env
.get('HLF_MSP_ID_ORG1')
.default('Org1MSP')
.example('Org1MSP')
.asString();
/*
* The Org2 MSP ID
*/
export const mspIdOrg2 = env
.get('HLF_MSP_ID_ORG2')
.default('Org2MSP')
.example('Org2MSP')
.asString();
/*
* Name of the channel which the basic asset sample chaincode has been installed on
*/
export const channelName = env
.get('HLF_CHANNEL_NAME')
.default('mychannel')
.example('mychannel')
.asString();
/*
* Name used to install the basic asset sample
*/
export const chaincodeName = env
.get('HLF_CHAINCODE_NAME')
.default('basic')
.example('basic')
.asString();
/*
* The transaction submit timeout in seconds for commit notification to complete
*/
export const commitTimeout = env
.get('HLF_COMMIT_TIMEOUT')
.default('3000')
.example('3000')
.asIntPositive();
/*
* The transaction submit timeout in seconds for the endorsement to complete
*/
export const endorseTimeout = env
.get('HLF_ENDORSE_TIMEOUT')
.default('30')
.example('30')
.asIntPositive();
/*
* The transaction query timeout in seconds
*/
export const queryTimeout = env
.get('HLF_QUERY_TIMEOUT')
.default('3')
.example('3')
.asIntPositive();
/*
* The Org1 connection profile JSON
*/
export const connectionProfileOrg1 = env
.get('HLF_CONNECTION_PROFILE_ORG1')
.required()
@ -81,18 +130,27 @@ export const connectionProfileOrg1 = env
)
.asJsonObject();
/*
* Certificate for the Org1 identity
*/
export const certificateOrg1 = env
.get('HLF_CERTIFICATE_ORG1')
.required()
.example('"-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----\\n"')
.asString();
/*
* Private key for the Org1 identity
*/
export const privateKeyOrg1 = env
.get('HLF_PRIVATE_KEY_ORG1')
.required()
.example('"-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n"')
.asString();
/*
* The Org2 connection profile JSON
*/
export const connectionProfileOrg2 = env
.get('HLF_CONNECTION_PROFILE_ORG2')
.required()
@ -101,43 +159,69 @@ export const connectionProfileOrg2 = env
)
.asJsonObject();
/*
* Certificate for the Org2 identity
*/
export const certificateOrg2 = env
.get('HLF_CERTIFICATE_ORG2')
.required()
.example('"-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----\\n"')
.asString();
/*
* Private key for the Org2 identity
*/
export const privateKeyOrg2 = env
.get('HLF_PRIVATE_KEY_ORG2')
.required()
.example('"-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n"')
.asString();
/*
* The host the Redis server is running on
*/
export const redisHost = env
.get('REDIS_HOST')
.default('localhost')
.example('localhost')
.asString();
/*
* The port the Redis server is running on
*/
export const redisPort = env
.get('REDIS_PORT')
.default('6379')
.example('6379')
.asPortNumber();
/*
* Username for the Redis server
*/
export const redisUsername = env
.get('REDIS_USERNAME')
.example('conga')
.asString();
/*
* Password for the Redis server
*/
export const redisPassword = env.get('REDIS_PASSWORD').asString();
/*
* API key for Org1
* Specify this API key with the X-Api-Key header to use the Org1 connection profile and credentials
*/
export const org1ApiKey = env
.get('ORG1_APIKEY')
.required()
.example('123')
.asString();
/*
* API key for Org2
* Specify this API key with the X-Api-Key header to use the Org2 connection profile and credentials
*/
export const org2ApiKey = env
.get('ORG2_APIKEY')
.required()

View file

@ -85,14 +85,14 @@ export const getGateway = async (org: string): Promise<Gateway> => {
const connectOptions: GatewayOptions = {
wallet,
identity: fabricConfig.identityName,
discovery: { enabled: true, asLocalhost: config.asLocalHost },
discovery: { enabled: true, asLocalhost: config.asLocalhost },
eventHandlerOptions: {
commitTimeout: config.commitTimeout,
endorseTimeout: config.endorseTimeout,
strategy: DefaultEventHandlerStrategies.PREFER_MSPID_SCOPE_ANYFORTX,
},
queryHandlerOptions: {
timeout: 3,
timeout: config.queryTimeout,
strategy: DefaultQueryHandlerStrategies.PREFER_MSPID_SCOPE_ROUND_ROBIN,
},
};