Skip to content

Commit

Permalink
[FAB-13344] move protoc target out of testdata
Browse files Browse the repository at this point in the history
The use of testdata for code that needs to be compiled was causing
issues with go tools.

Change-Id: Idf0fcafc7a62abc7c0261bcb474706861f8c66cb
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
  • Loading branch information
sykesm committed Dec 19, 2018
1 parent 1777374 commit 1646757
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion core/comm/client_test.go
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/comm"
testpb "github.com/hyperledger/fabric/core/comm/testdata/grpc"
"github.com/hyperledger/fabric/core/comm/testpb"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
Expand Down
2 changes: 1 addition & 1 deletion core/comm/connection_test.go
Expand Up @@ -18,7 +18,7 @@ import (
"testing"
"time"

testpb "github.com/hyperledger/fabric/core/comm/testdata/grpc"
"github.com/hyperledger/fabric/core/comm/testpb"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down
Expand Up @@ -4,8 +4,6 @@ Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

// +build ignore
//go:generate protoc --proto_path=$GOPATH/src/github.com/hyperledger/fabric/core/comm/testdata/grpc --go_out=plugins=grpc:$GOPATH/src $GOPATH/src/github.com/hyperledger/fabric/core/comm/testdata/grpc/test.proto

//go:generate protoc --proto_path=$GOPATH/src/github.com/hyperledger/fabric/core/comm/testdata/grpc --go_out=plugins=grpc:$GOPATH/src test.proto

package grpc
package comm_test
2 changes: 1 addition & 1 deletion core/comm/server_test.go
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/hyperledger/fabric/common/crypto/tlsgen"
"github.com/hyperledger/fabric/core/comm"
testpb "github.com/hyperledger/fabric/core/comm/testdata/grpc"
"github.com/hyperledger/fabric/core/comm/testpb"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down
2 changes: 1 addition & 1 deletion core/comm/serverstatshandler_test.go
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/hyperledger/fabric/common/metrics"
"github.com/hyperledger/fabric/common/metrics/metricsfakes"
"github.com/hyperledger/fabric/core/comm"
testpb "github.com/hyperledger/fabric/core/comm/testdata/grpc"
"github.com/hyperledger/fabric/core/comm/testpb"
. "github.com/onsi/gomega"
"google.golang.org/grpc"
"google.golang.org/grpc/stats"
Expand Down
2 changes: 1 addition & 1 deletion core/comm/testdata/grpc/test.proto
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

option go_package = "github.com/hyperledger/fabric/core/comm/testdata/grpc";
option go_package = "github.com/hyperledger/fabric/core/comm/testpb";

message Empty {}

Expand Down
41 changes: 20 additions & 21 deletions core/comm/testdata/grpc/test.pb.go → core/comm/testpb/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions core/comm/util_test.go
Expand Up @@ -18,7 +18,7 @@ import (

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/comm"
grpc_testdata "github.com/hyperledger/fabric/core/comm/testdata/grpc"
"github.com/hyperledger/fabric/core/comm/testpb"
"github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/utils"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -153,9 +153,9 @@ type inspectingServer struct {
inspector comm.BindingInspector
}

func (is *inspectingServer) EmptyCall(ctx context.Context, _ *grpc_testdata.Empty) (*grpc_testdata.Empty, error) {
func (is *inspectingServer) EmptyCall(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) {
is.lastContext.Store(ctx)
return &grpc_testdata.Empty{}, nil
return &testpb.Empty{}, nil
}

func (is *inspectingServer) inspect(envelope *common.Envelope) error {
Expand All @@ -178,7 +178,7 @@ func newInspectingServer(listener net.Listener, inspector comm.BindingInspector)
GRPCServer: srv,
inspector: inspector,
}
grpc_testdata.RegisterTestServiceServer(srv.Server(), is)
testpb.RegisterTestServiceServer(srv.Server(), is)
return is
}

Expand Down Expand Up @@ -217,7 +217,7 @@ func (ins *inspection) inspectBinding(envelope *common.Envelope) error {
conn, err := grpc.DialContext(ctx, ins.server.addr, grpc.WithTransportCredentials(ins.creds), grpc.WithBlock())
defer conn.Close()
assert.NoError(ins.t, err)
_, err = grpc_testdata.NewTestServiceClient(conn).EmptyCall(context.Background(), &grpc_testdata.Empty{})
_, err = testpb.NewTestServiceClient(conn).EmptyCall(context.Background(), &testpb.Empty{})
return ins.server.inspect(envelope)
}

Expand Down
2 changes: 1 addition & 1 deletion core/peer/pkg_test.go
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/golang/protobuf/proto"
configtxtest "github.com/hyperledger/fabric/common/configtx/test"
"github.com/hyperledger/fabric/core/comm"
testpb "github.com/hyperledger/fabric/core/comm/testdata/grpc"
"github.com/hyperledger/fabric/core/comm/testpb"
"github.com/hyperledger/fabric/core/ledger/util"
"github.com/hyperledger/fabric/core/peer"
"github.com/hyperledger/fabric/msp"
Expand Down
2 changes: 1 addition & 1 deletion peer/node/status_test.go
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/hyperledger/fabric/core/admin"
"github.com/hyperledger/fabric/core/comm"
testpb "github.com/hyperledger/fabric/core/comm/testdata/grpc"
"github.com/hyperledger/fabric/core/comm/testpb"
"github.com/hyperledger/fabric/core/peer"
"github.com/hyperledger/fabric/msp"
common2 "github.com/hyperledger/fabric/peer/common"
Expand Down
1 change: 1 addition & 0 deletions scripts/golinter.sh
Expand Up @@ -38,6 +38,7 @@ fi
echo "Checking for golang.org/x/net/context"
context_whitelist=(
"^github.com/hyperledger/fabric/protos(:|/.*:)"
"^github.com/hyperledger/fabric/core/comm/testpb:"
"^github.com/hyperledger/fabric/orderer/common/broadcast/mock:"
"^github.com/hyperledger/fabric/common/grpclogging/fakes:"
"^github.com/hyperledger/fabric/common/grpclogging/testpb:"
Expand Down

0 comments on commit 1646757

Please sign in to comment.