Welcome to the Linux Foundation Forum!

Lab 10.1: Chaincode Unit Testing with MockStub -

Hello,

In the Lab 10.1: Chaincode Unit Testing with MockStub,
when I want to start the unit test command, I've got :
_go: cannot find main module, but found .git/config in /Users/xxx/go/src/github.com/hyperledger/fabric-samples
to create a module there, run:
cd ../.. && go mod init
_

It is normal?

Here is my go env result:
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/christophe.charles/Library/Caches/go-build"
GOENV="/Users/christophe.charles/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/christophe.charles/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/christophe.charles/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.2/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f9/lq3l8rtn6szdqgq0nqmg2b080000gn/T/go-build1797718618=/tmp/go-build -gno-record-gcc-switches -fno-common"

How can I solve this problem ?
Thanks :)

BR

Comments

  • Bobbijn
    Bobbijn Posts: 67

    @christophe.charles , Hello and welcome to the forum . Please provide more information as to what command was issued before you received the error message. The labs execute specific scenarios that need to be completed in the correct order. If you run into trouble it is suggested you re-do the lab from where you received the error. Hope this helps. Keep on learning!
    Bobbi

  • Hello @Bobbijn
    Thank for your answer.

    But, as shown on page 56, I ran the simple_chaincode_test.go file test with min IDE (Intellij).
    And the test is ok!

    But when I try to run the same test, in a terminal, the test is KO! :(

  • Bobbijn
    Bobbijn Posts: 67

    @christophe.charles, Hello, In this lab, a mock implementation for ChaincodeStubInterface is needed to run any tests. When testing in a terminal, some of the configurations may not work outside the lab environment. If you would like to learn more on this topic, please join the The Hyperledger Fabric Private Chaincode Working Group meetings, all are welcome to attend. https://wiki.hyperledger.org/display/fabric/Hyperledger+Fabric+Private+Chaincode . Keep learning, Bobbi

  • Thank you Bobbi ;-)
    BR

Categories

Upcoming Training