Build

Pre-requisites

Install blockchain SDKs

Fabric

Install with source code

Clone fabric-sdk-node and run the headless tests to make sure everything is ok

Install fabric-client and fabric-ca-client from the SDK, e.g run npm install path-to-sdk/fabric-client path-to-sdk/fabric-ca-client in caliper's root folder, or just copy the node_modules from fabric-sdk-node project

Or install using the repository

run npm install fabric-ca-client fabric-client in the root folder

Sawtooth

Clone sawtooth-core and run the ./bin/run_tests -m javascript_sdk to test the SDK

The scripts defined in command.start will be called before the test, and the scripts defined in command.end will be called after the finish of all tests. You can use them to define any preparation or clean-up works.

You can also run the test with your own blockchain network, a network configuration should be provided and corresponding file path should be specified in configuration file's blockchain.config.

Note:

When running the benchmark, one or more blockchain clients will be used to generate and submit transactions to the SUT. The number of launched clients as well as testing workload can be defined using the configuration file.

Run benchmark with distributed clients (experimental)

In this way, multiple clients can be launched on distributed hosts to run the same benchmark.

Start the ZooKeeper service

Launch clients on target machines separately by running node ./src/comm/client/zoo-client.js zookeeper-server or npm run startclient -- zookeeper-server . Time synchronization between target machines should be executed before launching the clients.

Zookeeper is used to register clients and exchange messages. A launched client will add a new znode under /caliper/clients/. The benchmark checks the directory to learn how many clients are there, and assign tasks to each client according to the workload.

There is no automatic time synchronization between the clients. You should manually synchronize time between target machines, for example using 'ntpdate'.

The blockchain configuration file must exist on machines which run the client, and the relative path (relative to the caliper folder) of the file must be identical. All referenced files in the configuration must also exist.

Write your own benchmarks

Caliper provides a set of nodejs NBIs (North Bound Interfaces) for applications to interact with backend blockchain system. Check the src/comm/blockchain.js to learn about the NBIs. Multiple Adaptors are implemented to translate the NBIs to different blockchain protocols. So developers can write a benchmark once, and run it with different blockchain systems.

Generally speaking, to write a new caliper benchmark, you need to:

Write smart contracts for systems you want to test

Write a testing flow using caliper NBIs. Caliper provides a default benchmark engine, which is pluggable and configurable to integrate new tests easily. For more details, please refer to Benchmark Engine .

Write a configuration file to define the backend network and benchmark arguments.

Directory Structure

Directory

Description

/benchmark

Samples of the blockchain benchmarks

/docs

Documents

/network

Boot configuration files used to deploy some predefined blockchain network under test.