How to use the @hyperledger/caliper-core.CaliperEngine function in @hyperledger/caliper-core

To help you get started, we’ve selected a few @hyperledger/caliper-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / caliper / packages / caliper-cli / lib / benchmark / lib / runBenchmark.js View on Github external
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;
        }