1 Star 0 Fork 0

陈文甲/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
support.go 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package lscc
import (
"github.com/hyperledger/fabric/core/common/ccprovider"
"github.com/hyperledger/fabric/protos/peer"
)
type MockSupport struct {
PutChaincodeToLocalStorageErr error
GetChaincodeFromLocalStorageRv ccprovider.CCPackage
GetChaincodeFromLocalStorageErr error
GetChaincodesFromLocalStorageRv *peer.ChaincodeQueryResponse
GetChaincodesFromLocalStorageErr error
GetInstantiationPolicyRv []byte
GetInstantiationPolicyErr error
CheckInstantiationPolicyErr error
GetInstantiationPolicyMap map[string][]byte
CheckInstantiationPolicyMap map[string]error
}
func (s *MockSupport) PutChaincodeToLocalStorage(ccpack ccprovider.CCPackage) error {
return s.PutChaincodeToLocalStorageErr
}
func (s *MockSupport) GetChaincodeFromLocalStorage(ccname string, ccversion string) (ccprovider.CCPackage, error) {
return s.GetChaincodeFromLocalStorageRv, s.GetChaincodeFromLocalStorageErr
}
func (s *MockSupport) GetChaincodesFromLocalStorage() (*peer.ChaincodeQueryResponse, error) {
return s.GetChaincodesFromLocalStorageRv, s.GetChaincodesFromLocalStorageErr
}
func (s *MockSupport) GetInstantiationPolicy(channel string, ccpack ccprovider.CCPackage) ([]byte, error) {
if s.GetInstantiationPolicyMap != nil {
str := ccpack.GetChaincodeData().Name + ccpack.GetChaincodeData().Version
s.GetInstantiationPolicyMap[str] = []byte(str)
return []byte(ccpack.GetChaincodeData().Name + ccpack.GetChaincodeData().Version), nil
}
return s.GetInstantiationPolicyRv, s.GetInstantiationPolicyErr
}
func (s *MockSupport) CheckInstantiationPolicy(signedProp *peer.SignedProposal, chainName string, instantiationPolicy []byte) error {
if s.CheckInstantiationPolicyMap != nil {
return s.CheckInstantiationPolicyMap[string(instantiationPolicy)]
}
return s.CheckInstantiationPolicyErr
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/venjia/fabric.git
git@gitee.com:venjia/fabric.git
venjia
fabric
fabric
v1.1.0-alpha

搜索帮助