diff --git a/.gitignore b/.gitignore index 7a9e3f87b43..e3929e5082c 100755 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,8 @@ tags *.log # bddtest coverage files bddtests/coverage +# bddtest Dockerfile +bddtests/environments/kafka/Dockerfile *.cov # Makefile dummy artifacts .*-dummy diff --git a/gossip/api/channel.go b/gossip/api/channel.go index 7dbd00e6a1a..bb1ee8b48cb 100644 --- a/gossip/api/channel.go +++ b/gossip/api/channel.go @@ -32,8 +32,6 @@ type SecurityAdvisor interface { // Verify verifies a JoinChannelMessage, returns nil on success, // and an error on failure Verify(JoinChannelMessage) error - - } // ChannelNotifier is implemented by the gossip component and is used for the peer diff --git a/gossip/comm/comm_impl.go b/gossip/comm/comm_impl.go index 5eaf02651ce..65454a23310 100644 --- a/gossip/comm/comm_impl.go +++ b/gossip/comm/comm_impl.go @@ -544,7 +544,6 @@ func createGRPCLayer(port int) (*grpc.Server, net.Listener, grpc.DialOption, []b var serverOpts []grpc.ServerOption var dialOpts grpc.DialOption - keyFileName := fmt.Sprintf("key.%d.pem", rand.Int63()) certFileName := fmt.Sprintf("cert.%d.pem", rand.Int63()) diff --git a/gossip/comm/comm_test.go b/gossip/comm/comm_test.go index 745f003c3e1..cdcfd9b2d6b 100644 --- a/gossip/comm/comm_test.go +++ b/gossip/comm/comm_test.go @@ -426,11 +426,11 @@ func TestReConnections(t *testing.T) { // comm1 connects to comm2 comm1.Send(createGossipMsg(), remotePeer(3612)) - waitForMessages(t, out2 , 1, "Comm2 didn't receive a message from comm1 in a timely manner") + waitForMessages(t, out2, 1, "Comm2 didn't receive a message from comm1 in a timely manner") time.Sleep(time.Second) // comm2 sends to comm1 comm2.Send(createGossipMsg(), remotePeer(3611)) - waitForMessages(t, out1 , 1, "Comm1 didn't receive a message from comm2 in a timely manner") + waitForMessages(t, out1, 1, "Comm1 didn't receive a message from comm2 in a timely manner") comm1.Stop() comm1, _ = newCommInstance(3611, naiveSec) @@ -438,7 +438,7 @@ func TestReConnections(t *testing.T) { out1 = make(chan uint64, 1) go reader(out1, comm1.Accept(acceptAll)) comm2.Send(createGossipMsg(), remotePeer(3611)) - waitForMessages(t, out1 , 1, "Comm1 didn't receive a message from comm2 in a timely manner") + waitForMessages(t, out1, 1, "Comm1 didn't receive a message from comm2 in a timely manner") } func TestProbe(t *testing.T) { diff --git a/gossip/comm/mock/mock_comm.go b/gossip/comm/mock/mock_comm.go index e5134c5c9f8..2f8884284e3 100644 --- a/gossip/comm/mock/mock_comm.go +++ b/gossip/comm/mock/mock_comm.go @@ -186,4 +186,3 @@ func (mock *commMock) Stop() { func (mock *commMock) BlackListPKIid(PKIid common.PKIidType) { // NOOP } - diff --git a/gossip/discovery/discovery.go b/gossip/discovery/discovery.go index 9fe1080d9a4..fb9d282b9a1 100644 --- a/gossip/discovery/discovery.go +++ b/gossip/discovery/discovery.go @@ -17,8 +17,8 @@ limitations under the License. package discovery import ( - "github.com/hyperledger/fabric/gossip/proto" "github.com/hyperledger/fabric/gossip/common" + "github.com/hyperledger/fabric/gossip/proto" ) // CryptoService is an interface that the discovery expects to be implemented and passed on creation diff --git a/gossip/election/election.go b/gossip/election/election.go index 9111ceef2fd..d5635bf9868 100644 --- a/gossip/election/election.go +++ b/gossip/election/election.go @@ -45,7 +45,6 @@ var ( // only 1 leader should be left eventually // - Peers communicate by gossiping leadership proposal or declaration messages - // The Algorithm, in pseudo code: // // @@ -86,8 +85,6 @@ var ( // than yourself was received, return. // Else, declare yourself a leader - - // LeaderElectionAdapter is used by the leader election module // to send and receive messages and to get membership information type LeaderElectionAdapter interface { diff --git a/gossip/filter/filter.go b/gossip/filter/filter.go index 773aa9fe0e7..4b09c57831e 100644 --- a/gossip/filter/filter.go +++ b/gossip/filter/filter.go @@ -43,7 +43,7 @@ func CombineRoutingFilters(filters ...RoutingFilter) RoutingFilter { func SelectPeers(k int, peerPool []discovery.NetworkMember, filters ...RoutingFilter) []*comm.RemotePeer { var filteredPeers []*comm.RemotePeer for _, peer := range peerPool { - if CombineRoutingFilters(filters ...)(peer) { + if CombineRoutingFilters(filters...)(peer) { filteredPeers = append(filteredPeers, &comm.RemotePeer{PKIID: peer.PKIid, Endpoint: peer.Endpoint}) } } diff --git a/gossip/gossip/certstore.go b/gossip/gossip/certstore.go index 6a7123d2a35..b96b2223c87 100644 --- a/gossip/gossip/certstore.go +++ b/gossip/gossip/certstore.go @@ -99,7 +99,7 @@ func (cs *certStore) handleMessage(msg comm.ReceivedMessage) { func (cs *certStore) validateIdentityMsg(msg *proto.GossipMessage) error { idMsg := msg.GetPeerIdentity() if idMsg == nil { - return fmt.Errorf("Identity empty:", msg) + return fmt.Errorf("Identity empty: %+v", msg) } pkiID := idMsg.PkiID cert := idMsg.Cert diff --git a/gossip/gossip/channel/channel.go b/gossip/gossip/channel/channel.go index 810b6065f24..19c6bd85403 100644 --- a/gossip/gossip/channel/channel.go +++ b/gossip/gossip/channel/channel.go @@ -538,4 +538,4 @@ func (gc *gossipChannel) UpdateStateInfo(msg *proto.GossipMessage) { // NewStateInfoMessageStore returns a MessageStore func NewStateInfoMessageStore() msgstore.MessageStore { return msgstore.NewMessageStore(proto.NewGossipMessageComparator(0), func(m interface{}) {}) -} \ No newline at end of file +} diff --git a/gossip/gossip/gossip.go b/gossip/gossip/gossip.go index b899c4d3a79..712fbb088fc 100644 --- a/gossip/gossip/gossip.go +++ b/gossip/gossip/gossip.go @@ -20,6 +20,7 @@ import ( "time" "crypto/tls" + "github.com/hyperledger/fabric/gossip/api" "github.com/hyperledger/fabric/gossip/comm" "github.com/hyperledger/fabric/gossip/common" diff --git a/gossip/gossip/gossip_impl.go b/gossip/gossip/gossip_impl.go index a6781b6781f..625710a79f5 100644 --- a/gossip/gossip/gossip_impl.go +++ b/gossip/gossip/gossip_impl.go @@ -826,13 +826,13 @@ func (g *gossipServiceImpl) createStateInfoMsg(metadata []byte, chainID common.C b, err := prot.Marshal(stateInfMsg) if err != nil { - g.logger.Error("Failed marshalling StateInfo message:", err) + g.logger.Error("Failed marshalling StateInfo message: ", err) return nil, err } sig, err := g.mcs.Sign(b) if err != nil { - g.logger.Errorf("Failed signing StateInfo message:", err) + g.logger.Error("Failed signing StateInfo message: ", err) return nil, err } diff --git a/gossip/gossip/gossip_test.go b/gossip/gossip/gossip_test.go index b1c36df6714..8b88a057977 100644 --- a/gossip/gossip/gossip_test.go +++ b/gossip/gossip/gossip_test.go @@ -766,7 +766,7 @@ var testingg = func(g goroutine) bool { return strings.Index(g.stack[len(g.stack)-1], "testing.go") != -1 } -func anyOfPredicates(predicates ... goroutinePredicate) goroutinePredicate { +func anyOfPredicates(predicates ...goroutinePredicate) goroutinePredicate { return func(g goroutine) bool { for _, pred := range predicates { if pred(g) { @@ -778,7 +778,7 @@ func anyOfPredicates(predicates ... goroutinePredicate) goroutinePredicate { } func shouldNotBeRunningAtEnd(gr goroutine) bool { - return ! anyOfPredicates(runTests, goExit, testingg, waitForTestCompl, gossipTest, clientConn, connectionLeak)(gr) + return !anyOfPredicates(runTests, goExit, testingg, waitForTestCompl, gossipTest, clientConn, connectionLeak)(gr) } func ensureGoroutineExit(t *testing.T) { diff --git a/gossip/integration/integration.go b/gossip/integration/integration.go index b0e2f41f7a6..eee6e87d368 100644 --- a/gossip/integration/integration.go +++ b/gossip/integration/integration.go @@ -101,7 +101,6 @@ func (cs *naiveCryptoService) Verify(vkID api.PeerIdentityType, signature, messa } type orgCryptoService struct { - } // OrgByPeerIdentity returns the OrgIdentityType @@ -114,4 +113,4 @@ func (*orgCryptoService) OrgByPeerIdentity(identity api.PeerIdentityType) api.Or // and an error on failure func (*orgCryptoService) Verify(joinChanMsg api.JoinChannelMessage) error { return nil -} \ No newline at end of file +} diff --git a/gossip/proto/extensions.go b/gossip/proto/extensions.go index 4f3820009e2..6b146812062 100644 --- a/gossip/proto/extensions.go +++ b/gossip/proto/extensions.go @@ -20,6 +20,7 @@ import ( "bytes" "fmt" + "github.com/hyperledger/fabric/gossip/common" "github.com/hyperledger/fabric/gossip/util" ) diff --git a/gossip/state/metastate.go b/gossip/state/metastate.go index 2e604d8a1ca..e88392d1d46 100644 --- a/gossip/state/metastate.go +++ b/gossip/state/metastate.go @@ -59,7 +59,7 @@ func (n *NodeMetastate) Update(height uint64) { // FromBytes - encode from byte array into meta data structure func FromBytes(buf []byte) (*NodeMetastate, error) { - state := NodeMetastate{} + state := NodeMetastate{} reader := bytes.NewReader(buf) // As bytes are written in the big endian to keep supporting // cross platforming and for consistency reasons read also diff --git a/gossip/state/metastate_test.go b/gossip/state/metastate_test.go index 375c79fe1b0..de41ba125d3 100644 --- a/gossip/state/metastate_test.go +++ b/gossip/state/metastate_test.go @@ -18,6 +18,7 @@ package state import ( "testing" + "github.com/docker/docker/pkg/testutil/assert" ) @@ -71,4 +72,4 @@ func TestNodeMetastate_FromBytes(t *testing.T) { updatedState, err := FromBytes(bytes) assert.NilError(t, err) assert.Equal(t, updatedState.Height(), uint64(17)) -} \ No newline at end of file +} diff --git a/gossip/util/misc.go b/gossip/util/misc.go index 297c5ba2a3e..3b5e0413f3c 100644 --- a/gossip/util/misc.go +++ b/gossip/util/misc.go @@ -130,4 +130,4 @@ func PrintStackTrace() { buf := make([]byte, 1<<16) runtime.Stack(buf, true) fmt.Printf("%s", buf) -} \ No newline at end of file +} diff --git a/scripts/golinter.sh b/scripts/golinter.sh index 08ceb96863d..520c4162823 100755 --- a/scripts/golinter.sh +++ b/scripts/golinter.sh @@ -2,7 +2,7 @@ set -e -declare -a arr=("./core" "./events" "./examples" "./peer" "./protos" "./orderer") +declare -a arr=("./core" "./events" "./examples" "./peer" "./protos" "./orderer" "./msp" "./gossip") for i in "${arr[@]}" do