Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new Error(msg);
}
let knownError = false;
try {
logger.info(`Set workspace path: ${workspacePath}`);
logger.info(`Set benchmark configuration path: ${benchmarkConfigPath}`);
logger.info(`Set network configuration path: ${networkConfigPath}`);
logger.info(`Detected SUT type: ${blockchainType}`);
const {AdminClient, ClientFactory} = require(`@hyperledger/caliper-${blockchainType}`);
const blockchainAdapter = new AdminClient(networkConfigPath, workspacePath);
const workerFactory = new ClientFactory();
const engine = new CaliperEngine(benchmarkConfig, networkConfig, blockchainAdapter, workerFactory);
const response = await engine.run();
if (response === 0) {
logger.info('Benchmark successfully finished');
} else {
knownError = true;
let msg = `Benchmark failed with error code ${response}`;
logger.error(msg);
throw new Error(msg);
}
} catch (err) {
if (!knownError) {
logger.error(`Unexpected error during benchmark execution: ${err.stack || err}`);
}
throw err;
}