Skip to content

Commit 63231a0

Browse files
committed
[FAB-10172] Extended Unit test for discovery
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>
1 parent 9d485a6 commit 63231a0

File tree

5 files changed

+1035
-0
lines changed

5 files changed

+1035
-0
lines changed

discovery/api.go

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ type ConfigSequenceSupport interface {
2727
ConfigSequence(channel string) uint64
2828
}
2929

30+
//go:generate mockery -name GossipSupport -case underscore -output ../support/mocks/
31+
3032
// GossipSupport aggregates abilities that the gossip module
3133
// provides to the discovery service, such as knowing information about peers
3234
type GossipSupport interface {

discovery/support/acl/support.go

+10
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ func (s *DiscoverySupport) MSPOfPrincipal(principal *msp.MSPPrincipal) string {
141141
return ""
142142
}
143143

144+
//go:generate mockery -name ChannelPolicyManagerGetter -case underscore -output ../mocks/
145+
146+
// ChannelPolicyManagerGetter is a support interface
147+
// to get access to the policy manager of a given channel
148+
type ChannelPolicyManagerGetter interface {
149+
// Returns the policy manager associated to the passed channel
150+
// and true if it was the manager requested, or false if it is the default manager
151+
Manager(channelID string) (policies.Manager, bool)
152+
}
153+
144154
// NewChannelVerifier returns a new channel verifier from the given policy and policy manager getter
145155
func NewChannelVerifier(policy string, polMgr policies.ChannelPolicyManagerGetter) *ChannelVerifier {
146156
return &ChannelVerifier{

discovery/support/mocks/channel_policy_manager_getter.go

+33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

discovery/support/mocks/gossip_support.go

+75
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)