Hyperledger Fabric性能测试工具:Stupid

前提:
1、已启动区块链网络,并安装实例化安装链码
2、docker ps 可查看已启动的服务

服务器地址: ssh IP地址 -l root

fabric-samples 和 test-network所在目录:
/usr/local/src/hyperleger/fabric/scripts
/usr/local/src/hyperleger/fabric/scripts/fabric-samples
创建stupid工作空间,与fabric-samples同级目录:

mkdir stupid-workspace

stupid源码下载:

 git clone https://github.com/18640869382/stupid.git

go版本查询:go version
golang代理:

export GO111MODULE=on
export GOPROXY=https://goproxy.cn

进入stupid文件夹内构建:cd stupid
编译二进制:go build
stupid位置:

/usr/local/src/hyperleger/fabric/scripts/stupid-workspace1/stupid

参数配置文件:cat config.json
执行测试命令:./stupid config.json 500
其中500为要发送的交易数
注意:需要把peer0.org1.example.com 跟orderer.example.com写到本机的hosts文件中
参数内容:
{
"peer_addr": "peer0.org1.example.com:7051",
"orderer_addr": "orderer.example.com:7050",
"channel": "mychannel",
"chaincode": "basic",
"args": [ "GetAllAssets"],
"mspid": "Org1MSP",
"private_key": "/usr/local/src/hyperleger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk",
"sign_cert": "/usr/local/src/hyperleger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem",
"tls_ca_certs": ["/usr/local/src/hyperleger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem","/usr/local/src/hyperleger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem"],
"num_of_conn": 20,
"client_per_conn": 40
}

参数说明:
"peer_addr": peer节点地址与端口
"orderer_addr":orderer节点地址与端口
"channel": 通道名称
"chaincode": 链码名称,区块链内指定的,不是文件名称
"args": 合约方法,
"mspid": MSP的ID,
"private_key”:私钥文件 ,
"sign_cert":签名证书文件 ,
"tls_ca_certs": peer证书、orderer证书,
"num_of_conn": client端与peer端、orderer端之间所建立的grpc连接数
"client_per_conn": 指向一个peer发送交易提案的客户端数目
测试结果:
2021-06-17T03:15:40.png
结果中的 Tx 10可以修改,在 fabric 下 configtx.yaml 文件中的出块策略
Max Message Count: The maximum number of messages to permit in a batch
2021-06-17T03:15:54.png
路径:
/usr/local/src/hyperleger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml

本文链接:

http://wanyor.com/2021/06/17/260.html