Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FAB-18120] Adding DevMode integration test for new lifecycle.
* Added integration test for DevMode using new lifecycle.

Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
  • Loading branch information
DereckLuo authored and sykesm committed Aug 25, 2020
1 parent 23088b6 commit 3386c80
Show file tree
Hide file tree
Showing 9 changed files with 416 additions and 10 deletions.
4 changes: 4 additions & 0 deletions integration/chaincode/simple/chaincode.go
Expand Up @@ -8,6 +8,7 @@ package simple

import (
"fmt"
"os"
"strconv"

"github.com/hyperledger/fabric-chaincode-go/shim"
Expand Down Expand Up @@ -59,6 +60,9 @@ func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {

func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
fmt.Println("ex02 Invoke")
if os.Getenv("DEVMODE_ENABLED") != "" {
fmt.Println("invoking in devmode")
}
function, args := stub.GetFunctionAndParameters()
switch function {
case "invoke":
Expand Down
4 changes: 4 additions & 0 deletions integration/chaincode/simple/cmd/main.go
Expand Up @@ -62,6 +62,10 @@ func main() {
}
}()

if os.Getenv("DEVMODE_ENABLED") != "" {
fmt.Println("starting up in devmode...")
}

var err error
select {
case err = <-startErrChan:
Expand Down
50 changes: 50 additions & 0 deletions integration/devmode/devmode_suite_test.go
@@ -0,0 +1,50 @@
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package devmode

import (
"encoding/json"
"testing"

"github.com/hyperledger/fabric/integration"
"github.com/hyperledger/fabric/integration/nwo"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func TestEndToEnd(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Devmode Suite")
}

var (
buildServer *nwo.BuildServer
components *nwo.Components
)

var _ = SynchronizedBeforeSuite(func() []byte {
buildServer = nwo.NewBuildServer()
buildServer.Serve()

components = buildServer.Components()
payload, err := json.Marshal(components)
Expect(err).NotTo(HaveOccurred())

return payload
}, func(payload []byte) {
err := json.Unmarshal(payload, &components)
Expect(err).NotTo(HaveOccurred())
})

var _ = SynchronizedAfterSuite(func() {
}, func() {
components.Cleanup()
})

func StartPort() int {
return integration.DevModePort.StartPortForNode()
}

0 comments on commit 3386c80

Please sign in to comment.