github.com/myafeier/fabric@v1.0.1-0.20170722181825-3a4b1f2bce86/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/chaincode/shim" 23 "github.com/hyperledger/fabric/core/common/ccprovider" 24 "github.com/hyperledger/fabric/core/ledger" 25 "github.com/hyperledger/fabric/protos/peer" 26 ) 27 28 // MockCcProviderFactory is a factory that returns 29 // mock implementations of the ccprovider.ChaincodeProvider interface 30 type MockCcProviderFactory struct { 31 } 32 33 // NewChaincodeProvider returns a mock implementation of the ccprovider.ChaincodeProvider interface 34 func (c *MockCcProviderFactory) NewChaincodeProvider() ccprovider.ChaincodeProvider { 35 return &mockCcProviderImpl{} 36 } 37 38 // mockCcProviderImpl is a mock implementation of the chaincode provider 39 type mockCcProviderImpl struct { 40 } 41 42 type mockCcProviderContextImpl struct { 43 } 44 45 // GetContext does nothing 46 func (c *mockCcProviderImpl) GetContext(ledger ledger.PeerLedger) (context.Context, error) { 47 return nil, nil 48 } 49 50 // GetCCContext does nothing 51 func (c *mockCcProviderImpl) GetCCContext(cid, name, version, txid string, syscc bool, signedProp *peer.SignedProposal, prop *peer.Proposal) interface{} { 52 return &mockCcProviderContextImpl{} 53 } 54 55 // GetCCValidationInfoFromLSCC does nothing 56 func (c *mockCcProviderImpl) GetCCValidationInfoFromLSCC(ctxt context.Context, txid string, signedProp *peer.SignedProposal, prop *peer.Proposal, chainID string, chaincodeID string) (string, []byte, error) { 57 return "vscc", nil, nil 58 } 59 60 // ExecuteChaincode does nothing 61 func (c *mockCcProviderImpl) ExecuteChaincode(ctxt context.Context, cccid interface{}, args [][]byte) (*peer.Response, *peer.ChaincodeEvent, error) { 62 return &peer.Response{Status: shim.OK}, nil, nil 63 } 64 65 // Execute executes the chaincode given context and spec (invocation or deploy) 66 func (c *mockCcProviderImpl) Execute(ctxt context.Context, cccid interface{}, spec interface{}) (*peer.Response, *peer.ChaincodeEvent, error) { 67 return nil, nil, nil 68 } 69 70 // ExecuteWithErrorFilder executes the chaincode given context and spec and returns payload 71 func (c *mockCcProviderImpl) ExecuteWithErrorFilter(ctxt context.Context, cccid interface{}, spec interface{}) ([]byte, *peer.ChaincodeEvent, error) { 72 return nil, nil, nil 73 } 74 75 // Stop stops the chaincode given context and deployment spec 76 func (c *mockCcProviderImpl) Stop(ctxt context.Context, cccid interface{}, spec *peer.ChaincodeDeploymentSpec) error { 77 return nil 78 } 79 80 // ReleaseContext does nothing 81 func (c *mockCcProviderImpl) ReleaseContext() { 82 }