Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function timeOutTest(signingIdentity, t) {
const CONNECTION_TIMEOUT = FabricCAServices.getConfigSetting('connection-timeout');
t.equal(CONNECTION_TIMEOUT, 3000, 'connection-timeout should have default value 3000');
const SO_TIMEOUT = FabricCAServices.getConfigSetting('socket-operation-timeout');
t.equal(SO_TIMEOUT, undefined, 'socket-operation-timeout should have default value undefined');
let start, end;
// test CONNECTION_TIMEOUT
// Connect to a non-routable IP address should throw error connection_timeout
try {
const caClient = new FabricCAServices('http://10.255.255.1:3000')._fabricCAClient;
start = Date.now();
await caClient.request('GET', '/aMethod', signingIdentity);
t.fail('Should throw error by CONNECTION_TIMEOUT');
} catch (e) {
end = Date.now();
logger.debug('Conection failed with error ' + e.toString());
if (e.message === 'Calling /aMethod endpoint failed, CONNECTION Timeout') {
function getFabricCAService() {
FabricCAServices.addConfigFile(path.join(__dirname, 'e2e', 'config.json'));
ORGS = FabricCAServices.getConfigSetting('test-network');
fabricCAEndpoint = ORGS[userOrg].ca.url;
FabricCAServices.getConfigSetting('crypto-keysize', '256');// force for npm test
FabricCAServices.setConfigSetting('crypto-hash-algo', 'SHA2');// force for npm test
return new FabricCAServices(fabricCAEndpoint, tlsOptions, ORGS[userOrg].ca.name);
}
async function timeOutTest(signingIdentity, t) {
const CONNECTION_TIMEOUT = FabricCAServices.getConfigSetting('connection-timeout');
t.equal(CONNECTION_TIMEOUT, 3000, 'connection-timeout should have default value 3000');
const SO_TIMEOUT = FabricCAServices.getConfigSetting('socket-operation-timeout');
t.equal(SO_TIMEOUT, undefined, 'socket-operation-timeout should have default value undefined');
let start, end;
// test CONNECTION_TIMEOUT
// Connect to a non-routable IP address should throw error connection_timeout
try {
const caClient = new FabricCAServices('http://10.255.255.1:3000')._fabricCAClient;
start = Date.now();
await caClient.request('GET', '/aMethod', signingIdentity);
t.fail('Should throw error by CONNECTION_TIMEOUT');
} catch (e) {
end = Date.now();
logger.debug('Conection failed with error ' + e.toString());
if (e.message === 'Calling /aMethod endpoint failed, CONNECTION Timeout') {
// for connection timeout, verify the timeout value
t.equal(Math.floor((end - start) / 1000), 3, 'should have duration roughly equals 3000');
function getFabricCAService() {
FabricCAServices.addConfigFile(path.join(__dirname, 'e2e', 'config.json'));
ORGS = FabricCAServices.getConfigSetting('test-network');
fabricCAEndpoint = ORGS[userOrg].ca.url;
FabricCAServices.getConfigSetting('crypto-keysize', '256');// force for npm test
FabricCAServices.setConfigSetting('crypto-hash-algo', 'SHA2');// force for npm test
return new FabricCAServices(fabricCAEndpoint, tlsOptions, ORGS[userOrg].ca.name);
}