Skip to content

Commit

Permalink
[FAB-10172] Extended Unit test for discovery
Browse files Browse the repository at this point in the history
This change set adds an extended unit test for discovery, which:
- Uses production implementations of all discovery components, including
  the discovery support objects found under discovery/
- Uses production implementations of MSPs and real x509 identities
- Uses a real genesis block from configtxgen for config query testing
- Uses a mock gossip implementation
- Uses a mock ledger implementation, but a production lifecycle
  support (the object that intermediates between discovery and the ledger
  and is found under core/cclifecycle
- Uses real gRPC servers and clients with TLS.
  The gRPC servers listen to ephemeral ports, so we won't get
  a bind: already in use error in CI ;)

The test contains the following tests:

TestGreenPath: Tests all query types, specifically:
- cc2cc endorsers query and endorsers query with collections
- both channel and local peer query
- config query

TestRevocation:
- Queries once to warmup the cache
- Queries twice to ensure the underlying MSP isn't used
  because the ACL cache takes the hit
- Advances the config sequence and artificially revokes
  all identities in the MSP manager
- Queries thrice and sees that the cache isn't hit,
  and that "access denied" is returned

TestEndorsementComputationFailure:
- tests a case where the collection policy doesn't cover
  any possible principal set combination for endorsement

TestLedgerFailure:
- Tests that querying from the ledger fails in some of the keys

Change-Id: I717572e04c8f178ef10bd3807f707cf58da0b406
Signed-off-by: yacovm <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed Jun 4, 2018
1 parent 9d485a6 commit 63231a0
Show file tree
Hide file tree
Showing 5 changed files with 1,035 additions and 0 deletions.
2 changes: 2 additions & 0 deletions discovery/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type ConfigSequenceSupport interface {
ConfigSequence(channel string) uint64
}

//go:generate mockery -name GossipSupport -case underscore -output ../support/mocks/

// GossipSupport aggregates abilities that the gossip module
// provides to the discovery service, such as knowing information about peers
type GossipSupport interface {
Expand Down
10 changes: 10 additions & 0 deletions discovery/support/acl/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ func (s *DiscoverySupport) MSPOfPrincipal(principal *msp.MSPPrincipal) string {
return ""
}

//go:generate mockery -name ChannelPolicyManagerGetter -case underscore -output ../mocks/

// ChannelPolicyManagerGetter is a support interface
// to get access to the policy manager of a given channel
type ChannelPolicyManagerGetter interface {
// Returns the policy manager associated to the passed channel
// and true if it was the manager requested, or false if it is the default manager
Manager(channelID string) (policies.Manager, bool)
}

// NewChannelVerifier returns a new channel verifier from the given policy and policy manager getter
func NewChannelVerifier(policy string, polMgr policies.ChannelPolicyManagerGetter) *ChannelVerifier {
return &ChannelVerifier{
Expand Down
33 changes: 33 additions & 0 deletions discovery/support/mocks/channel_policy_manager_getter.go

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

75 changes: 75 additions & 0 deletions discovery/support/mocks/gossip_support.go

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

Loading

0 comments on commit 63231a0

Please sign in to comment.