github.com/suchongming/fabric@v2.1.1+incompatible/integration/gossip/gossip_suite_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package gossip
     8  
     9  import (
    10  	"encoding/json"
    11  	"testing"
    12  
    13  	"github.com/hyperledger/fabric/integration"
    14  	"github.com/hyperledger/fabric/integration/nwo"
    15  	. "github.com/onsi/ginkgo"
    16  	. "github.com/onsi/gomega"
    17  )
    18  
    19  func TestGossip(t *testing.T) {
    20  	RegisterFailHandler(Fail)
    21  	RunSpecs(t, "Gossip Communication Suite")
    22  }
    23  
    24  var (
    25  	buildServer *nwo.BuildServer
    26  	components  *nwo.Components
    27  )
    28  
    29  var _ = SynchronizedBeforeSuite(func() []byte {
    30  	buildServer = nwo.NewBuildServer()
    31  	buildServer.Serve()
    32  
    33  	components = buildServer.Components()
    34  	payload, err := json.Marshal(components)
    35  	Expect(err).NotTo(HaveOccurred())
    36  
    37  	return payload
    38  }, func(payload []byte) {
    39  	err := json.Unmarshal(payload, &components)
    40  	Expect(err).NotTo(HaveOccurred())
    41  })
    42  
    43  var _ = SynchronizedAfterSuite(func() {
    44  }, func() {
    45  	buildServer.Shutdown()
    46  })
    47  
    48  func StartPort() int {
    49  	return integration.GossipBasePort.StartPortForNode()
    50  }