在fabric中,sample提供了一脚本network.sh,不仅可以检测当前的环境配置是否正确,还可以在里头测试部署你写的链码。
以下是network.sh的官方文档,我把它翻译了以下,方便使用
路径为 fabric-samples/test-network/network.sh
Usage: network脚本的用法
network.sh <Mode> [Flags]
Modes:
up - bring up fabric orderer and peer nodes. No channel is created 生成fabric排序节点和普通节点,不会创建channel
up createChannel - bring up fabric network with one channel 生成一个channel
createChannel - create and join a channel after the network is created 在网络被创建好好,创建并且加入一个channel
deployCC - deploy the asset transfer basic chaincode on the channel or specify 在channel中调用asset transfer basic链码或者指定的链码
down - clear the network with docker-compose down清除网络和docker-compose
restart - restart the network重启网络
Flags:
-ca <use CAs> - create Certificate Authorities to generate the crypto material 创建一个CA以生成密码材料
-c <channel name> - channel name to use (defaults to "mychannel")待使用的通道名称
-s <dbtype> - the database backend to use: goleveldb (default) or couchdb要使用的数据库后端,默认leveldb
-r <max retry> - CLI times out after certain number of attempts (defaults to 5)CLI(客户端)尝试超时的时间(默认5s)
-d <delay> - delay duration in seconds (defaults to 3)延迟时间(默认3s)
-ccn <name> - the short name of the chaincode to deploy: basic (default),ledger, private, secured要调用的链码简称,默认(basic),ledger,private,secured
-ccl <language> - the programming language of the chaincode to deploy: go (default), java, javascript, typescript 调用链码使用的程序语言,默认go,java,javascript,typescript
-ccv <version> - chaincode version. 1.0 (default)链码版本(默认1.0)
-ccs <sequence> - chaincode definition sequence. Must be an integer, 1 (default), 2, 3, etc 定义链码的数顺序,必须是整数,例如1,2,3,默认为1,
-ccp <path> - Optional, chaincode path. Path to the chaincode. When provided the -ccn will be used as the deployed name and not the short name of the known chaincodes. 可选项,链码的路径,提供-ccn时,将用作部署名称,而不是已知链码的短名称。
-cci <fcn name> - Optional, chaincode init required function to invoke. When provided this function will be invoked after deployment of the chaincode and will define the chaincode as initialization required. 可选项,链码需要调用的函数名称。当提供该函数时,将在部署链码后调用该函数,并将链码定义为初始化所需的代码。
-i <imagetag> - the tag to be used to launch the network (defaults to "latest") 用于启动网络所使用的标签,默认latest
-cai <ca_imagetag> - the image tag to be used for CA (defaults to "latest")ca使用的镜像标签,默认latest
-verbose - verbose mode详细模式
-h - print this message 打印这条信息
Possible Mode and flag combinations可能的mode和flag组合
up -ca -c -r -d -s -i -verbose
up createChannel -ca -c -r -d -s -i -verbose
createChannel -c -r -d -verbose
deployCC -ccn -ccl -ccv -ccs -ccp -cci -r -d -verbose
Taking all defaults:接受所有默认值
network.sh up
Examples: 例子
network.sh up createChannel -ca -c mychannel -s couchdb -i 2.0.0
network.sh createChannel -c channelName
network.sh deployCC -ccn basic -ccl javascript