Skip to content

Commit

Permalink
Fix issues reported from goreportcard
Browse files Browse the repository at this point in the history
Change-Id: I68a8d33be6d04f04a48af5a919af773ce3aaf5cb
Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
  • Loading branch information
fqutishat committed Mar 29, 2017
1 parent 9b8d2c0 commit 583a90a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions fabric-ca-client/fabricca_test.go
Expand Up @@ -72,12 +72,12 @@ func TestRegister(t *testing.T) {
}
user.SetEnrollmentCertificate(readCert(t))
user.SetPrivateKey(mockKey)
// Register without registration name paramter
// Register without registration name parameter
_, err = fabricCAClient.Register(user, &RegistrationRequest{})
if err.Error() != "Error Registering User: Register was called without a Name set" {
t.Fatalf("Expected error without registration information. Got: %s", err.Error())
}
// Register without registration affiliation paramter
// Register without registration affiliation parameter
_, err = fabricCAClient.Register(user, &RegistrationRequest{Name: "test"})
if err.Error() != "Error Registering User: Registration request does not have an affiliation" {
t.Fatalf("Expected error without registration information. Got: %s", err.Error())
Expand Down
5 changes: 5 additions & 0 deletions fabric-ca-client/mocks/mockkey.go
Expand Up @@ -25,22 +25,27 @@ import "github.com/hyperledger/fabric/bccsp"
type MockKey struct {
}

// Bytes ...
func (m *MockKey) Bytes() ([]byte, error) {
return []byte("Not implemented"), nil
}

// SKI ...
func (m *MockKey) SKI() []byte {
return []byte("Not implemented")
}

// Symmetric ...
func (m *MockKey) Symmetric() bool {
return false
}

// Private ...
func (m *MockKey) Private() bool {
return true
}

// PublicKey ...
func (m *MockKey) PublicKey() (bccsp.Key, error) {
return m, nil
}
2 changes: 1 addition & 1 deletion fabric-client/events/consumer/consumer.go
Expand Up @@ -177,7 +177,7 @@ func (ec *eventsClient) unregister(ies []*ehpb.Interest) error {
return err
}

// Recv recieves next event - use when client has not called Start
// Recv receives next event - use when client has not called Start
func (ec *eventsClient) Recv() (*ehpb.Event, error) {
in, err := ec.stream.Recv()
if err == io.EOF {
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/orderer.go
Expand Up @@ -108,7 +108,7 @@ func (o *orderer) SendBroadcast(envelope *SignedEnvelope) error {
continue
}
if broadcastResponse.Status != common.Status_SUCCESS {
broadcastErr = fmt.Errorf("broadcast respone is not success : %v", broadcastResponse.Status)
broadcastErr = fmt.Errorf("broadcast response is not success : %v", broadcastResponse.Status)
}
}
}()
Expand Down
2 changes: 1 addition & 1 deletion fabric-client/packager/golang.go
Expand Up @@ -139,7 +139,7 @@ func generateTarGz(descriptors []*Descriptor) ([]byte, error) {
err := packEntry(tw, gw, v)
if err != nil {
closeStream(tw, gw)
return nil, fmt.Errorf("error from packEntry for %s error:", v.fqp, err.Error())
return nil, fmt.Errorf("error from packEntry for %s error %s:", v.fqp, err.Error())
}
}
closeStream(tw, gw)
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/src/github.com/example_cc/example_cc.go
Expand Up @@ -28,6 +28,7 @@ import (
type SimpleChaincode struct {
}

// Init ...
func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {
fmt.Println("########### example_cc Init ###########")
_, args := stub.GetFunctionAndParameters()
Expand Down Expand Up @@ -67,10 +68,12 @@ func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {

}

// Query ...
func (t *SimpleChaincode) Query(stub shim.ChaincodeStubInterface) pb.Response {
return shim.Error("Unknown supported call")
}

// Invoke ...
// Transaction makes payment of X units from A to B
func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
fmt.Println("########### example_cc Invoke ###########")
Expand Down
8 changes: 8 additions & 0 deletions test/integration/base_test_setup.go
Expand Up @@ -171,6 +171,7 @@ func (setup *BaseSetupImpl) GetEventHub(interestedEvents []*pb.Interest) (events
return eventHub, nil
}

// InstallCC ...
func (setup *BaseSetupImpl) InstallCC(chain fabricClient.Chain, chainCodeID string, chainCodePath string, chainCodeVersion string, chaincodePackage []byte, targets []fabricClient.Peer) error {
setup.ChangeGOPATHToDeploy()
transactionProposalResponse, _, err := chain.SendInstallProposal(chainCodeID, chainCodePath, chainCodeVersion, chaincodePackage, targets)
Expand All @@ -190,6 +191,7 @@ func (setup *BaseSetupImpl) InstallCC(chain fabricClient.Chain, chainCodeID stri

}

// InstantiateCC ...
func (setup *BaseSetupImpl) InstantiateCC(chain fabricClient.Chain, eventHub events.EventHub) error {

var args []string
Expand Down Expand Up @@ -250,6 +252,7 @@ func (setup *BaseSetupImpl) InstantiateCC(chain fabricClient.Chain, eventHub eve

}

// GetQueryValue ...
func (setup *BaseSetupImpl) GetQueryValue(t *testing.T, chain fabricClient.Chain) (string, error) {

var args []string
Expand All @@ -275,6 +278,7 @@ func (setup *BaseSetupImpl) GetQueryValue(t *testing.T, chain fabricClient.Chain
return "", nil
}

// Invoke ...
func (setup *BaseSetupImpl) Invoke(chain fabricClient.Chain, eventHub events.EventHub) (string, error) {

var args []string
Expand Down Expand Up @@ -346,6 +350,7 @@ func randomString(strlen int) string {
return string(result)
}

// ChangeGOPATHToDeploy ...
func (setup *BaseSetupImpl) ChangeGOPATHToDeploy() {
goPath = os.Getenv("GOPATH")
pwd, err := os.Getwd()
Expand All @@ -356,10 +361,12 @@ func (setup *BaseSetupImpl) ChangeGOPATHToDeploy() {
os.Setenv("GOPATH", path.Join(pwd, "../fixtures"))
}

// ResetGOPATH ...
func (setup *BaseSetupImpl) ResetGOPATH() {
os.Setenv("GOPATH", goPath)
}

// InitConfig ...
func (setup *BaseSetupImpl) InitConfig() {
err := config.InitConfig("../fixtures/config/config_test.yaml")
if err != nil {
Expand All @@ -368,6 +375,7 @@ func (setup *BaseSetupImpl) InitConfig() {
setup.GenerateRandomCCID()
}

// GenerateRandomCCID ...
func (setup *BaseSetupImpl) GenerateRandomCCID() {
rand.Seed(time.Now().UnixNano())
chainCodeID = randomString(10)
Expand Down

0 comments on commit 583a90a

Please sign in to comment.