caliper压力测试,自定义测试用例,以及报错处理总结(二)

一、caliper测试

接上篇文章caliper压力测试,自定义测试用例,以及报错处理总结(一)_晚风皆是过客.的博客-CSDN博客

部署caliper,完成测试

二、报错处理总结

2.1 错误1    fatal: unable to access 'https://github.com/creationix/nvm.git/': Could not resolve host: github.com

caliper压力测试,自定义测试用例,以及报错处理总结(二)_第1张图片

 解决办法

sudo vim /etc/hosts

打开hosts文件,将这个域名加到localhost下面即可

140.82.114.4    github.com

 问题解决

caliper压力测试,自定义测试用例,以及报错处理总结(二)_第2张图片

 2.2 错误2

Command 'npm' not found

这个是npm init的时候,我们就需要重新下载一下npm

sudo apt install npm

2.3 错误3

npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! Linux 5.4.0-124-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "--only=prod" "@hyperledger/[email protected]"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! path /home/fisco/benchmarks/node_modules/.staging/@types/node-77814c16/package.json
npm ERR! code ENOTDIR
npm ERR! errno -20
npm ERR! syscall open
 
npm ERR! ENOTDIR: not a directory, open '/home/fisco/benchmarks/node_modules/.staging/@types/node-77814c16/package.json'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     
 
npm ERR! Please include the following file with any support request:
npm ERR!     /home/fisco/benchmarks/npm-debug.log

这个问题就是Npm和nodejs版本不对{"node":">=8.10.0","npm":">=5.6.0"} 

 需要使用nvm 8

nvm use 8

2.4 错误4  dial unix /var/run/docker.sock: connect: permission denied

 error [caliper] [fiscoBcosApi.js] 	Compiling error: 
docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

2023.07.23-01:30:05.744 error [caliper] [installSmartContract.js] 	Depolying error: undefined
2023.07.23-01:30:05.744 error [caliper] [installSmartContract.js] 	Failed to install smart contract helloworld, path=/home/csdn/testFisco/benchmarks/caliper-benchmarks/src/fisco-bcos/helloworld/HelloWorld.sol

 

caliper压力测试,自定义测试用例,以及报错处理总结(二)_第3张图片

 这是因为用户没有加入docker用户组的原因

解决办法

sudo groupadd docker               #添加用户组
sudo gpasswd -a username docker    #将当前用户添加至用户组
#sudo gpasswd -a csdn docker
newgrp docker                      #更新用户组

2.5 错误5    Depolying error: Error: Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: 982005432c484060b0c89ec0b321ad72Failed to install smart contract helloworld, path=/home/shijianfeng/fisco/benchmarks/caliper-benchmarks/src/fisco-bcos/helloworld/HelloWorld.sol
 

error [caliper] [installSmartContract.js] 	Depolying error: Error: Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: 46bcc91063db42968a300e3a32d96b88
2023.07.23-01:35:01.776 error [caliper] [installSmartContract.js] 	Failed to install smart contract helloworld, path=/home/csdn/testFisco/benchmarks/caliper-benchmarks/src/fisco-bcos/helloworld/HelloWorld.sol
2023.07.23-01:35:01.777 error [caliper] [caliper-flow] 	Error: TypeError: Color.error is not a function
    at FiscoBcos.installSmartContract (/home/csdn/testFisco/benchmarks/node_modules/@hyperledger/caliper-fisco-bcos/lib/fiscoBcos.js:62:36)
    at 

caliper压力测试,自定义测试用例,以及报错处理总结(二)_第4张图片

 这是因为根据官方文档提示有些文件配置没有修改

进入到/node_modules/@hyperledger/caliper-fisco-bcos/lib目录下对fiscoBcos.js进行修改

 

 fiscoBcos.js

sudo vim fiscoBcos.js
......

​const invokeSmartContractImpl = require('./invokeSmartContract');
const generateRawTransactionImpl = require('./generateRawTransactions');
const sendRawTransactionImpl = require('./sendRawTransactions');
#const Color = require('./common');#删除掉这一行
const Color = require('./common').Color;#修改为这一行
const commLogger = CaliperUtils.getLogger('fiscoBcos.js');

​......

 this.bcType = 'fisco-bcos';
        this.workspaceRoot = workspace_root;
        this.fiscoBcosSettings = CaliperUtils.parseYaml(this.configPath)['fisco-bcos'];
        #从这里开始添加
        if (this.fiscoBcosSettings.network && this.fiscoBcosSettings.network.authentication) {
            for (let k in this.fiscoBcosSettings.network.authentication) {
                this.fiscoBcosSettings.network.authentication[k] = CaliperUtils.resolvePath(this.fiscoBcosSettings.network.authentication[k], workspace_root);
            }
        }
        #到这里结束
    }

​......

    async installSmartContract() {
        #const fiscoBcosSettings = CaliperUtils.parseYaml(this.configPath)['fisco-bcos'];#删除掉这一行
        const fiscoBcosSettings = this.fiscoBcosSettings;#替换为这一行
        try {
            await installSmartContractImpl.run(fiscoBcosSettings, this.workspaceRoot);
        } catch (error) {

......

​

channelPromise.js  

sudo vim channelPromise.js 
......

function parseResponse(response) {
    let seq = response.slice(6, 38).toString();
    let result = JSON.parse(response.slice(42).toString());
    #let emitter = emitters.get(seq).emitter;#删除掉这一行
    #从这里开始添加
    let emitter = emitters.get(seq);
    if(!emitter) {
        //Stale message receieved
        return;
    }
    emitter = emitter.emitter;
    #到这里结束

    if (emitter) {
        let readOnly = Object.getOwnPropertyDescriptor(emitter, 'readOnly').value;

web3sync.js

 进入到/node_modules/@hyperledger/caliper-fisco-bcos/lib/web3lib目录下对web3sync.js进行修改

sudo vim web3sync.js
......

function genRandomID() {
    let uuid = uuidv4();
    #uuid = uuid.replace(/-/g, '');#删除掉这一行
    uuid = '0x' + uuid.replace(/-/g, '');#替换为这一行

    return uuid;
}

......

        blockLimit: blockLimit,
        chainId: 1,
        groupId: groupId,
        extraData: ''
        extraData: '0x0'#修改为这行
    };

    return signTransaction(postdata, privateKey, null);

......

        blockLimit: blockLimit,
        chainId: 1,
        groupId: groupId,
        extraData: ''
        extraData: '0x0'#修改为这行
    };

    return signTransaction(postdata, privateKey, null);

......

2.6 错误6  Depolying error: TypeError: secp256k1.sign is not a function

  

 error [caliper] [installSmartContract.js] 	Depolying error: TypeError: secp256k1.sign is not a function
2023.07.23-01:56:04.406 error [caliper] [installSmartContract.js] 	Failed to install smart contract helloworld, path=/home/csdn/testFisco/benchmarks/caliper-benchmarks/src/fisco-bcos/helloworld/HelloWorld.sol
2023.07.23-01:56:04.407 error [caliper] [fiscoBcos.js] 	FISCO BCOS smart contract install failed: TypeError: secp256k1.sign is not a function
    at Object.ecsign (/home/csdn/testFisco/benchmarks/node_modules/@hyperledger/caliper-fisco-bcos/lib/web3lib/utils.js:141:29)
    at Transaction.sign (/home/csdn/testFisco/benchmarks/node_modules/@hyperledger/caliper-fisco-bcos/lib/web3lib/transactionObject.js:272:23)
    at signTransaction (/home/csdn/testFisco/benchmarks/node_modules/@hyperledger/caliper-fisco-bcos/lib/web3lib/web3sync.js:42:8)
    at Object.getSignDeployTx (/home/csdn/testFisco/benchmarks/node_modules/@hyperledger/caliper-fisco-bcos/lib/web3lib/web3sync.js:121:12)
    at Object.module.exports.deploy (/home/csdn/testFisco/benchmarks/node_modules/@hyperledger/caliper-fisco-bcos/lib/fiscoBcosApi.js:165:27)
    at 

caliper压力测试,自定义测试用例,以及报错处理总结(二)_第5张图片

 解决办法

指定secp256k1依赖包时版本限制没写对,导致在绑定时时自动安装了4.0版本的secp256k1包,但是最新的4.0的包API全部变了,导致执行出错。

有一个临时的解决方案,进入node_modules/@hyperledger/caliper-fisco-bcos目录,编辑该目录下的package.json文件,在"dependencies"中添加一项"secp256k1": "^3.8.0",随后在该目录下执行npm i,更新完成后测试程序就能启动了。

caliper压力测试,自定义测试用例,以及报错处理总结(二)_第6张图片

 在该目录下npm i 就可以了

你可能感兴趣的:(fisco-bcos,压力测试,测试用例,区块链,运维)