Skip to content

Commit

Permalink
[FAB-4694] Improve test coverage
Browse files Browse the repository at this point in the history
This patch improves test coverage for the client peer package.
- Refactors the peer package
- Moves existing peer test down
- Introduces gomock
- Adds tests for the refactored peer package

Change-Id: Iaed14c61d6c383b14a9e08865d95c7328f8d15af
Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
troyronda committed Jun 26, 2017
1 parent b164375 commit 9e10dd3
Show file tree
Hide file tree
Showing 22 changed files with 1,974 additions and 221 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
# integration-test: runs all the integration tests
# checks: runs all check conditions (license, spelling, linting)
# clean: stops docker conatainers used for integration testing
# mock-gen: generate mocks needed for testing (using mockgen)
#

export ARCH=$(shell uname -m)
export LDFLAGS=-ldflags "-s"
export LDFLAGS=-ldflags=-s

all: checks unit-test integration-test

Expand Down Expand Up @@ -43,6 +44,12 @@ integration-test: clean depend

integration-tests: integration-test

mock-gen:
go get -u github.com/golang/mock/gomock
go get -u github.com/golang/mock/mockgen
mockgen -source=pkg/fabric-client/peer/peer.go -destination=pkg/fabric-client/peer/mocks/mockpeer.gen.go
mockgen -build_flags '$(LDFLAGS)' github.com/hyperledger/fabric-sdk-go/api Config | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" > api/mocks/mockconfig.gen.go

clean:
rm -Rf /tmp/enroll_user /tmp/msp /tmp/keyvaluestore
rm -f integration-report.xml report.xml
Expand Down
338 changes: 338 additions & 0 deletions api/mocks/mockconfig.gen.go

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

8 changes: 4 additions & 4 deletions api/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ type Peer interface {
IsEventListened(event string, channel Channel) (bool, error)
AddListener(eventType string, eventTypeData interface{}, eventCallback interface{}) (string, error)
RemoveListener(eventListenerRef string) (bool, error)
GetName() string
Name() string
SetName(name string)
GetRoles() []string
Roles() []string
SetRoles(roles []string)
GetEnrollmentCertificate() *pem.Block
EnrollmentCertificate() *pem.Block
SetEnrollmentCertificate(pem *pem.Block)
GetURL() string
URL() string
SendProposal(proposal *TransactionProposal) (*TransactionProposalResponse, error)
}
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func (c *config) IsTLSEnabled() bool {
}

// GetTLSCACertPool ...
// TODO: Should be related to configuration.
func (c *config) GetTLSCACertPool(tlsCertificate string) (*x509.CertPool, error) {
certPool := x509.NewCertPool()
if tlsCertificate != "" {
Expand Down
Loading

0 comments on commit 9e10dd3

Please sign in to comment.