嗨,我是stackoverflow的新手。如果有任何不清楚的地方,请指出。谢谢!
我刚开始研究hyperledger-fabric。作为Java程序员,我选择使用fabric-java-sdk。
我可以运行测试用例End2endIT.java后,我想更改chaincode
。我只是在fabric-sdk-java/src/test/fixture/sdkintegration/gocc/sample1/src/github.com/example_cc/example_cc.go
找到example_cc.go。但是,在我更改了链码之后,它确实没有用。即使我删除了这段代码,测试用例仍然可以运行。
因此,我猜我发现了一个错误的地方。谁能告诉我在哪里更改chaincode
? THX!
加载链码的代码
if (isFooChain) {
// on foo chain install from directory.
////For GO language and serving just a single user, chaincodeSource is mostly likely the users GOPATH
installProposalRequest.setChaincodeSourceLocation(new File(TEST_FIXTURES_PATH + "/sdkintegration/gocc/sample1"));
//[output]: src/test/fixture/sdkintegration/gocc/sample1
System.out.println(TEST_FIXTURES_PATH + "/sdkintegration/gocc/sample1");
} else {
// On bar chain install from an input stream.
installProposalRequest.setChaincodeInputStream(Util.generateTarGzInputStream(
(Paths.get(TEST_FIXTURES_PATH, "/sdkintegration/gocc/sample1", "src", CHAIN_CODE_PATH).toFile()),
Paths.get("src", CHAIN_CODE_PATH).toString()));
}
答案 0 :(得分:1)
我最后解决了这个问题,因为我注意到了fabric.sh中的fabric-sdk-java。
./fabric.sh up
强制重新创建docker容器./fabric.sh clean
清理同伴我可以在没有链代码的情况下运行调用请求的原因是我没有清理同行的列。
源代码如下:
#!/usr/bin/env bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# simple batch script making it easier to cleanup and start a relatively fresh fabric env.
if [ ! -e "docker-compose.yaml" ];then
echo "docker-compose.yaml not found."
exit 8
fi
ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION=${ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION:-}
function clean(){
rm -rf /var/hyperledger/*
if [ -e "/tmp/HFCSampletest.properties" ];then
rm -f "/tmp/HFCSampletest.properties"
fi
lines=`docker ps -a | grep 'dev-peer' | wc -l`
if [ "$lines" -gt 0 ]; then
docker ps -a | grep 'dev-peer' | awk '{print $1}' | xargs docker rm -f
fi
lines=`docker images | grep 'dev-peer' | grep 'dev-peer' | wc -l`
if [ "$lines" -gt 0 ]; then
docker images | grep 'dev-peer' | awk '{print $1}' | xargs docker rmi -f
fi
}
function up(){
if [ "$ORG_HYPERLEDGER_FABRIC_SDKTEST_VERSION" == "1.0.0" ]; then
docker-compose up --force-recreate ca0 ca1 peer1.org1.example.com peer1.org2.example.com ccenv
else
docker-compose up --force-recreate
fi
}
function down(){
docker-compose down;
}
function stop (){
docker-compose stop;
}
function start (){
docker-compose start;
}
for opt in "$@"
do
case "$opt" in
up)
up
;;
down)
down
;;
stop)
stop
;;
start)
start
;;
clean)
clean
;;
restart)
down
clean
up
;;
*)
echo $"Usage: $0 {up|down|start|stop|clean|restart}"
exit 1
esac
done