参考:
https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/tutorial/stress_testing.html?highlight=caliper#caliper
https://blog.csdn.net/u013288190/article/details/116304877
1、建立一个工作目录
mkdir benchmarks && cd benchmarks
2、对NPM项目进行初始化
npm init -y
3、安装caliper-cli
npm install --only=prod @hyperledger/caliper-cli@0.2.0
4、绑定fisco-bcos
sudo npx caliper bind --caliper-bind-sut fisco-bcos --caliper-bind-sdk latest
5、下载测试用例
git clone https://github.com/vita-dounai/caliper-benchmarks.git 若出现网络问题导致的长时间拉取代码失败,则尝试以下方式: git clone https://gitee.com/vita-dounai/caliper-benchmarks.git
6、执行合约测试
HelloWorld合约测试 npx caliper benchmark run --caliper-workspace caliper-benchmarks --caliper-benchconfig benchmarks/samples/fisco-bcos/helloworld/config.yaml --caliper-networkconfig networks/fisco-bcos/4nodes1group/fisco-bcos.json Solidity版转账合约测试 npx caliper benchmark run --caliper-workspace caliper-benchmarks --caliper-benchconfig benchmarks/samples/fisco-bcos/transfer/solidity/config.yaml --caliper-networkconfig networks/fisco-bcos/4nodes1group/fisco-bcos.json 预编译版转账合约测试 npx caliper benchmark run --caliper-workspace caliper-benchmarks --caliper-benchconfig benchmarks/samples/fisco-bcos/transfer/precompiled/config.yaml --caliper-networkconfig networks/fisco-bcos/4nodes1group/fisco-bcos.json
问题记录:
1、
fatal: unable to access 'https://github.com/frozeman/bignumber.js-nolookahead.git/': Failed to connect to github.com port 443: Connection refused
确保能够上github,如果能,则多试几次
2、Depolying error: Error: Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: 982005432c484060b0c89ec0b321ad72
Failed to install smart contract helloworld, path=/home/shijianfeng/fisco/benchmarks/caliper-benchmarks/src/fisco-bcos/helloworld/HelloWorld.sol
参考一下内容:
https://github.com/FISCO-BCOS/FISCO-BCOS/issues/1248
https://github.com/hyperledger/caliper/pull/677/files
https://github.com/hyperledger/caliper/pull/647/files
即需修改源码,其目录为:./benchmarks/node_modules/@hyperledger/caliper-fisco-bcos/lib
修改的文件是:fiscoBcos , channelPromise , web3sync
3、Depolying error: TypeError: secp256k1.sign is not a function
指定secp256k1依赖包时版本限制没写对,导致在绑定时时自动安装了4.0版本的secp256k1包,但是最新的4.0的包API全部变了,导致执行出错。
方法1 :
进入node_modules/@hyperledger/caliper-fisco-bcos目录,编辑该目录下的package.json文件,在"dependencies"中添加一项"secp256k1": "^3.8.0",随后在该目录下执行npm i,更新完成后测试程序就能启动了。
方法2:
npm i secp256k1@3.0.0 或 sudo npm i secp256k1@3.0.0