github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/core/mocks/ccprovider/ccprovider.go (about) 1 /* 2 Copyright IBM Corp. 2017 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package ccprovider 18 19 import ( 20 "context" 21 22 "github.com/hyperledger/fabric/core/common/ccprovider" 23 "github.com/hyperledger/fabric/core/ledger" 24 "github.com/hyperledger/fabric/protos/peer" 25 ) 26 27 // MockCcProviderFactory is a factory that returns 28 // mock implementations of the ccprovider.ChaincodeProvider interface 29 type MockCcProviderFactory struct { 30 } 31 32 // NewChaincodeProvider returns a mock implementation of the ccprovider.ChaincodeProvider interface 33 func (c *MockCcProviderFactory) NewChaincodeProvider() ccprovider.ChaincodeProvider { 34 return &mockCcProviderImpl{} 35 } 36 37 // mockCcProviderImpl is a mock implementation of the chaincode provider 38 type mockCcProviderImpl struct { 39 } 40 41 type mockCcProviderContextImpl struct { 42 } 43 44 // GetContext does nothing 45 func (c *mockCcProviderImpl) GetContext(ledger ledger.PeerLedger) (context.Context, error) { 46 return nil, nil 47 } 48 49 // GetCCContext does nothing 50 func (c *mockCcProviderImpl) GetCCContext(cid, name, version, txid string, syscc bool, signedProp *peer.SignedProposal, prop *peer.Proposal) interface{} { 51 return &mockCcProviderContextImpl{} 52 } 53 54 // GetCCValidationInfoFromLCCC does nothing 55 func (c *mockCcProviderImpl) GetCCValidationInfoFromLCCC(ctxt context.Context, txid string, signedProp *peer.SignedProposal, prop *peer.Proposal, chainID string, chaincodeID string) (string, []byte, error) { 56 return "vscc", nil, nil 57 } 58 59 // ExecuteChaincode does nothing 60 func (c *mockCcProviderImpl) ExecuteChaincode(ctxt context.Context, cccid interface{}, args [][]byte) (*peer.Response, *peer.ChaincodeEvent, error) { 61 return nil, nil, nil 62 } 63 64 // Execute executes the chaincode given context and spec (invocation or deploy) 65 func (c *mockCcProviderImpl) Execute(ctxt context.Context, cccid interface{}, spec interface{}) (*peer.Response, *peer.ChaincodeEvent, error) { 66 return nil, nil, nil 67 } 68 69 // ExecuteWithErrorFilder executes the chaincode given context and spec and returns payload 70 func (c *mockCcProviderImpl) ExecuteWithErrorFilter(ctxt context.Context, cccid interface{}, spec interface{}) ([]byte, *peer.ChaincodeEvent, error) { 71 return nil, nil, nil 72 } 73 74 // Stop stops the chaincode given context and deployment spec 75 func (c *mockCcProviderImpl) Stop(ctxt context.Context, cccid interface{}, spec *peer.ChaincodeDeploymentSpec) error { 76 return nil 77 } 78 79 // ReleaseContext does nothing 80 func (c *mockCcProviderImpl) ReleaseContext() { 81 }