fabric-sdk-go

Hyperledger Fabric Client SDK for Go

go get -u github.com/hyperledger/fabric-sdk-go

文档  https://godoc.org/github.com/hyperledger/fabric-sdk-go

兼容性
  • fabric v1.0.1 & fabric-ca v1.0.1
    • fabric-sdk-go: master:HEAD
  • fabric v1.0.0 & fabric-ca v1.0.0
    • fabric-sdk-go: master:110bf21bf3ab0a9a084f46d9698e1daeeda68a59
运行整体测试
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/
make depend-install
一些包无法go get到,只能git clone
make
在Makefile文件中,执行dep ensure -vendor-only时报错

原因是godep工具根据Gopkg.toml中name配置寻找包源的时候,name和包的git地址不一致,譬如
name: google.golang.org/grpc
git : https://github.com/grpc/grpc-go
name: golang.org/x/crypto
git  https://github.com/golang/crypto
name: golang.org/x/sync
git  https://github.com/golang/sync
name: golang.org/x/net
git: https://github.com/golang/net
添加source配置也无效,在github上的问题追踪https://github.com/golang/dep/issues/860
目前在Makefile中去掉"populate",不去处理vendor问题,而使用GOPATH下的依赖包
make clean
运行部分测试
# In the Fabric SDK Go directory
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/

# Ensure dependencies are installed
make depend

# Running code checks (license, linting, spelling, etc)
make checks

# Running all unit tests
make unit-test

# Running all integration tests
make integration-test
没有太好的办法,网络问题,需要多次尝试
报错:

原因是在docker compose文件中,映射目录时,将本地fabric-sdk-go目录映射到容器的fabric-sdk-go目录,依赖包采用的是vendor中包

手动将$GOPATH下的依赖包拷贝到fabric-sdk-go/vendor中
再次运行
make integration-test

用docker开启fabric网络测试环境

Testing with Local Build of Fabric (Advanced)

Alternatively you can build and run Fabric on your own box using the following commands:

# Build fabric:
cd $GOPATH/src/github.com/hyperledger/
git clone https://github.com/hyperledger/fabric
cd $GOPATH/src/github.com/hyperledger/fabric/
git checkout v1.0.1

make docker

本地镜像的tag与要求不匹配,需要手动修改镜像的tag REPOSITORY

docker tag imageId repository:tag


# Build fabric-ca:
cd $GOPATH/src/github.com/hyperledger/
git clone https://github.com/hyperledger/fabric-ca
cd $GOPATH/src/github.com/hyperledger/fabric-ca/
git checkout v1.0.1
make docker

# Start fabric - latest-env.sh overrides the default docker tags in .env
cd $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/
(source latest-env.sh && docker-compose up --force-recreate)


 
  
 
   
 

猜你喜欢

转载自blog.csdn.net/btqszl/article/details/78400707