diff --git a/common/mocks/config/application.go b/common/mocks/config/application.go deleted file mode 100644 index e0ac1728ac1..00000000000 --- a/common/mocks/config/application.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -Copyright IBM Corp. 2017 All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package config - -import ( - "github.com/hyperledger/fabric/common/channelconfig" -) - -type MockApplication struct { - CapabilitiesRv channelconfig.ApplicationCapabilities - Acls map[string]string -} - -func (m *MockApplication) Organizations() map[string]channelconfig.ApplicationOrg { - return nil -} - -func (m *MockApplication) Capabilities() channelconfig.ApplicationCapabilities { - return m.CapabilitiesRv -} - -func (m *MockApplication) PolicyRefForAPI(apiName string) string { - if m.Acls == nil { - return "" - } - return m.Acls[apiName] -} - -// Returns the mock which itself is a provider -func (m *MockApplication) APIPolicyMapper() channelconfig.PolicyMapper { - return m -} - -type MockApplicationCapabilities struct { - SupportedRv error - ForbidDuplicateTXIdInBlockRv bool - ACLsRv bool - PrivateChannelDataRv bool - CollectionUpgradeRv bool - V1_1ValidationRv bool - V1_2ValidationRv bool - LifecycleV20Rv bool - KeyLevelEndorsementRv bool - V1_3ValidationRv bool - V2_0ValidationRv bool - StorePvtDataOfInvalidTxRv bool -} - -func (mac *MockApplicationCapabilities) Supported() error { - return mac.SupportedRv -} - -func (mac *MockApplicationCapabilities) ForbidDuplicateTXIdInBlock() bool { - return mac.ForbidDuplicateTXIdInBlockRv -} - -func (mac *MockApplicationCapabilities) ACLs() bool { - return mac.ACLsRv -} - -func (mac *MockApplicationCapabilities) PrivateChannelData() bool { - return mac.PrivateChannelDataRv -} - -func (mac *MockApplicationCapabilities) CollectionUpgrade() bool { - return mac.CollectionUpgradeRv -} - -func (mac *MockApplicationCapabilities) V1_1Validation() bool { - return mac.V1_1ValidationRv -} - -func (mac *MockApplicationCapabilities) V1_2Validation() bool { - return mac.V1_2ValidationRv -} - -func (mac *MockApplicationCapabilities) LifecycleV20() bool { - return mac.LifecycleV20Rv -} - -func (mac *MockApplicationCapabilities) MetadataLifecycle() bool { - return false -} - -func (mac *MockApplicationCapabilities) KeyLevelEndorsement() bool { - return mac.KeyLevelEndorsementRv -} - -func (mac *MockApplicationCapabilities) V1_3Validation() bool { - return mac.V1_3ValidationRv -} - -func (mac *MockApplicationCapabilities) V2_0Validation() bool { - return mac.V2_0ValidationRv -} - -func (mac *MockApplicationCapabilities) StorePvtDataOfInvalidTx() bool { - return mac.StorePvtDataOfInvalidTxRv -} diff --git a/common/mocks/config/channel.go b/common/mocks/config/channel.go deleted file mode 100644 index c34570154a6..00000000000 --- a/common/mocks/config/channel.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright IBM Corp. 2016 All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package config - -import ( - "github.com/hyperledger/fabric/common/channelconfig" - "github.com/hyperledger/fabric/common/util" - "github.com/hyperledger/fabric/msp" -) - -func nearIdentityHash(input []byte) []byte { - return util.ConcatenateBytes([]byte("FakeHash("), input, []byte("")) -} - -// Channel is a mock implementation of config.Channel -type Channel struct { - // HashingAlgorithmVal is returned as the result of HashingAlgorithm() if set - HashingAlgorithmVal func([]byte) []byte - // BlockDataHashingStructureWidthVal is returned as the result of BlockDataHashingStructureWidth() - BlockDataHashingStructureWidthVal uint32 - // OrdererAddressesVal is returned as the result of OrdererAddresses() - OrdererAddressesVal []string - // CapabilitiesVal is returned as the result of Capabilities() - CapabilitiesVal channelconfig.ChannelCapabilities -} - -// HashingAlgorithm returns the HashingAlgorithmVal if set, otherwise a fake simple hash function -func (scm *Channel) HashingAlgorithm() func([]byte) []byte { - if scm.HashingAlgorithmVal == nil { - return nearIdentityHash - } - return scm.HashingAlgorithmVal -} - -// BlockDataHashingStructureWidth returns the BlockDataHashingStructureWidthVal -func (scm *Channel) BlockDataHashingStructureWidth() uint32 { - return scm.BlockDataHashingStructureWidthVal -} - -// OrdererAddresses returns the OrdererAddressesVal -func (scm *Channel) OrdererAddresses() []string { - return scm.OrdererAddressesVal -} - -// Capabilities returns CapabilitiesVal -func (scm *Channel) Capabilities() channelconfig.ChannelCapabilities { - return scm.CapabilitiesVal -} - -// ChannelCapabilities mocks the channelconfig.ChannelCapabilities interface -type ChannelCapabilities struct { - // SupportedErr is returned by Supported() - SupportedErr error - - // MSPVersionVal is returned by MSPVersion() - MSPVersionVal msp.MSPVersion - - ConsensusTypeMigrationVal bool -} - -func (cc *ChannelCapabilities) OrgSpecificOrdererEndpoints() bool { - // refusing to extend this bespoke mock - // If you want to override this return value, generate your own mock.. - return false -} - -// Supported returns SupportedErr -func (cc *ChannelCapabilities) Supported() error { - return cc.SupportedErr -} - -// MSPVersion returns MSPVersionVal -func (cc *ChannelCapabilities) MSPVersion() msp.MSPVersion { - return cc.MSPVersionVal -} - -// ConsensusTypeMigration returns ConsensusTypeMigrationVal -func (cc *ChannelCapabilities) ConsensusTypeMigration() bool { - return cc.ConsensusTypeMigrationVal -} diff --git a/common/mocks/config/channel_test.go b/common/mocks/config/channel_test.go deleted file mode 100644 index 53b49f5d3fd..00000000000 --- a/common/mocks/config/channel_test.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package config - -import ( - "testing" - - "github.com/hyperledger/fabric/common/channelconfig" -) - -func TestChannelConfigInterface(t *testing.T) { - _ = channelconfig.Channel(&Channel{}) -} diff --git a/common/mocks/config/orderer.go b/common/mocks/config/orderer.go deleted file mode 100644 index 096e25a11b6..00000000000 --- a/common/mocks/config/orderer.go +++ /dev/null @@ -1,131 +0,0 @@ -/* -Copyright IBM Corp. 2016 All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package config - -import ( - "time" - - ab "github.com/hyperledger/fabric-protos-go/orderer" - "github.com/hyperledger/fabric/common/channelconfig" -) - -// Orderer is a mock implementation of channelconfig.Orderer -type Orderer struct { - // ConsensusTypeVal is returned as the result of ConsensusType() - ConsensusTypeVal string - // ConsensusMetadataVal is returned as the result of ConsensusMetadata() - ConsensusMetadataVal []byte - // ConsensusTypeStateVal is returned as the result of ConsensusState() - ConsensusTypeStateVal ab.ConsensusType_State - - // BatchSizeVal is returned as the result of BatchSize() - BatchSizeVal *ab.BatchSize - // BatchTimeoutVal is returned as the result of BatchTimeout() - BatchTimeoutVal time.Duration - // KafkaBrokersVal is returned as the result of KafkaBrokers() - KafkaBrokersVal []string - // MaxChannelsCountVal is returns as the result of MaxChannelsCount() - MaxChannelsCountVal uint64 - // OrganizationsVal is returned as the result of Organizations() - OrganizationsVal map[string]channelconfig.OrdererOrg - // CapabilitiesVal is returned as the result of Capabilities() - CapabilitiesVal channelconfig.OrdererCapabilities -} - -// ConsensusType returns the ConsensusTypeVal -func (o *Orderer) ConsensusType() string { - return o.ConsensusTypeVal -} - -// ConsensusMetadata returns the ConsensusMetadataVal -func (o *Orderer) ConsensusMetadata() []byte { - return o.ConsensusMetadataVal -} - -// ConsensusState returns the ConsensusTypeStateVal -func (o *Orderer) ConsensusState() ab.ConsensusType_State { - return o.ConsensusTypeStateVal -} - -// BatchSize returns the BatchSizeVal -func (o *Orderer) BatchSize() *ab.BatchSize { - return o.BatchSizeVal -} - -// BatchTimeout returns the BatchTimeoutVal -func (o *Orderer) BatchTimeout() time.Duration { - return o.BatchTimeoutVal -} - -// KafkaBrokers returns the KafkaBrokersVal -func (o *Orderer) KafkaBrokers() []string { - return o.KafkaBrokersVal -} - -// MaxChannelsCount returns the MaxChannelsCountVal -func (o *Orderer) MaxChannelsCount() uint64 { - return o.MaxChannelsCountVal -} - -// Organizations returns OrganizationsVal -func (o *Orderer) Organizations() map[string]channelconfig.OrdererOrg { - return o.OrganizationsVal -} - -// Capabilities returns CapabilitiesVal -func (o *Orderer) Capabilities() channelconfig.OrdererCapabilities { - return o.CapabilitiesVal -} - -// OrdererCapabilities mocks the channelconfig.OrdererCapabilities interface -type OrdererCapabilities struct { - // SupportedErr is returned by Supported() - SupportedErr error - - // PredictableChannelTemplateVal is returned by PredictableChannelTemplate() - PredictableChannelTemplateVal bool - - // ResubmissionVal is returned by Resubmission() - ResubmissionVal bool - - // ExpirationVal is returned by ExpirationCheck() - ExpirationVal bool - - ConsensusTypeMigrationVal bool - - UseChannelCreationPolicyAsAdminsVal bool -} - -// Supported returns SupportedErr -func (oc *OrdererCapabilities) Supported() error { - return oc.SupportedErr -} - -// PredictableChannelTemplate returns PredictableChannelTemplateVal -func (oc *OrdererCapabilities) PredictableChannelTemplate() bool { - return oc.PredictableChannelTemplateVal -} - -// Resubmission returns ResubmissionVal -func (oc *OrdererCapabilities) Resubmission() bool { - return oc.ResubmissionVal -} - -// ExpirationCheck specifies whether the orderer checks for identity expiration checks -// when validating messages -func (oc *OrdererCapabilities) ExpirationCheck() bool { - return oc.ExpirationVal -} - -// ConsensusTypeMigration checks whether the orderer permits a consensus-type migration. -func (oc *OrdererCapabilities) ConsensusTypeMigration() bool { - return oc.ConsensusTypeMigrationVal -} - -func (oc *OrdererCapabilities) UseChannelCreationPolicyAsAdmins() bool { - return oc.UseChannelCreationPolicyAsAdminsVal -} diff --git a/common/mocks/config/orderer_test.go b/common/mocks/config/orderer_test.go deleted file mode 100644 index bd72b2c3a51..00000000000 --- a/common/mocks/config/orderer_test.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright IBM Corp. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package config - -import ( - "testing" - - "github.com/hyperledger/fabric/common/channelconfig" -) - -func TestOrdererConfigInterface(t *testing.T) { - _ = channelconfig.Orderer(&Orderer{}) -} diff --git a/common/mocks/config/resources.go b/common/mocks/config/resources.go deleted file mode 100644 index 3c996b1cad5..00000000000 --- a/common/mocks/config/resources.go +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright IBM Corp. 2016 All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package config - -import ( - "github.com/hyperledger/fabric/common/channelconfig" - "github.com/hyperledger/fabric/common/configtx" - "github.com/hyperledger/fabric/common/policies" - "github.com/hyperledger/fabric/msp" -) - -type Resources struct { - // ConfigtxValidatorVal is returned as the result of ConfigtxValidator - ConfigtxValidatorVal configtx.Validator - - // PolicyManagerVal is returned as the result of PolicyManager() - PolicyManagerVal policies.Manager - - // ChannelConfigVal is returned as the result of ChannelConfig() - ChannelConfigVal channelconfig.Channel - - // OrdererConfigVal is returned as the result of OrdererConfig() - OrdererConfigVal channelconfig.Orderer - - // ApplicationConfigVal is returned as the result of ApplicationConfig() - ApplicationConfigVal channelconfig.Application - - // ConsortiumsConfigVal is returned as the result of ConsortiumsConfig() - ConsortiumsConfigVal channelconfig.Consortiums - - // MSPManagerVal is returned as the result of MSPManager() - MSPManagerVal msp.MSPManager - - // ValidateNewErr is returned as the result of ValidateNew - ValidateNewErr error -} - -// ConfigtxMangaer returns ConfigtxValidatorVal -func (r *Resources) ConfigtxValidator() configtx.Validator { - return r.ConfigtxValidatorVal -} - -// Returns the PolicyManagerVal -func (r *Resources) PolicyManager() policies.Manager { - return r.PolicyManagerVal -} - -// Returns the ChannelConfigVal -func (r *Resources) ChannelConfig() channelconfig.Channel { - return r.ChannelConfigVal -} - -// Returns the OrdererConfigVal -func (r *Resources) OrdererConfig() (channelconfig.Orderer, bool) { - return r.OrdererConfigVal, r.OrdererConfigVal != nil -} - -// Returns the ApplicationConfigVal -func (r *Resources) ApplicationConfig() (channelconfig.Application, bool) { - return r.ApplicationConfigVal, r.ApplicationConfigVal != nil -} - -func (r *Resources) ConsortiumsConfig() (channelconfig.Consortiums, bool) { - return r.ConsortiumsConfigVal, r.ConsortiumsConfigVal != nil -} - -// Returns the MSPManagerVal -func (r *Resources) MSPManager() msp.MSPManager { - return r.MSPManagerVal -} - -// ValidateNew returns ValidateNewErr -func (r *Resources) ValidateNew(res channelconfig.Resources) error { - return r.ValidateNewErr -} diff --git a/common/mocks/config/resources_test.go b/common/mocks/config/resources_test.go deleted file mode 100644 index f849d2eaabc..00000000000 --- a/common/mocks/config/resources_test.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright IBM Corp. 2016 All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 -*/ - -package config - -import ( - "testing" - - "github.com/hyperledger/fabric/common/channelconfig" -) - -func TestConfigtxResourcesInterface(t *testing.T) { - _ = channelconfig.Resources(&Resources{}) -} diff --git a/core/chaincode/chaincode_suite_test.go b/core/chaincode/chaincode_suite_test.go index e5f87d8dc22..caf1005b6bb 100644 --- a/core/chaincode/chaincode_suite_test.go +++ b/core/chaincode/chaincode_suite_test.go @@ -137,6 +137,11 @@ type applicationConfig interface { channelconfig.Application } +//go:generate counterfeiter -o mock/resources.go --fake-name Resources . resources +type resources interface { + channelconfig.Resources +} + //go:generate counterfeiter -o mock/policy_manager.go -fake-name PolicyManager . policyManager type policyManager interface { policies.Manager diff --git a/core/chaincode/chaincode_support_test.go b/core/chaincode/chaincode_support_test.go index 6f47560063d..ca7406a9b46 100644 --- a/core/chaincode/chaincode_support_test.go +++ b/core/chaincode/chaincode_support_test.go @@ -270,7 +270,12 @@ func initMockPeer(channelIDs ...string) (*peer.Peer, *ChaincodeSupport, func(), globalBlockNum = make(map[string]uint64, len(channelIDs)) for _, id := range channelIDs { - if err := peer.CreateMockChannel(peerInstance, id, &mock.PolicyManager{}); err != nil { + capabilities := &mock.ApplicationCapabilities{} + config := &mock.ApplicationConfig{} + config.CapabilitiesReturns(capabilities) + resources := &mock.Resources{} + resources.ApplicationConfigReturns(config, true) + if err := peer.CreateMockChannel(peerInstance, id, resources); err != nil { cleanup() return nil, nil, func() {}, err } diff --git a/core/chaincode/exectransaction_test.go b/core/chaincode/exectransaction_test.go index ee51b37d893..2372c8fcd05 100644 --- a/core/chaincode/exectransaction_test.go +++ b/core/chaincode/exectransaction_test.go @@ -623,17 +623,26 @@ func TestChaincodeInvokeChaincode(t *testing.T) { mockPolicy := &mock.Policy{} mockPolicy.EvaluateSignedDataReturns(nil) + capabilities := &mock.ApplicationCapabilities{} + config := &mock.ApplicationConfig{} + config.CapabilitiesReturns(capabilities) polMgrChannel1 := &mock.PolicyManager{} polMgrChannel1.GetPolicyReturns(mockPolicy, true) - err = peer.CreateMockChannel(chaincodeSupport.Peer, channel1, polMgrChannel1) + resources1 := &mock.Resources{} + resources1.PolicyManagerReturns(polMgrChannel1) + resources1.ApplicationConfigReturns(config, true) + err = peer.CreateMockChannel(chaincodeSupport.Peer, channel1, resources1) if err != nil { t.Fatalf("Failed to create mock channel: %s", err) } polMgrChannel2 := &mock.PolicyManager{} polMgrChannel2.GetPolicyReturns(mockPolicy, true) - err = peer.CreateMockChannel(chaincodeSupport.Peer, channel2, polMgrChannel2) + resources2 := &mock.Resources{} + resources2.PolicyManagerReturns(polMgrChannel2) + resources2.ApplicationConfigReturns(config, true) + err = peer.CreateMockChannel(chaincodeSupport.Peer, channel2, resources2) if err != nil { t.Fatalf("Failed to create mock channel: %s", err) } @@ -784,8 +793,14 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) { mockPolicy.EvaluateIdentitiesReturns(nil) mockPolicy.EvaluateSignedDataReturns(nil) polMgr.GetPolicyReturns(mockPolicy, true) + capabilities := &mock.ApplicationCapabilities{} + config := &mock.ApplicationConfig{} + config.CapabilitiesReturns(capabilities) + resources := &mock.Resources{} + resources.PolicyManagerReturns(polMgr) + resources.ApplicationConfigReturns(config, true) - peer.CreateMockChannel(chaincodeSupport.Peer, channelID, polMgr) + peer.CreateMockChannel(chaincodeSupport.Peer, channelID, resources) ml.ChaincodeEndorsementInfoStub = func(_, name string, _ ledger.SimpleQueryExecutor) (*lifecycle.ChaincodeEndorsementInfo, error) { switch name { @@ -882,7 +897,11 @@ func TestChaincodeInit(t *testing.T) { defer cleanup() - peer.CreateMockChannel(chaincodeSupport.Peer, channelID, nil) + config := &mock.ApplicationConfig{} + config.CapabilitiesReturns(&mock.ApplicationCapabilities{}) + resources := &mock.Resources{} + resources.ApplicationConfigReturns(config, true) + peer.CreateMockChannel(chaincodeSupport.Peer, channelID, resources) url := "github.com/hyperledger/fabric/core/chaincode/testdata/src/chaincodes/init_private_data" cID := &pb.ChaincodeID{Name: "init_pvtdata", Path: url, Version: "0"} @@ -938,7 +957,11 @@ func TestQueries(t *testing.T) { defer cleanup() - peer.CreateMockChannel(chaincodeSupport.Peer, channelID, nil) + config := &mock.ApplicationConfig{} + config.CapabilitiesReturns(&mock.ApplicationCapabilities{}) + resources := &mock.Resources{} + resources.ApplicationConfigReturns(config, true) + peer.CreateMockChannel(chaincodeSupport.Peer, channelID, resources) url := "github.com/hyperledger/fabric/core/chaincode/testdata/src/chaincodes/map" cID := &pb.ChaincodeID{Name: "tmap", Path: url, Version: "0"} diff --git a/core/chaincode/handler_test.go b/core/chaincode/handler_test.go index da73980ac82..22228f0939a 100644 --- a/core/chaincode/handler_test.go +++ b/core/chaincode/handler_test.go @@ -14,7 +14,7 @@ import ( pb "github.com/hyperledger/fabric-protos-go/peer" "github.com/hyperledger/fabric/common/metrics/metricsfakes" "github.com/hyperledger/fabric/common/util" - "github.com/hyperledger/fabric/core/aclmgmt/resources" + ar "github.com/hyperledger/fabric/core/aclmgmt/resources" "github.com/hyperledger/fabric/core/chaincode" "github.com/hyperledger/fabric/core/chaincode/fake" "github.com/hyperledger/fabric/core/chaincode/mock" @@ -2176,7 +2176,7 @@ var _ = Describe("Handler", func() { Expect(fakeACLProvider.CheckACLCallCount()).To(Equal(1)) resource, chainID, proposal := fakeACLProvider.CheckACLArgsForCall(0) - Expect(resource).To(Equal(resources.Peer_ChaincodeToChaincode)) + Expect(resource).To(Equal(ar.Peer_ChaincodeToChaincode)) Expect(chainID).To(Equal("channel-id")) Expect(proposal).To(Equal(expectedSignedProp)) }) @@ -2199,7 +2199,7 @@ var _ = Describe("Handler", func() { Expect(fakeACLProvider.CheckACLCallCount()).To(Equal(1)) resource, chainID, proposal := fakeACLProvider.CheckACLArgsForCall(0) - Expect(resource).To(Equal(resources.Peer_ChaincodeToChaincode)) + Expect(resource).To(Equal(ar.Peer_ChaincodeToChaincode)) Expect(chainID).To(Equal("target-channel-id")) Expect(proposal).To(Equal(expectedSignedProp)) }) diff --git a/core/chaincode/mock/resources.go b/core/chaincode/mock/resources.go new file mode 100644 index 00000000000..46526966d3c --- /dev/null +++ b/core/chaincode/mock/resources.go @@ -0,0 +1,574 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package mock + +import ( + "sync" + + "github.com/hyperledger/fabric/common/channelconfig" + "github.com/hyperledger/fabric/common/configtx" + "github.com/hyperledger/fabric/common/policies" + "github.com/hyperledger/fabric/msp" +) + +type Resources struct { + ApplicationConfigStub func() (channelconfig.Application, bool) + applicationConfigMutex sync.RWMutex + applicationConfigArgsForCall []struct { + } + applicationConfigReturns struct { + result1 channelconfig.Application + result2 bool + } + applicationConfigReturnsOnCall map[int]struct { + result1 channelconfig.Application + result2 bool + } + ChannelConfigStub func() channelconfig.Channel + channelConfigMutex sync.RWMutex + channelConfigArgsForCall []struct { + } + channelConfigReturns struct { + result1 channelconfig.Channel + } + channelConfigReturnsOnCall map[int]struct { + result1 channelconfig.Channel + } + ConfigtxValidatorStub func() configtx.Validator + configtxValidatorMutex sync.RWMutex + configtxValidatorArgsForCall []struct { + } + configtxValidatorReturns struct { + result1 configtx.Validator + } + configtxValidatorReturnsOnCall map[int]struct { + result1 configtx.Validator + } + ConsortiumsConfigStub func() (channelconfig.Consortiums, bool) + consortiumsConfigMutex sync.RWMutex + consortiumsConfigArgsForCall []struct { + } + consortiumsConfigReturns struct { + result1 channelconfig.Consortiums + result2 bool + } + consortiumsConfigReturnsOnCall map[int]struct { + result1 channelconfig.Consortiums + result2 bool + } + MSPManagerStub func() msp.MSPManager + mSPManagerMutex sync.RWMutex + mSPManagerArgsForCall []struct { + } + mSPManagerReturns struct { + result1 msp.MSPManager + } + mSPManagerReturnsOnCall map[int]struct { + result1 msp.MSPManager + } + OrdererConfigStub func() (channelconfig.Orderer, bool) + ordererConfigMutex sync.RWMutex + ordererConfigArgsForCall []struct { + } + ordererConfigReturns struct { + result1 channelconfig.Orderer + result2 bool + } + ordererConfigReturnsOnCall map[int]struct { + result1 channelconfig.Orderer + result2 bool + } + PolicyManagerStub func() policies.Manager + policyManagerMutex sync.RWMutex + policyManagerArgsForCall []struct { + } + policyManagerReturns struct { + result1 policies.Manager + } + policyManagerReturnsOnCall map[int]struct { + result1 policies.Manager + } + ValidateNewStub func(channelconfig.Resources) error + validateNewMutex sync.RWMutex + validateNewArgsForCall []struct { + arg1 channelconfig.Resources + } + validateNewReturns struct { + result1 error + } + validateNewReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *Resources) ApplicationConfig() (channelconfig.Application, bool) { + fake.applicationConfigMutex.Lock() + ret, specificReturn := fake.applicationConfigReturnsOnCall[len(fake.applicationConfigArgsForCall)] + fake.applicationConfigArgsForCall = append(fake.applicationConfigArgsForCall, struct { + }{}) + fake.recordInvocation("ApplicationConfig", []interface{}{}) + fake.applicationConfigMutex.Unlock() + if fake.ApplicationConfigStub != nil { + return fake.ApplicationConfigStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.applicationConfigReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *Resources) ApplicationConfigCallCount() int { + fake.applicationConfigMutex.RLock() + defer fake.applicationConfigMutex.RUnlock() + return len(fake.applicationConfigArgsForCall) +} + +func (fake *Resources) ApplicationConfigCalls(stub func() (channelconfig.Application, bool)) { + fake.applicationConfigMutex.Lock() + defer fake.applicationConfigMutex.Unlock() + fake.ApplicationConfigStub = stub +} + +func (fake *Resources) ApplicationConfigReturns(result1 channelconfig.Application, result2 bool) { + fake.applicationConfigMutex.Lock() + defer fake.applicationConfigMutex.Unlock() + fake.ApplicationConfigStub = nil + fake.applicationConfigReturns = struct { + result1 channelconfig.Application + result2 bool + }{result1, result2} +} + +func (fake *Resources) ApplicationConfigReturnsOnCall(i int, result1 channelconfig.Application, result2 bool) { + fake.applicationConfigMutex.Lock() + defer fake.applicationConfigMutex.Unlock() + fake.ApplicationConfigStub = nil + if fake.applicationConfigReturnsOnCall == nil { + fake.applicationConfigReturnsOnCall = make(map[int]struct { + result1 channelconfig.Application + result2 bool + }) + } + fake.applicationConfigReturnsOnCall[i] = struct { + result1 channelconfig.Application + result2 bool + }{result1, result2} +} + +func (fake *Resources) ChannelConfig() channelconfig.Channel { + fake.channelConfigMutex.Lock() + ret, specificReturn := fake.channelConfigReturnsOnCall[len(fake.channelConfigArgsForCall)] + fake.channelConfigArgsForCall = append(fake.channelConfigArgsForCall, struct { + }{}) + fake.recordInvocation("ChannelConfig", []interface{}{}) + fake.channelConfigMutex.Unlock() + if fake.ChannelConfigStub != nil { + return fake.ChannelConfigStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.channelConfigReturns + return fakeReturns.result1 +} + +func (fake *Resources) ChannelConfigCallCount() int { + fake.channelConfigMutex.RLock() + defer fake.channelConfigMutex.RUnlock() + return len(fake.channelConfigArgsForCall) +} + +func (fake *Resources) ChannelConfigCalls(stub func() channelconfig.Channel) { + fake.channelConfigMutex.Lock() + defer fake.channelConfigMutex.Unlock() + fake.ChannelConfigStub = stub +} + +func (fake *Resources) ChannelConfigReturns(result1 channelconfig.Channel) { + fake.channelConfigMutex.Lock() + defer fake.channelConfigMutex.Unlock() + fake.ChannelConfigStub = nil + fake.channelConfigReturns = struct { + result1 channelconfig.Channel + }{result1} +} + +func (fake *Resources) ChannelConfigReturnsOnCall(i int, result1 channelconfig.Channel) { + fake.channelConfigMutex.Lock() + defer fake.channelConfigMutex.Unlock() + fake.ChannelConfigStub = nil + if fake.channelConfigReturnsOnCall == nil { + fake.channelConfigReturnsOnCall = make(map[int]struct { + result1 channelconfig.Channel + }) + } + fake.channelConfigReturnsOnCall[i] = struct { + result1 channelconfig.Channel + }{result1} +} + +func (fake *Resources) ConfigtxValidator() configtx.Validator { + fake.configtxValidatorMutex.Lock() + ret, specificReturn := fake.configtxValidatorReturnsOnCall[len(fake.configtxValidatorArgsForCall)] + fake.configtxValidatorArgsForCall = append(fake.configtxValidatorArgsForCall, struct { + }{}) + fake.recordInvocation("ConfigtxValidator", []interface{}{}) + fake.configtxValidatorMutex.Unlock() + if fake.ConfigtxValidatorStub != nil { + return fake.ConfigtxValidatorStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.configtxValidatorReturns + return fakeReturns.result1 +} + +func (fake *Resources) ConfigtxValidatorCallCount() int { + fake.configtxValidatorMutex.RLock() + defer fake.configtxValidatorMutex.RUnlock() + return len(fake.configtxValidatorArgsForCall) +} + +func (fake *Resources) ConfigtxValidatorCalls(stub func() configtx.Validator) { + fake.configtxValidatorMutex.Lock() + defer fake.configtxValidatorMutex.Unlock() + fake.ConfigtxValidatorStub = stub +} + +func (fake *Resources) ConfigtxValidatorReturns(result1 configtx.Validator) { + fake.configtxValidatorMutex.Lock() + defer fake.configtxValidatorMutex.Unlock() + fake.ConfigtxValidatorStub = nil + fake.configtxValidatorReturns = struct { + result1 configtx.Validator + }{result1} +} + +func (fake *Resources) ConfigtxValidatorReturnsOnCall(i int, result1 configtx.Validator) { + fake.configtxValidatorMutex.Lock() + defer fake.configtxValidatorMutex.Unlock() + fake.ConfigtxValidatorStub = nil + if fake.configtxValidatorReturnsOnCall == nil { + fake.configtxValidatorReturnsOnCall = make(map[int]struct { + result1 configtx.Validator + }) + } + fake.configtxValidatorReturnsOnCall[i] = struct { + result1 configtx.Validator + }{result1} +} + +func (fake *Resources) ConsortiumsConfig() (channelconfig.Consortiums, bool) { + fake.consortiumsConfigMutex.Lock() + ret, specificReturn := fake.consortiumsConfigReturnsOnCall[len(fake.consortiumsConfigArgsForCall)] + fake.consortiumsConfigArgsForCall = append(fake.consortiumsConfigArgsForCall, struct { + }{}) + fake.recordInvocation("ConsortiumsConfig", []interface{}{}) + fake.consortiumsConfigMutex.Unlock() + if fake.ConsortiumsConfigStub != nil { + return fake.ConsortiumsConfigStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.consortiumsConfigReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *Resources) ConsortiumsConfigCallCount() int { + fake.consortiumsConfigMutex.RLock() + defer fake.consortiumsConfigMutex.RUnlock() + return len(fake.consortiumsConfigArgsForCall) +} + +func (fake *Resources) ConsortiumsConfigCalls(stub func() (channelconfig.Consortiums, bool)) { + fake.consortiumsConfigMutex.Lock() + defer fake.consortiumsConfigMutex.Unlock() + fake.ConsortiumsConfigStub = stub +} + +func (fake *Resources) ConsortiumsConfigReturns(result1 channelconfig.Consortiums, result2 bool) { + fake.consortiumsConfigMutex.Lock() + defer fake.consortiumsConfigMutex.Unlock() + fake.ConsortiumsConfigStub = nil + fake.consortiumsConfigReturns = struct { + result1 channelconfig.Consortiums + result2 bool + }{result1, result2} +} + +func (fake *Resources) ConsortiumsConfigReturnsOnCall(i int, result1 channelconfig.Consortiums, result2 bool) { + fake.consortiumsConfigMutex.Lock() + defer fake.consortiumsConfigMutex.Unlock() + fake.ConsortiumsConfigStub = nil + if fake.consortiumsConfigReturnsOnCall == nil { + fake.consortiumsConfigReturnsOnCall = make(map[int]struct { + result1 channelconfig.Consortiums + result2 bool + }) + } + fake.consortiumsConfigReturnsOnCall[i] = struct { + result1 channelconfig.Consortiums + result2 bool + }{result1, result2} +} + +func (fake *Resources) MSPManager() msp.MSPManager { + fake.mSPManagerMutex.Lock() + ret, specificReturn := fake.mSPManagerReturnsOnCall[len(fake.mSPManagerArgsForCall)] + fake.mSPManagerArgsForCall = append(fake.mSPManagerArgsForCall, struct { + }{}) + fake.recordInvocation("MSPManager", []interface{}{}) + fake.mSPManagerMutex.Unlock() + if fake.MSPManagerStub != nil { + return fake.MSPManagerStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.mSPManagerReturns + return fakeReturns.result1 +} + +func (fake *Resources) MSPManagerCallCount() int { + fake.mSPManagerMutex.RLock() + defer fake.mSPManagerMutex.RUnlock() + return len(fake.mSPManagerArgsForCall) +} + +func (fake *Resources) MSPManagerCalls(stub func() msp.MSPManager) { + fake.mSPManagerMutex.Lock() + defer fake.mSPManagerMutex.Unlock() + fake.MSPManagerStub = stub +} + +func (fake *Resources) MSPManagerReturns(result1 msp.MSPManager) { + fake.mSPManagerMutex.Lock() + defer fake.mSPManagerMutex.Unlock() + fake.MSPManagerStub = nil + fake.mSPManagerReturns = struct { + result1 msp.MSPManager + }{result1} +} + +func (fake *Resources) MSPManagerReturnsOnCall(i int, result1 msp.MSPManager) { + fake.mSPManagerMutex.Lock() + defer fake.mSPManagerMutex.Unlock() + fake.MSPManagerStub = nil + if fake.mSPManagerReturnsOnCall == nil { + fake.mSPManagerReturnsOnCall = make(map[int]struct { + result1 msp.MSPManager + }) + } + fake.mSPManagerReturnsOnCall[i] = struct { + result1 msp.MSPManager + }{result1} +} + +func (fake *Resources) OrdererConfig() (channelconfig.Orderer, bool) { + fake.ordererConfigMutex.Lock() + ret, specificReturn := fake.ordererConfigReturnsOnCall[len(fake.ordererConfigArgsForCall)] + fake.ordererConfigArgsForCall = append(fake.ordererConfigArgsForCall, struct { + }{}) + fake.recordInvocation("OrdererConfig", []interface{}{}) + fake.ordererConfigMutex.Unlock() + if fake.OrdererConfigStub != nil { + return fake.OrdererConfigStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.ordererConfigReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *Resources) OrdererConfigCallCount() int { + fake.ordererConfigMutex.RLock() + defer fake.ordererConfigMutex.RUnlock() + return len(fake.ordererConfigArgsForCall) +} + +func (fake *Resources) OrdererConfigCalls(stub func() (channelconfig.Orderer, bool)) { + fake.ordererConfigMutex.Lock() + defer fake.ordererConfigMutex.Unlock() + fake.OrdererConfigStub = stub +} + +func (fake *Resources) OrdererConfigReturns(result1 channelconfig.Orderer, result2 bool) { + fake.ordererConfigMutex.Lock() + defer fake.ordererConfigMutex.Unlock() + fake.OrdererConfigStub = nil + fake.ordererConfigReturns = struct { + result1 channelconfig.Orderer + result2 bool + }{result1, result2} +} + +func (fake *Resources) OrdererConfigReturnsOnCall(i int, result1 channelconfig.Orderer, result2 bool) { + fake.ordererConfigMutex.Lock() + defer fake.ordererConfigMutex.Unlock() + fake.OrdererConfigStub = nil + if fake.ordererConfigReturnsOnCall == nil { + fake.ordererConfigReturnsOnCall = make(map[int]struct { + result1 channelconfig.Orderer + result2 bool + }) + } + fake.ordererConfigReturnsOnCall[i] = struct { + result1 channelconfig.Orderer + result2 bool + }{result1, result2} +} + +func (fake *Resources) PolicyManager() policies.Manager { + fake.policyManagerMutex.Lock() + ret, specificReturn := fake.policyManagerReturnsOnCall[len(fake.policyManagerArgsForCall)] + fake.policyManagerArgsForCall = append(fake.policyManagerArgsForCall, struct { + }{}) + fake.recordInvocation("PolicyManager", []interface{}{}) + fake.policyManagerMutex.Unlock() + if fake.PolicyManagerStub != nil { + return fake.PolicyManagerStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.policyManagerReturns + return fakeReturns.result1 +} + +func (fake *Resources) PolicyManagerCallCount() int { + fake.policyManagerMutex.RLock() + defer fake.policyManagerMutex.RUnlock() + return len(fake.policyManagerArgsForCall) +} + +func (fake *Resources) PolicyManagerCalls(stub func() policies.Manager) { + fake.policyManagerMutex.Lock() + defer fake.policyManagerMutex.Unlock() + fake.PolicyManagerStub = stub +} + +func (fake *Resources) PolicyManagerReturns(result1 policies.Manager) { + fake.policyManagerMutex.Lock() + defer fake.policyManagerMutex.Unlock() + fake.PolicyManagerStub = nil + fake.policyManagerReturns = struct { + result1 policies.Manager + }{result1} +} + +func (fake *Resources) PolicyManagerReturnsOnCall(i int, result1 policies.Manager) { + fake.policyManagerMutex.Lock() + defer fake.policyManagerMutex.Unlock() + fake.PolicyManagerStub = nil + if fake.policyManagerReturnsOnCall == nil { + fake.policyManagerReturnsOnCall = make(map[int]struct { + result1 policies.Manager + }) + } + fake.policyManagerReturnsOnCall[i] = struct { + result1 policies.Manager + }{result1} +} + +func (fake *Resources) ValidateNew(arg1 channelconfig.Resources) error { + fake.validateNewMutex.Lock() + ret, specificReturn := fake.validateNewReturnsOnCall[len(fake.validateNewArgsForCall)] + fake.validateNewArgsForCall = append(fake.validateNewArgsForCall, struct { + arg1 channelconfig.Resources + }{arg1}) + fake.recordInvocation("ValidateNew", []interface{}{arg1}) + fake.validateNewMutex.Unlock() + if fake.ValidateNewStub != nil { + return fake.ValidateNewStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.validateNewReturns + return fakeReturns.result1 +} + +func (fake *Resources) ValidateNewCallCount() int { + fake.validateNewMutex.RLock() + defer fake.validateNewMutex.RUnlock() + return len(fake.validateNewArgsForCall) +} + +func (fake *Resources) ValidateNewCalls(stub func(channelconfig.Resources) error) { + fake.validateNewMutex.Lock() + defer fake.validateNewMutex.Unlock() + fake.ValidateNewStub = stub +} + +func (fake *Resources) ValidateNewArgsForCall(i int) channelconfig.Resources { + fake.validateNewMutex.RLock() + defer fake.validateNewMutex.RUnlock() + argsForCall := fake.validateNewArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *Resources) ValidateNewReturns(result1 error) { + fake.validateNewMutex.Lock() + defer fake.validateNewMutex.Unlock() + fake.ValidateNewStub = nil + fake.validateNewReturns = struct { + result1 error + }{result1} +} + +func (fake *Resources) ValidateNewReturnsOnCall(i int, result1 error) { + fake.validateNewMutex.Lock() + defer fake.validateNewMutex.Unlock() + fake.ValidateNewStub = nil + if fake.validateNewReturnsOnCall == nil { + fake.validateNewReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.validateNewReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *Resources) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.applicationConfigMutex.RLock() + defer fake.applicationConfigMutex.RUnlock() + fake.channelConfigMutex.RLock() + defer fake.channelConfigMutex.RUnlock() + fake.configtxValidatorMutex.RLock() + defer fake.configtxValidatorMutex.RUnlock() + fake.consortiumsConfigMutex.RLock() + defer fake.consortiumsConfigMutex.RUnlock() + fake.mSPManagerMutex.RLock() + defer fake.mSPManagerMutex.RUnlock() + fake.ordererConfigMutex.RLock() + defer fake.ordererConfigMutex.RUnlock() + fake.policyManagerMutex.RLock() + defer fake.policyManagerMutex.RUnlock() + fake.validateNewMutex.RLock() + defer fake.validateNewMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *Resources) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} diff --git a/core/peer/mock_helpers.go b/core/peer/mock_helpers.go index dcb3134e200..01463a18bba 100644 --- a/core/peer/mock_helpers.go +++ b/core/peer/mock_helpers.go @@ -8,14 +8,12 @@ package peer import ( "github.com/hyperledger/fabric/bccsp/sw" + "github.com/hyperledger/fabric/common/channelconfig" configtxtest "github.com/hyperledger/fabric/common/configtx/test" - mockchannelconfig "github.com/hyperledger/fabric/common/mocks/config" - mockconfigtx "github.com/hyperledger/fabric/common/mocks/configtx" - "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/core/ledger" ) -func CreateMockChannel(p *Peer, cid string, policyMgr policies.Manager) error { +func CreateMockChannel(p *Peer, cid string, resources channelconfig.Resources) error { var ledger ledger.PeerLedger var err error @@ -39,12 +37,8 @@ func CreateMockChannel(p *Peer, cid string, policyMgr policies.Manager) error { } p.channels[cid] = &Channel{ - ledger: ledger, - resources: &mockchannelconfig.Resources{ - PolicyManagerVal: policyMgr, - ConfigtxValidatorVal: &mockconfigtx.Validator{}, - ApplicationConfigVal: &mockchannelconfig.MockApplication{CapabilitiesRv: &mockchannelconfig.MockApplicationCapabilities{}}, - }, + ledger: ledger, + resources: resources, cryptoProvider: cryptoProvider, } diff --git a/core/scc/lscc/lscc_test.go b/core/scc/lscc/lscc_test.go index 2d4c494d6c6..5704c0c8c18 100644 --- a/core/scc/lscc/lscc_test.go +++ b/core/scc/lscc/lscc_test.go @@ -26,7 +26,7 @@ import ( pb "github.com/hyperledger/fabric-protos-go/peer" "github.com/hyperledger/fabric/bccsp/sw" "github.com/hyperledger/fabric/common/cauthdsl" - "github.com/hyperledger/fabric/common/mocks/config" + "github.com/hyperledger/fabric/common/channelconfig" mscc "github.com/hyperledger/fabric/common/mocks/scc" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/common/util" @@ -51,6 +51,18 @@ import ( "github.com/stretchr/testify/require" ) +//go:generate counterfeiter -o mock/application.go -fake-name Application . application + +type application interface { + channelconfig.Application +} + +//go:generate counterfeiter -o mock/application_capabilities.go -fake-name ApplicationCapabilities . applicationCapabilities + +type applicationCapabilities interface { + channelconfig.ApplicationCapabilities +} + // create a valid SignaturePolicyEnvelope to be used in tests var testPolicyEnvelope = &common.SignaturePolicyEnvelope{ Version: 0, @@ -262,13 +274,13 @@ func testInstall(t *testing.T, ccname string, version string, path string, creat func TestNewLifecycleEnabled(t *testing.T) { // Enable PrivateChannelData + capabilities := &mock.ApplicationCapabilities{} + capabilities.LifecycleV20Returns(true) + application := &mock.Application{} + application.CapabilitiesReturns(capabilities) mocksccProvider := (&mscc.MocksccProviderFactory{ ApplicationConfigBool: true, - ApplicationConfigRv: &config.MockApplication{ - CapabilitiesRv: &config.MockApplicationCapabilities{ - LifecycleV20Rv: true, - }, - }, + ApplicationConfigRv: application, }).NewSystemChaincodeProvider().(*mscc.MocksccProviderImpl) cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore()) @@ -387,13 +399,13 @@ func TestDeploy(t *testing.T) { testDeploy(t, "example02", "1.0", path, false, false, true, PrivateChannelDataNotAvailable("").Error(), scc, stub, []byte("collections")) // Enable PrivateChannelData + capabilities := &mock.ApplicationCapabilities{} + capabilities.PrivateChannelDataReturns(true) + application := &mock.Application{} + application.CapabilitiesReturns(capabilities) mocksccProvider := (&mscc.MocksccProviderFactory{ ApplicationConfigBool: true, - ApplicationConfigRv: &config.MockApplication{ - CapabilitiesRv: &config.MockApplicationCapabilities{ - PrivateChannelDataRv: true, - }, - }, + ApplicationConfigRv: application, }).NewSystemChaincodeProvider().(*mscc.MocksccProviderImpl) scc = &SCC{ @@ -702,13 +714,13 @@ func TestUpgrade(t *testing.T) { testUpgrade(t, "example02", "0", "example02", "1", path, "barf", scc, stub, nil) // Enable PrivateChannelData + capabilities := &mock.ApplicationCapabilities{} + capabilities.PrivateChannelDataReturns(true) + application := &mock.Application{} + application.CapabilitiesReturns(capabilities) mocksccProvider := (&mscc.MocksccProviderFactory{ ApplicationConfigBool: true, - ApplicationConfigRv: &config.MockApplication{ - CapabilitiesRv: &config.MockApplicationCapabilities{ - PrivateChannelDataRv: true, - }, - }, + ApplicationConfigRv: application, }).NewSystemChaincodeProvider().(*mscc.MocksccProviderImpl) scc = &SCC{ @@ -742,14 +754,14 @@ func TestUpgrade(t *testing.T) { testUpgrade(t, "example02", "0", "example02", "1", path, expectedErrorMsg, scc, stub, ccpBytes) // Enable PrivateChannelData and V1_2Validation + capabilities = &mock.ApplicationCapabilities{} + capabilities.CollectionUpgradeReturns(true) + capabilities.PrivateChannelDataReturns(true) + application = &mock.Application{} + application.CapabilitiesReturns(capabilities) mocksccProvider = (&mscc.MocksccProviderFactory{ ApplicationConfigBool: true, - ApplicationConfigRv: &config.MockApplication{ - CapabilitiesRv: &config.MockApplicationCapabilities{ - PrivateChannelDataRv: true, - CollectionUpgradeRv: true, - }, - }, + ApplicationConfigRv: application, }).NewSystemChaincodeProvider().(*mscc.MocksccProviderImpl) scc = &SCC{ @@ -1503,11 +1515,12 @@ var channelID = "testchannelid" var mockAclProvider *mocks.MockACLProvider func NewMockProvider() *mscc.MocksccProviderImpl { + capabilities := &mock.ApplicationCapabilities{} + application := &mock.Application{} + application.CapabilitiesReturns(capabilities) return (&mscc.MocksccProviderFactory{ ApplicationConfigBool: true, - ApplicationConfigRv: &config.MockApplication{ - CapabilitiesRv: &config.MockApplicationCapabilities{}, - }, + ApplicationConfigRv: application, }).NewSystemChaincodeProvider().(*mscc.MocksccProviderImpl) } diff --git a/core/scc/lscc/mock/application.go b/core/scc/lscc/mock/application.go new file mode 100644 index 00000000000..d0e09234b50 --- /dev/null +++ b/core/scc/lscc/mock/application.go @@ -0,0 +1,227 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package mock + +import ( + "sync" + + "github.com/hyperledger/fabric/common/channelconfig" +) + +type Application struct { + APIPolicyMapperStub func() channelconfig.PolicyMapper + aPIPolicyMapperMutex sync.RWMutex + aPIPolicyMapperArgsForCall []struct { + } + aPIPolicyMapperReturns struct { + result1 channelconfig.PolicyMapper + } + aPIPolicyMapperReturnsOnCall map[int]struct { + result1 channelconfig.PolicyMapper + } + CapabilitiesStub func() channelconfig.ApplicationCapabilities + capabilitiesMutex sync.RWMutex + capabilitiesArgsForCall []struct { + } + capabilitiesReturns struct { + result1 channelconfig.ApplicationCapabilities + } + capabilitiesReturnsOnCall map[int]struct { + result1 channelconfig.ApplicationCapabilities + } + OrganizationsStub func() map[string]channelconfig.ApplicationOrg + organizationsMutex sync.RWMutex + organizationsArgsForCall []struct { + } + organizationsReturns struct { + result1 map[string]channelconfig.ApplicationOrg + } + organizationsReturnsOnCall map[int]struct { + result1 map[string]channelconfig.ApplicationOrg + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *Application) APIPolicyMapper() channelconfig.PolicyMapper { + fake.aPIPolicyMapperMutex.Lock() + ret, specificReturn := fake.aPIPolicyMapperReturnsOnCall[len(fake.aPIPolicyMapperArgsForCall)] + fake.aPIPolicyMapperArgsForCall = append(fake.aPIPolicyMapperArgsForCall, struct { + }{}) + fake.recordInvocation("APIPolicyMapper", []interface{}{}) + fake.aPIPolicyMapperMutex.Unlock() + if fake.APIPolicyMapperStub != nil { + return fake.APIPolicyMapperStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.aPIPolicyMapperReturns + return fakeReturns.result1 +} + +func (fake *Application) APIPolicyMapperCallCount() int { + fake.aPIPolicyMapperMutex.RLock() + defer fake.aPIPolicyMapperMutex.RUnlock() + return len(fake.aPIPolicyMapperArgsForCall) +} + +func (fake *Application) APIPolicyMapperCalls(stub func() channelconfig.PolicyMapper) { + fake.aPIPolicyMapperMutex.Lock() + defer fake.aPIPolicyMapperMutex.Unlock() + fake.APIPolicyMapperStub = stub +} + +func (fake *Application) APIPolicyMapperReturns(result1 channelconfig.PolicyMapper) { + fake.aPIPolicyMapperMutex.Lock() + defer fake.aPIPolicyMapperMutex.Unlock() + fake.APIPolicyMapperStub = nil + fake.aPIPolicyMapperReturns = struct { + result1 channelconfig.PolicyMapper + }{result1} +} + +func (fake *Application) APIPolicyMapperReturnsOnCall(i int, result1 channelconfig.PolicyMapper) { + fake.aPIPolicyMapperMutex.Lock() + defer fake.aPIPolicyMapperMutex.Unlock() + fake.APIPolicyMapperStub = nil + if fake.aPIPolicyMapperReturnsOnCall == nil { + fake.aPIPolicyMapperReturnsOnCall = make(map[int]struct { + result1 channelconfig.PolicyMapper + }) + } + fake.aPIPolicyMapperReturnsOnCall[i] = struct { + result1 channelconfig.PolicyMapper + }{result1} +} + +func (fake *Application) Capabilities() channelconfig.ApplicationCapabilities { + fake.capabilitiesMutex.Lock() + ret, specificReturn := fake.capabilitiesReturnsOnCall[len(fake.capabilitiesArgsForCall)] + fake.capabilitiesArgsForCall = append(fake.capabilitiesArgsForCall, struct { + }{}) + fake.recordInvocation("Capabilities", []interface{}{}) + fake.capabilitiesMutex.Unlock() + if fake.CapabilitiesStub != nil { + return fake.CapabilitiesStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.capabilitiesReturns + return fakeReturns.result1 +} + +func (fake *Application) CapabilitiesCallCount() int { + fake.capabilitiesMutex.RLock() + defer fake.capabilitiesMutex.RUnlock() + return len(fake.capabilitiesArgsForCall) +} + +func (fake *Application) CapabilitiesCalls(stub func() channelconfig.ApplicationCapabilities) { + fake.capabilitiesMutex.Lock() + defer fake.capabilitiesMutex.Unlock() + fake.CapabilitiesStub = stub +} + +func (fake *Application) CapabilitiesReturns(result1 channelconfig.ApplicationCapabilities) { + fake.capabilitiesMutex.Lock() + defer fake.capabilitiesMutex.Unlock() + fake.CapabilitiesStub = nil + fake.capabilitiesReturns = struct { + result1 channelconfig.ApplicationCapabilities + }{result1} +} + +func (fake *Application) CapabilitiesReturnsOnCall(i int, result1 channelconfig.ApplicationCapabilities) { + fake.capabilitiesMutex.Lock() + defer fake.capabilitiesMutex.Unlock() + fake.CapabilitiesStub = nil + if fake.capabilitiesReturnsOnCall == nil { + fake.capabilitiesReturnsOnCall = make(map[int]struct { + result1 channelconfig.ApplicationCapabilities + }) + } + fake.capabilitiesReturnsOnCall[i] = struct { + result1 channelconfig.ApplicationCapabilities + }{result1} +} + +func (fake *Application) Organizations() map[string]channelconfig.ApplicationOrg { + fake.organizationsMutex.Lock() + ret, specificReturn := fake.organizationsReturnsOnCall[len(fake.organizationsArgsForCall)] + fake.organizationsArgsForCall = append(fake.organizationsArgsForCall, struct { + }{}) + fake.recordInvocation("Organizations", []interface{}{}) + fake.organizationsMutex.Unlock() + if fake.OrganizationsStub != nil { + return fake.OrganizationsStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.organizationsReturns + return fakeReturns.result1 +} + +func (fake *Application) OrganizationsCallCount() int { + fake.organizationsMutex.RLock() + defer fake.organizationsMutex.RUnlock() + return len(fake.organizationsArgsForCall) +} + +func (fake *Application) OrganizationsCalls(stub func() map[string]channelconfig.ApplicationOrg) { + fake.organizationsMutex.Lock() + defer fake.organizationsMutex.Unlock() + fake.OrganizationsStub = stub +} + +func (fake *Application) OrganizationsReturns(result1 map[string]channelconfig.ApplicationOrg) { + fake.organizationsMutex.Lock() + defer fake.organizationsMutex.Unlock() + fake.OrganizationsStub = nil + fake.organizationsReturns = struct { + result1 map[string]channelconfig.ApplicationOrg + }{result1} +} + +func (fake *Application) OrganizationsReturnsOnCall(i int, result1 map[string]channelconfig.ApplicationOrg) { + fake.organizationsMutex.Lock() + defer fake.organizationsMutex.Unlock() + fake.OrganizationsStub = nil + if fake.organizationsReturnsOnCall == nil { + fake.organizationsReturnsOnCall = make(map[int]struct { + result1 map[string]channelconfig.ApplicationOrg + }) + } + fake.organizationsReturnsOnCall[i] = struct { + result1 map[string]channelconfig.ApplicationOrg + }{result1} +} + +func (fake *Application) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.aPIPolicyMapperMutex.RLock() + defer fake.aPIPolicyMapperMutex.RUnlock() + fake.capabilitiesMutex.RLock() + defer fake.capabilitiesMutex.RUnlock() + fake.organizationsMutex.RLock() + defer fake.organizationsMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *Application) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} diff --git a/core/scc/lscc/mock/application_capabilities.go b/core/scc/lscc/mock/application_capabilities.go new file mode 100644 index 00000000000..2ccdd6dfd83 --- /dev/null +++ b/core/scc/lscc/mock/application_capabilities.go @@ -0,0 +1,865 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package mock + +import ( + "sync" +) + +type ApplicationCapabilities struct { + ACLsStub func() bool + aCLsMutex sync.RWMutex + aCLsArgsForCall []struct { + } + aCLsReturns struct { + result1 bool + } + aCLsReturnsOnCall map[int]struct { + result1 bool + } + CollectionUpgradeStub func() bool + collectionUpgradeMutex sync.RWMutex + collectionUpgradeArgsForCall []struct { + } + collectionUpgradeReturns struct { + result1 bool + } + collectionUpgradeReturnsOnCall map[int]struct { + result1 bool + } + ForbidDuplicateTXIdInBlockStub func() bool + forbidDuplicateTXIdInBlockMutex sync.RWMutex + forbidDuplicateTXIdInBlockArgsForCall []struct { + } + forbidDuplicateTXIdInBlockReturns struct { + result1 bool + } + forbidDuplicateTXIdInBlockReturnsOnCall map[int]struct { + result1 bool + } + KeyLevelEndorsementStub func() bool + keyLevelEndorsementMutex sync.RWMutex + keyLevelEndorsementArgsForCall []struct { + } + keyLevelEndorsementReturns struct { + result1 bool + } + keyLevelEndorsementReturnsOnCall map[int]struct { + result1 bool + } + LifecycleV20Stub func() bool + lifecycleV20Mutex sync.RWMutex + lifecycleV20ArgsForCall []struct { + } + lifecycleV20Returns struct { + result1 bool + } + lifecycleV20ReturnsOnCall map[int]struct { + result1 bool + } + MetadataLifecycleStub func() bool + metadataLifecycleMutex sync.RWMutex + metadataLifecycleArgsForCall []struct { + } + metadataLifecycleReturns struct { + result1 bool + } + metadataLifecycleReturnsOnCall map[int]struct { + result1 bool + } + PrivateChannelDataStub func() bool + privateChannelDataMutex sync.RWMutex + privateChannelDataArgsForCall []struct { + } + privateChannelDataReturns struct { + result1 bool + } + privateChannelDataReturnsOnCall map[int]struct { + result1 bool + } + StorePvtDataOfInvalidTxStub func() bool + storePvtDataOfInvalidTxMutex sync.RWMutex + storePvtDataOfInvalidTxArgsForCall []struct { + } + storePvtDataOfInvalidTxReturns struct { + result1 bool + } + storePvtDataOfInvalidTxReturnsOnCall map[int]struct { + result1 bool + } + SupportedStub func() error + supportedMutex sync.RWMutex + supportedArgsForCall []struct { + } + supportedReturns struct { + result1 error + } + supportedReturnsOnCall map[int]struct { + result1 error + } + V1_1ValidationStub func() bool + v1_1ValidationMutex sync.RWMutex + v1_1ValidationArgsForCall []struct { + } + v1_1ValidationReturns struct { + result1 bool + } + v1_1ValidationReturnsOnCall map[int]struct { + result1 bool + } + V1_2ValidationStub func() bool + v1_2ValidationMutex sync.RWMutex + v1_2ValidationArgsForCall []struct { + } + v1_2ValidationReturns struct { + result1 bool + } + v1_2ValidationReturnsOnCall map[int]struct { + result1 bool + } + V1_3ValidationStub func() bool + v1_3ValidationMutex sync.RWMutex + v1_3ValidationArgsForCall []struct { + } + v1_3ValidationReturns struct { + result1 bool + } + v1_3ValidationReturnsOnCall map[int]struct { + result1 bool + } + V2_0ValidationStub func() bool + v2_0ValidationMutex sync.RWMutex + v2_0ValidationArgsForCall []struct { + } + v2_0ValidationReturns struct { + result1 bool + } + v2_0ValidationReturnsOnCall map[int]struct { + result1 bool + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *ApplicationCapabilities) ACLs() bool { + fake.aCLsMutex.Lock() + ret, specificReturn := fake.aCLsReturnsOnCall[len(fake.aCLsArgsForCall)] + fake.aCLsArgsForCall = append(fake.aCLsArgsForCall, struct { + }{}) + fake.recordInvocation("ACLs", []interface{}{}) + fake.aCLsMutex.Unlock() + if fake.ACLsStub != nil { + return fake.ACLsStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.aCLsReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) ACLsCallCount() int { + fake.aCLsMutex.RLock() + defer fake.aCLsMutex.RUnlock() + return len(fake.aCLsArgsForCall) +} + +func (fake *ApplicationCapabilities) ACLsCalls(stub func() bool) { + fake.aCLsMutex.Lock() + defer fake.aCLsMutex.Unlock() + fake.ACLsStub = stub +} + +func (fake *ApplicationCapabilities) ACLsReturns(result1 bool) { + fake.aCLsMutex.Lock() + defer fake.aCLsMutex.Unlock() + fake.ACLsStub = nil + fake.aCLsReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) ACLsReturnsOnCall(i int, result1 bool) { + fake.aCLsMutex.Lock() + defer fake.aCLsMutex.Unlock() + fake.ACLsStub = nil + if fake.aCLsReturnsOnCall == nil { + fake.aCLsReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.aCLsReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) CollectionUpgrade() bool { + fake.collectionUpgradeMutex.Lock() + ret, specificReturn := fake.collectionUpgradeReturnsOnCall[len(fake.collectionUpgradeArgsForCall)] + fake.collectionUpgradeArgsForCall = append(fake.collectionUpgradeArgsForCall, struct { + }{}) + fake.recordInvocation("CollectionUpgrade", []interface{}{}) + fake.collectionUpgradeMutex.Unlock() + if fake.CollectionUpgradeStub != nil { + return fake.CollectionUpgradeStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.collectionUpgradeReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) CollectionUpgradeCallCount() int { + fake.collectionUpgradeMutex.RLock() + defer fake.collectionUpgradeMutex.RUnlock() + return len(fake.collectionUpgradeArgsForCall) +} + +func (fake *ApplicationCapabilities) CollectionUpgradeCalls(stub func() bool) { + fake.collectionUpgradeMutex.Lock() + defer fake.collectionUpgradeMutex.Unlock() + fake.CollectionUpgradeStub = stub +} + +func (fake *ApplicationCapabilities) CollectionUpgradeReturns(result1 bool) { + fake.collectionUpgradeMutex.Lock() + defer fake.collectionUpgradeMutex.Unlock() + fake.CollectionUpgradeStub = nil + fake.collectionUpgradeReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) CollectionUpgradeReturnsOnCall(i int, result1 bool) { + fake.collectionUpgradeMutex.Lock() + defer fake.collectionUpgradeMutex.Unlock() + fake.CollectionUpgradeStub = nil + if fake.collectionUpgradeReturnsOnCall == nil { + fake.collectionUpgradeReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.collectionUpgradeReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) ForbidDuplicateTXIdInBlock() bool { + fake.forbidDuplicateTXIdInBlockMutex.Lock() + ret, specificReturn := fake.forbidDuplicateTXIdInBlockReturnsOnCall[len(fake.forbidDuplicateTXIdInBlockArgsForCall)] + fake.forbidDuplicateTXIdInBlockArgsForCall = append(fake.forbidDuplicateTXIdInBlockArgsForCall, struct { + }{}) + fake.recordInvocation("ForbidDuplicateTXIdInBlock", []interface{}{}) + fake.forbidDuplicateTXIdInBlockMutex.Unlock() + if fake.ForbidDuplicateTXIdInBlockStub != nil { + return fake.ForbidDuplicateTXIdInBlockStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.forbidDuplicateTXIdInBlockReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) ForbidDuplicateTXIdInBlockCallCount() int { + fake.forbidDuplicateTXIdInBlockMutex.RLock() + defer fake.forbidDuplicateTXIdInBlockMutex.RUnlock() + return len(fake.forbidDuplicateTXIdInBlockArgsForCall) +} + +func (fake *ApplicationCapabilities) ForbidDuplicateTXIdInBlockCalls(stub func() bool) { + fake.forbidDuplicateTXIdInBlockMutex.Lock() + defer fake.forbidDuplicateTXIdInBlockMutex.Unlock() + fake.ForbidDuplicateTXIdInBlockStub = stub +} + +func (fake *ApplicationCapabilities) ForbidDuplicateTXIdInBlockReturns(result1 bool) { + fake.forbidDuplicateTXIdInBlockMutex.Lock() + defer fake.forbidDuplicateTXIdInBlockMutex.Unlock() + fake.ForbidDuplicateTXIdInBlockStub = nil + fake.forbidDuplicateTXIdInBlockReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) ForbidDuplicateTXIdInBlockReturnsOnCall(i int, result1 bool) { + fake.forbidDuplicateTXIdInBlockMutex.Lock() + defer fake.forbidDuplicateTXIdInBlockMutex.Unlock() + fake.ForbidDuplicateTXIdInBlockStub = nil + if fake.forbidDuplicateTXIdInBlockReturnsOnCall == nil { + fake.forbidDuplicateTXIdInBlockReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.forbidDuplicateTXIdInBlockReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) KeyLevelEndorsement() bool { + fake.keyLevelEndorsementMutex.Lock() + ret, specificReturn := fake.keyLevelEndorsementReturnsOnCall[len(fake.keyLevelEndorsementArgsForCall)] + fake.keyLevelEndorsementArgsForCall = append(fake.keyLevelEndorsementArgsForCall, struct { + }{}) + fake.recordInvocation("KeyLevelEndorsement", []interface{}{}) + fake.keyLevelEndorsementMutex.Unlock() + if fake.KeyLevelEndorsementStub != nil { + return fake.KeyLevelEndorsementStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.keyLevelEndorsementReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) KeyLevelEndorsementCallCount() int { + fake.keyLevelEndorsementMutex.RLock() + defer fake.keyLevelEndorsementMutex.RUnlock() + return len(fake.keyLevelEndorsementArgsForCall) +} + +func (fake *ApplicationCapabilities) KeyLevelEndorsementCalls(stub func() bool) { + fake.keyLevelEndorsementMutex.Lock() + defer fake.keyLevelEndorsementMutex.Unlock() + fake.KeyLevelEndorsementStub = stub +} + +func (fake *ApplicationCapabilities) KeyLevelEndorsementReturns(result1 bool) { + fake.keyLevelEndorsementMutex.Lock() + defer fake.keyLevelEndorsementMutex.Unlock() + fake.KeyLevelEndorsementStub = nil + fake.keyLevelEndorsementReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) KeyLevelEndorsementReturnsOnCall(i int, result1 bool) { + fake.keyLevelEndorsementMutex.Lock() + defer fake.keyLevelEndorsementMutex.Unlock() + fake.KeyLevelEndorsementStub = nil + if fake.keyLevelEndorsementReturnsOnCall == nil { + fake.keyLevelEndorsementReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.keyLevelEndorsementReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) LifecycleV20() bool { + fake.lifecycleV20Mutex.Lock() + ret, specificReturn := fake.lifecycleV20ReturnsOnCall[len(fake.lifecycleV20ArgsForCall)] + fake.lifecycleV20ArgsForCall = append(fake.lifecycleV20ArgsForCall, struct { + }{}) + fake.recordInvocation("LifecycleV20", []interface{}{}) + fake.lifecycleV20Mutex.Unlock() + if fake.LifecycleV20Stub != nil { + return fake.LifecycleV20Stub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.lifecycleV20Returns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) LifecycleV20CallCount() int { + fake.lifecycleV20Mutex.RLock() + defer fake.lifecycleV20Mutex.RUnlock() + return len(fake.lifecycleV20ArgsForCall) +} + +func (fake *ApplicationCapabilities) LifecycleV20Calls(stub func() bool) { + fake.lifecycleV20Mutex.Lock() + defer fake.lifecycleV20Mutex.Unlock() + fake.LifecycleV20Stub = stub +} + +func (fake *ApplicationCapabilities) LifecycleV20Returns(result1 bool) { + fake.lifecycleV20Mutex.Lock() + defer fake.lifecycleV20Mutex.Unlock() + fake.LifecycleV20Stub = nil + fake.lifecycleV20Returns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) LifecycleV20ReturnsOnCall(i int, result1 bool) { + fake.lifecycleV20Mutex.Lock() + defer fake.lifecycleV20Mutex.Unlock() + fake.LifecycleV20Stub = nil + if fake.lifecycleV20ReturnsOnCall == nil { + fake.lifecycleV20ReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.lifecycleV20ReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) MetadataLifecycle() bool { + fake.metadataLifecycleMutex.Lock() + ret, specificReturn := fake.metadataLifecycleReturnsOnCall[len(fake.metadataLifecycleArgsForCall)] + fake.metadataLifecycleArgsForCall = append(fake.metadataLifecycleArgsForCall, struct { + }{}) + fake.recordInvocation("MetadataLifecycle", []interface{}{}) + fake.metadataLifecycleMutex.Unlock() + if fake.MetadataLifecycleStub != nil { + return fake.MetadataLifecycleStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.metadataLifecycleReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) MetadataLifecycleCallCount() int { + fake.metadataLifecycleMutex.RLock() + defer fake.metadataLifecycleMutex.RUnlock() + return len(fake.metadataLifecycleArgsForCall) +} + +func (fake *ApplicationCapabilities) MetadataLifecycleCalls(stub func() bool) { + fake.metadataLifecycleMutex.Lock() + defer fake.metadataLifecycleMutex.Unlock() + fake.MetadataLifecycleStub = stub +} + +func (fake *ApplicationCapabilities) MetadataLifecycleReturns(result1 bool) { + fake.metadataLifecycleMutex.Lock() + defer fake.metadataLifecycleMutex.Unlock() + fake.MetadataLifecycleStub = nil + fake.metadataLifecycleReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) MetadataLifecycleReturnsOnCall(i int, result1 bool) { + fake.metadataLifecycleMutex.Lock() + defer fake.metadataLifecycleMutex.Unlock() + fake.MetadataLifecycleStub = nil + if fake.metadataLifecycleReturnsOnCall == nil { + fake.metadataLifecycleReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.metadataLifecycleReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) PrivateChannelData() bool { + fake.privateChannelDataMutex.Lock() + ret, specificReturn := fake.privateChannelDataReturnsOnCall[len(fake.privateChannelDataArgsForCall)] + fake.privateChannelDataArgsForCall = append(fake.privateChannelDataArgsForCall, struct { + }{}) + fake.recordInvocation("PrivateChannelData", []interface{}{}) + fake.privateChannelDataMutex.Unlock() + if fake.PrivateChannelDataStub != nil { + return fake.PrivateChannelDataStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.privateChannelDataReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) PrivateChannelDataCallCount() int { + fake.privateChannelDataMutex.RLock() + defer fake.privateChannelDataMutex.RUnlock() + return len(fake.privateChannelDataArgsForCall) +} + +func (fake *ApplicationCapabilities) PrivateChannelDataCalls(stub func() bool) { + fake.privateChannelDataMutex.Lock() + defer fake.privateChannelDataMutex.Unlock() + fake.PrivateChannelDataStub = stub +} + +func (fake *ApplicationCapabilities) PrivateChannelDataReturns(result1 bool) { + fake.privateChannelDataMutex.Lock() + defer fake.privateChannelDataMutex.Unlock() + fake.PrivateChannelDataStub = nil + fake.privateChannelDataReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) PrivateChannelDataReturnsOnCall(i int, result1 bool) { + fake.privateChannelDataMutex.Lock() + defer fake.privateChannelDataMutex.Unlock() + fake.PrivateChannelDataStub = nil + if fake.privateChannelDataReturnsOnCall == nil { + fake.privateChannelDataReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.privateChannelDataReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) StorePvtDataOfInvalidTx() bool { + fake.storePvtDataOfInvalidTxMutex.Lock() + ret, specificReturn := fake.storePvtDataOfInvalidTxReturnsOnCall[len(fake.storePvtDataOfInvalidTxArgsForCall)] + fake.storePvtDataOfInvalidTxArgsForCall = append(fake.storePvtDataOfInvalidTxArgsForCall, struct { + }{}) + fake.recordInvocation("StorePvtDataOfInvalidTx", []interface{}{}) + fake.storePvtDataOfInvalidTxMutex.Unlock() + if fake.StorePvtDataOfInvalidTxStub != nil { + return fake.StorePvtDataOfInvalidTxStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.storePvtDataOfInvalidTxReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) StorePvtDataOfInvalidTxCallCount() int { + fake.storePvtDataOfInvalidTxMutex.RLock() + defer fake.storePvtDataOfInvalidTxMutex.RUnlock() + return len(fake.storePvtDataOfInvalidTxArgsForCall) +} + +func (fake *ApplicationCapabilities) StorePvtDataOfInvalidTxCalls(stub func() bool) { + fake.storePvtDataOfInvalidTxMutex.Lock() + defer fake.storePvtDataOfInvalidTxMutex.Unlock() + fake.StorePvtDataOfInvalidTxStub = stub +} + +func (fake *ApplicationCapabilities) StorePvtDataOfInvalidTxReturns(result1 bool) { + fake.storePvtDataOfInvalidTxMutex.Lock() + defer fake.storePvtDataOfInvalidTxMutex.Unlock() + fake.StorePvtDataOfInvalidTxStub = nil + fake.storePvtDataOfInvalidTxReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) StorePvtDataOfInvalidTxReturnsOnCall(i int, result1 bool) { + fake.storePvtDataOfInvalidTxMutex.Lock() + defer fake.storePvtDataOfInvalidTxMutex.Unlock() + fake.StorePvtDataOfInvalidTxStub = nil + if fake.storePvtDataOfInvalidTxReturnsOnCall == nil { + fake.storePvtDataOfInvalidTxReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.storePvtDataOfInvalidTxReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) Supported() error { + fake.supportedMutex.Lock() + ret, specificReturn := fake.supportedReturnsOnCall[len(fake.supportedArgsForCall)] + fake.supportedArgsForCall = append(fake.supportedArgsForCall, struct { + }{}) + fake.recordInvocation("Supported", []interface{}{}) + fake.supportedMutex.Unlock() + if fake.SupportedStub != nil { + return fake.SupportedStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.supportedReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) SupportedCallCount() int { + fake.supportedMutex.RLock() + defer fake.supportedMutex.RUnlock() + return len(fake.supportedArgsForCall) +} + +func (fake *ApplicationCapabilities) SupportedCalls(stub func() error) { + fake.supportedMutex.Lock() + defer fake.supportedMutex.Unlock() + fake.SupportedStub = stub +} + +func (fake *ApplicationCapabilities) SupportedReturns(result1 error) { + fake.supportedMutex.Lock() + defer fake.supportedMutex.Unlock() + fake.SupportedStub = nil + fake.supportedReturns = struct { + result1 error + }{result1} +} + +func (fake *ApplicationCapabilities) SupportedReturnsOnCall(i int, result1 error) { + fake.supportedMutex.Lock() + defer fake.supportedMutex.Unlock() + fake.SupportedStub = nil + if fake.supportedReturnsOnCall == nil { + fake.supportedReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.supportedReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *ApplicationCapabilities) V1_1Validation() bool { + fake.v1_1ValidationMutex.Lock() + ret, specificReturn := fake.v1_1ValidationReturnsOnCall[len(fake.v1_1ValidationArgsForCall)] + fake.v1_1ValidationArgsForCall = append(fake.v1_1ValidationArgsForCall, struct { + }{}) + fake.recordInvocation("V1_1Validation", []interface{}{}) + fake.v1_1ValidationMutex.Unlock() + if fake.V1_1ValidationStub != nil { + return fake.V1_1ValidationStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.v1_1ValidationReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) V1_1ValidationCallCount() int { + fake.v1_1ValidationMutex.RLock() + defer fake.v1_1ValidationMutex.RUnlock() + return len(fake.v1_1ValidationArgsForCall) +} + +func (fake *ApplicationCapabilities) V1_1ValidationCalls(stub func() bool) { + fake.v1_1ValidationMutex.Lock() + defer fake.v1_1ValidationMutex.Unlock() + fake.V1_1ValidationStub = stub +} + +func (fake *ApplicationCapabilities) V1_1ValidationReturns(result1 bool) { + fake.v1_1ValidationMutex.Lock() + defer fake.v1_1ValidationMutex.Unlock() + fake.V1_1ValidationStub = nil + fake.v1_1ValidationReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) V1_1ValidationReturnsOnCall(i int, result1 bool) { + fake.v1_1ValidationMutex.Lock() + defer fake.v1_1ValidationMutex.Unlock() + fake.V1_1ValidationStub = nil + if fake.v1_1ValidationReturnsOnCall == nil { + fake.v1_1ValidationReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.v1_1ValidationReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) V1_2Validation() bool { + fake.v1_2ValidationMutex.Lock() + ret, specificReturn := fake.v1_2ValidationReturnsOnCall[len(fake.v1_2ValidationArgsForCall)] + fake.v1_2ValidationArgsForCall = append(fake.v1_2ValidationArgsForCall, struct { + }{}) + fake.recordInvocation("V1_2Validation", []interface{}{}) + fake.v1_2ValidationMutex.Unlock() + if fake.V1_2ValidationStub != nil { + return fake.V1_2ValidationStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.v1_2ValidationReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) V1_2ValidationCallCount() int { + fake.v1_2ValidationMutex.RLock() + defer fake.v1_2ValidationMutex.RUnlock() + return len(fake.v1_2ValidationArgsForCall) +} + +func (fake *ApplicationCapabilities) V1_2ValidationCalls(stub func() bool) { + fake.v1_2ValidationMutex.Lock() + defer fake.v1_2ValidationMutex.Unlock() + fake.V1_2ValidationStub = stub +} + +func (fake *ApplicationCapabilities) V1_2ValidationReturns(result1 bool) { + fake.v1_2ValidationMutex.Lock() + defer fake.v1_2ValidationMutex.Unlock() + fake.V1_2ValidationStub = nil + fake.v1_2ValidationReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) V1_2ValidationReturnsOnCall(i int, result1 bool) { + fake.v1_2ValidationMutex.Lock() + defer fake.v1_2ValidationMutex.Unlock() + fake.V1_2ValidationStub = nil + if fake.v1_2ValidationReturnsOnCall == nil { + fake.v1_2ValidationReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.v1_2ValidationReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) V1_3Validation() bool { + fake.v1_3ValidationMutex.Lock() + ret, specificReturn := fake.v1_3ValidationReturnsOnCall[len(fake.v1_3ValidationArgsForCall)] + fake.v1_3ValidationArgsForCall = append(fake.v1_3ValidationArgsForCall, struct { + }{}) + fake.recordInvocation("V1_3Validation", []interface{}{}) + fake.v1_3ValidationMutex.Unlock() + if fake.V1_3ValidationStub != nil { + return fake.V1_3ValidationStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.v1_3ValidationReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) V1_3ValidationCallCount() int { + fake.v1_3ValidationMutex.RLock() + defer fake.v1_3ValidationMutex.RUnlock() + return len(fake.v1_3ValidationArgsForCall) +} + +func (fake *ApplicationCapabilities) V1_3ValidationCalls(stub func() bool) { + fake.v1_3ValidationMutex.Lock() + defer fake.v1_3ValidationMutex.Unlock() + fake.V1_3ValidationStub = stub +} + +func (fake *ApplicationCapabilities) V1_3ValidationReturns(result1 bool) { + fake.v1_3ValidationMutex.Lock() + defer fake.v1_3ValidationMutex.Unlock() + fake.V1_3ValidationStub = nil + fake.v1_3ValidationReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) V1_3ValidationReturnsOnCall(i int, result1 bool) { + fake.v1_3ValidationMutex.Lock() + defer fake.v1_3ValidationMutex.Unlock() + fake.V1_3ValidationStub = nil + if fake.v1_3ValidationReturnsOnCall == nil { + fake.v1_3ValidationReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.v1_3ValidationReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) V2_0Validation() bool { + fake.v2_0ValidationMutex.Lock() + ret, specificReturn := fake.v2_0ValidationReturnsOnCall[len(fake.v2_0ValidationArgsForCall)] + fake.v2_0ValidationArgsForCall = append(fake.v2_0ValidationArgsForCall, struct { + }{}) + fake.recordInvocation("V2_0Validation", []interface{}{}) + fake.v2_0ValidationMutex.Unlock() + if fake.V2_0ValidationStub != nil { + return fake.V2_0ValidationStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.v2_0ValidationReturns + return fakeReturns.result1 +} + +func (fake *ApplicationCapabilities) V2_0ValidationCallCount() int { + fake.v2_0ValidationMutex.RLock() + defer fake.v2_0ValidationMutex.RUnlock() + return len(fake.v2_0ValidationArgsForCall) +} + +func (fake *ApplicationCapabilities) V2_0ValidationCalls(stub func() bool) { + fake.v2_0ValidationMutex.Lock() + defer fake.v2_0ValidationMutex.Unlock() + fake.V2_0ValidationStub = stub +} + +func (fake *ApplicationCapabilities) V2_0ValidationReturns(result1 bool) { + fake.v2_0ValidationMutex.Lock() + defer fake.v2_0ValidationMutex.Unlock() + fake.V2_0ValidationStub = nil + fake.v2_0ValidationReturns = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) V2_0ValidationReturnsOnCall(i int, result1 bool) { + fake.v2_0ValidationMutex.Lock() + defer fake.v2_0ValidationMutex.Unlock() + fake.V2_0ValidationStub = nil + if fake.v2_0ValidationReturnsOnCall == nil { + fake.v2_0ValidationReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.v2_0ValidationReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *ApplicationCapabilities) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.aCLsMutex.RLock() + defer fake.aCLsMutex.RUnlock() + fake.collectionUpgradeMutex.RLock() + defer fake.collectionUpgradeMutex.RUnlock() + fake.forbidDuplicateTXIdInBlockMutex.RLock() + defer fake.forbidDuplicateTXIdInBlockMutex.RUnlock() + fake.keyLevelEndorsementMutex.RLock() + defer fake.keyLevelEndorsementMutex.RUnlock() + fake.lifecycleV20Mutex.RLock() + defer fake.lifecycleV20Mutex.RUnlock() + fake.metadataLifecycleMutex.RLock() + defer fake.metadataLifecycleMutex.RUnlock() + fake.privateChannelDataMutex.RLock() + defer fake.privateChannelDataMutex.RUnlock() + fake.storePvtDataOfInvalidTxMutex.RLock() + defer fake.storePvtDataOfInvalidTxMutex.RUnlock() + fake.supportedMutex.RLock() + defer fake.supportedMutex.RUnlock() + fake.v1_1ValidationMutex.RLock() + defer fake.v1_1ValidationMutex.RUnlock() + fake.v1_2ValidationMutex.RLock() + defer fake.v1_2ValidationMutex.RUnlock() + fake.v1_3ValidationMutex.RLock() + defer fake.v1_3ValidationMutex.RUnlock() + fake.v2_0ValidationMutex.RLock() + defer fake.v2_0ValidationMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *ApplicationCapabilities) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +}