Documentation
¶
Index ¶
- Variables
- func CreateBlockWithCCEvent(events *pp.ChaincodeEvent, txID string, channelID string) (*common.Block, error)
- func CreateBlockWithCCEventAndTxStatus(events *pp.ChaincodeEvent, txID string, channelID string, ...) (*common.Block, error)
- func NewMockChannelCfg(name string) fab.ChannelCfg
- func NewMockConfig() config.Config
- func NewMockConfigCustomized(tlsEnabled, mutualTLSEnabled, errorCase bool) config.Config
- func NewMockCredentialManager(orgName string, config apiconfig.Config, ...) (apifabclient.CredentialManager, error)
- func NewMockIdentity(err error) (msp.Identity, error)
- func NewMockOrderer(url string, broadcastListener chan *fab.SignedEnvelope) fab.Orderer
- func NewMockSigningIdentity() (msp.SigningIdentity, error)
- func NewMockSigningManager() apifabclient.SigningManager
- func NewMockTxnID() (fab.TransactionID, error)
- func NewMockUser(name string) ca.User
- func NewMockUserWithMSPID(name string, mspid string) ca.User
- func NewSimpleMockBlock() *common.Block
- func NewSimpleMockError() error
- type MockBroadcastServer
- type MockChannelCfg
- type MockChannelConfig
- type MockChannelProvider
- type MockChannelService
- type MockConfig
- func (c *MockConfig) CAClientCertPath(org string) (string, error)
- func (c *MockConfig) CAClientCertPem(org string) (string, error)
- func (c *MockConfig) CAClientKeyPath(org string) (string, error)
- func (c *MockConfig) CAClientKeyPem(org string) (string, error)
- func (c *MockConfig) CAConfig(org string) (*config.CAConfig, error)
- func (c *MockConfig) CAKeyStorePath() string
- func (c *MockConfig) CAServerCertPaths(org string) ([]string, error)
- func (c *MockConfig) CAServerCertPems(org string) ([]string, error)
- func (c *MockConfig) ChannelConfig(name string) (*config.ChannelConfig, error)
- func (c *MockConfig) ChannelOrderers(name string) ([]config.OrdererConfig, error)
- func (c *MockConfig) ChannelPeers(name string) ([]config.ChannelPeer, error)
- func (c *MockConfig) Client() (*config.ClientConfig, error)
- func (c *MockConfig) CryptoConfigPath() string
- func (c *MockConfig) Ephemeral() bool
- func (c *MockConfig) IsSecurityEnabled() bool
- func (c *MockConfig) KeyStorePath() string
- func (c *MockConfig) MspID(org string) (string, error)
- func (c *MockConfig) NetworkConfig() (*config.NetworkConfig, error)
- func (c *MockConfig) NetworkPeers() ([]config.NetworkPeer, error)
- func (c *MockConfig) OrdererConfig(name string) (*config.OrdererConfig, error)
- func (c *MockConfig) OrderersConfig() ([]config.OrdererConfig, error)
- func (c *MockConfig) PeerConfig(org string, name string) (*config.PeerConfig, error)
- func (c *MockConfig) PeerMspID(name string) (string, error)
- func (c *MockConfig) PeersConfig(org string) ([]config.PeerConfig, error)
- func (c *MockConfig) RandomOrdererConfig() (*config.OrdererConfig, error)
- func (c *MockConfig) SecurityAlgorithm() string
- func (c *MockConfig) SecurityLevel() int
- func (c *MockConfig) SecurityProvider() string
- func (c *MockConfig) SecurityProviderLabel() string
- func (c *MockConfig) SecurityProviderLibPath() string
- func (c *MockConfig) SecurityProviderPin() string
- func (c *MockConfig) SetTLSCACertPool(pool *sm2.CertPool)
- func (c *MockConfig) SoftVerify() bool
- func (c *MockConfig) TLSCACertPool(cert ...*sm2.Certificate) (*sm2.CertPool, error)
- func (c *MockConfig) TLSClientCerts() ([]tls.Certificate, error)
- func (c *MockConfig) TcertBatchSize() int
- func (c *MockConfig) TimeoutOrDefault(arg config.TimeoutType) time.Duration
- type MockConfigBlockBuilder
- type MockConfigGroupBuilder
- type MockConfigUpdateEnvelopeBuilder
- type MockContext
- type MockCredentialManager
- type MockCryptoSuite
- func (m *MockCryptoSuite) GetHash(opts apicryptosuite.HashOpts) (h hash.Hash, err error)
- func (m *MockCryptoSuite) GetKey(ski []byte) (k apicryptosuite.Key, err error)
- func (m *MockCryptoSuite) Hash(msg []byte, opts apicryptosuite.HashOpts) (hash []byte, err error)
- func (m *MockCryptoSuite) KeyGen(opts apicryptosuite.KeyGenOpts) (k apicryptosuite.Key, err error)
- func (m *MockCryptoSuite) KeyImport(raw interface{}, opts apicryptosuite.KeyImportOpts) (k apicryptosuite.Key, err error)
- func (m *MockCryptoSuite) Sign(k apicryptosuite.Key, digest []byte, opts apicryptosuite.SignerOpts) (signature []byte, err error)
- func (m *MockCryptoSuite) Verify(k apicryptosuite.Key, signature, digest []byte, opts apicryptosuite.SignerOpts) (valid bool, err error)
- type MockEndorserServer
- type MockEventHub
- func (m *MockEventHub) Connect() error
- func (m *MockEventHub) Disconnect() error
- func (m *MockEventHub) IsConnected() bool
- func (m *MockEventHub) RegisterBlockEvent(callback func(*common.Block))
- func (m *MockEventHub) RegisterChaincodeEvent(ccid string, eventname string, callback func(*apifabclient.ChaincodeEvent)) *apifabclient.ChainCodeCBE
- func (m *MockEventHub) RegisterTxEvent(txnID apifabclient.TransactionID, ...)
- func (m *MockEventHub) SetPeerAddr(peerURL string, certificate *sm2.Certificate, serverHostOverride string)
- func (m *MockEventHub) UnregisterBlockEvent(callback func(*common.Block))
- func (m *MockEventHub) UnregisterChaincodeEvent(cbe *apifabclient.ChainCodeCBE)
- func (m *MockEventHub) UnregisterTxEvent(txnID apifabclient.TransactionID)
- type MockEventServer
- type MockIdentity
- func (id *MockIdentity) ExpiresAt() time.Time
- func (id *MockIdentity) GetIdentifier() *msp.IdentityIdentifier
- func (id *MockIdentity) GetMSPIdentifier() string
- func (id *MockIdentity) GetOrganizationalUnits() []*msp.OUIdentifier
- func (id *MockIdentity) SatisfiesPrincipal(principal *msp_protos.MSPPrincipal) error
- func (id *MockIdentity) Serialize() ([]byte, error)
- func (id *MockIdentity) Validate() error
- func (id *MockIdentity) Verify(msg []byte, sig []byte) error
- type MockMSP
- func (m *MockMSP) DeserializeIdentity(serializedIdentity []byte) (msp.Identity, error)
- func (m *MockMSP) GetDefaultSigningIdentity() (msp.SigningIdentity, error)
- func (m *MockMSP) GetIdentifier() (string, error)
- func (m *MockMSP) GetMSPs() (map[string]msp.MSP, error)
- func (m *MockMSP) GetSigningIdentity(identifier *msp.IdentityIdentifier) (msp.SigningIdentity, error)
- func (m *MockMSP) GetTLSIntermediateCerts() [][]byte
- func (m *MockMSP) GetTLSRootCerts() [][]byte
- func (m *MockMSP) GetType() msp.ProviderType
- func (m *MockMSP) GetVersion() msp.MSPVersion
- func (m *MockMSP) IsWellFormed(identity *msp_protos.SerializedIdentity) error
- func (m *MockMSP) SatisfiesPrincipal(id msp.Identity, principal *msp_protos.MSPPrincipal) error
- func (m *MockMSP) Setup(config *msp_protos.MSPConfig) error
- func (m *MockMSP) Validate(id msp.Identity) error
- type MockMSPManager
- func (mgr *MockMSPManager) DeserializeIdentity(serializedIdentity []byte) (msp.Identity, error)
- func (mgr *MockMSPManager) GetMSPs() (map[string]msp.MSP, error)
- func (mgr *MockMSPManager) IsWellFormed(identity *msp_protos.SerializedIdentity) error
- func (mgr *MockMSPManager) Setup(msps []msp.MSP) error
- type MockOrderer
- type MockPeer
- func (p *MockPeer) EnrollmentCertificate() *pem.Block
- func (p *MockPeer) MSPID() string
- func (p MockPeer) Name() string
- func (p *MockPeer) ProcessTransactionProposal(tp apifabclient.TransactionProposal) (apifabclient.TransactionProposalResponse, error)
- func (p *MockPeer) Roles() []string
- func (p *MockPeer) SetEnrollmentCertificate(pem *pem.Block)
- func (p *MockPeer) SetMSPID(mspID string)
- func (p *MockPeer) SetName(name string)
- func (p *MockPeer) SetRoles(roles []string)
- func (p *MockPeer) URL() string
- type MockProviderContext
- type MockResource
- func (c *MockResource) CreateChannel(request fab.CreateChannelRequest) (fab.TransactionID, error)
- func (c *MockResource) ExtractChannelConfig(configEnvelope []byte) ([]byte, error)
- func (c *MockResource) GenesisBlockFromOrderer(channelName string, orderer fab.Orderer) (*common.Block, error)
- func (c *MockResource) InstallChaincode(req fab.InstallChaincodeRequest) ([]*fab.TransactionProposalResponse, string, error)
- func (c *MockResource) JoinChannel(request fab.JoinChannelRequest) error
- func (c *MockResource) QueryChannels(peer fab.ProposalProcessor) (*pb.ChannelQueryResponse, error)
- func (c *MockResource) QueryInstalledChaincodes(peer fab.ProposalProcessor) (*pb.ChaincodeQueryResponse, error)
- func (c *MockResource) SignChannelConfig(config []byte, signer fab.IdentityContext) (*common.ConfigSignature, error)
- type MockSigningIdentity
- type MockSigningManager
- type MockUser
- func (u *MockUser) EnrollmentCertificate() []byte
- func (u *MockUser) GenerateTcerts(count int, attributes []string)
- func (u *MockUser) Identity() ([]byte, error)
- func (u *MockUser) MspID() string
- func (u *MockUser) Name() string
- func (u *MockUser) PrivateKey() apicryptosuite.Key
- func (u *MockUser) Roles() []string
- func (u *MockUser) SetEnrollmentCertificate(cert []byte)
- func (u *MockUser) SetMspID(mspID string)
- func (u *MockUser) SetPrivateKey(privateKey apicryptosuite.Key)
- func (u *MockUser) SetRoles(roles []string)
Constants ¶
This section is empty.
Variables ¶
var TestBlock = &po.DeliverResponse{ Type: &po.DeliverResponse_Block{ Block: &common.Block{ Data: &common.BlockData{ Data: [][]byte{[]byte("test")}, }, }, }, }
TestBlock is a test block
Functions ¶
func CreateBlockWithCCEvent ¶
func CreateBlockWithCCEvent(events *pp.ChaincodeEvent, txID string, channelID string) (*common.Block, error)
CreateBlockWithCCEvent creates a mock block
func CreateBlockWithCCEventAndTxStatus ¶
func CreateBlockWithCCEventAndTxStatus(events *pp.ChaincodeEvent, txID string, channelID string, txValidationCode pp.TxValidationCode) (*common.Block, error)
CreateBlockWithCCEventAndTxStatus creates a mock block with the given CC event and TX validation code
func NewMockConfigCustomized ¶
NewMockConfigCustomized ...
func NewMockCredentialManager ¶
func NewMockCredentialManager(orgName string, config apiconfig.Config, cryptoProvider apicryptosuite.CryptoSuite) (apifabclient.CredentialManager, error)
NewMockCredentialManager Constructor for a credential manager.
func NewMockIdentity ¶
NewMockIdentity creates new mock identity
func NewMockOrderer ¶
func NewMockOrderer(url string, broadcastListener chan *fab.SignedEnvelope) fab.Orderer
NewMockOrderer ...
func NewMockSigningIdentity ¶
func NewMockSigningIdentity() (msp.SigningIdentity, error)
NewMockSigningIdentity ...
func NewMockSigningManager ¶
func NewMockSigningManager() apifabclient.SigningManager
NewMockSigningManager Constructor for a mock signing manager.
func NewMockTxnID ¶
func NewMockTxnID() (fab.TransactionID, error)
NewMockTxnID creates mock TxnID based on mock user.
func NewMockUserWithMSPID ¶
NewMockUserWithMSPID to return mock user with MSP ids
func NewSimpleMockBlock ¶
NewSimpleMockBlock returns a simple mock block
Types ¶
type MockBroadcastServer ¶
type MockBroadcastServer struct { DeliverError error BroadcastInternalServerError bool DeliverResponse *po.DeliverResponse BroadcastError error }
MockBroadcastServer mock broadcast server
func StartMockBroadcastServer ¶
func StartMockBroadcastServer(broadcastTestURL string) *MockBroadcastServer
StartMockBroadcastServer starts mock server for unit testing purpose
func (*MockBroadcastServer) Broadcast ¶
func (m *MockBroadcastServer) Broadcast(server po.AtomicBroadcast_BroadcastServer) error
Broadcast mock broadcast
func (*MockBroadcastServer) Deliver ¶
func (m *MockBroadcastServer) Deliver(server po.AtomicBroadcast_DeliverServer) error
Deliver mock deliver
type MockChannelCfg ¶
type MockChannelCfg struct { MockName string MockMsps []*msp.MSPConfig MockAnchorPeers []*fab.OrgAnchorPeer MockOrderers []string MockVersions *fab.Versions }
MockChannelCfg contains mock channel configuration
func (*MockChannelCfg) AnchorPeers ¶
func (cfg *MockChannelCfg) AnchorPeers() []*fab.OrgAnchorPeer
AnchorPeers returns anchor peers
func (*MockChannelCfg) Orderers ¶
func (cfg *MockChannelCfg) Orderers() []string
Orderers returns orderers
func (*MockChannelCfg) Versions ¶
func (cfg *MockChannelCfg) Versions() *fab.Versions
Versions returns versions
type MockChannelConfig ¶
type MockChannelConfig struct {
// contains filtered or unexported fields
}
MockChannelConfig mocks query channel configuration
func NewMockChannelConfig ¶
func NewMockChannelConfig(ctx fab.Context, channelID string) (*MockChannelConfig, error)
NewMockChannelConfig mocks channel config implementation
func (*MockChannelConfig) Query ¶
func (c *MockChannelConfig) Query() (fab.ChannelCfg, error)
Query mocks query for channel configuration
type MockChannelProvider ¶
type MockChannelProvider struct {
// contains filtered or unexported fields
}
MockChannelProvider holds a mock channel provider.
func NewMockChannelProvider ¶
func NewMockChannelProvider(ctx fab.Context) (*MockChannelProvider, error)
NewMockChannelProvider returns a mock ChannelProvider
func (*MockChannelProvider) NewChannelService ¶
func (cp *MockChannelProvider) NewChannelService(ic fab.IdentityContext, channelID string) (fab.ChannelService, error)
NewChannelService returns a mock ChannelService
func (*MockChannelProvider) SetChannel ¶
func (cp *MockChannelProvider) SetChannel(id string, channel fab.Channel)
SetChannel convenience method to set channel
type MockChannelService ¶
type MockChannelService struct {
// contains filtered or unexported fields
}
MockChannelService holds a mock channel service.
func (*MockChannelService) Channel ¶
func (cs *MockChannelService) Channel() (fab.Channel, error)
Channel ...
func (*MockChannelService) Config ¶
func (cs *MockChannelService) Config() (fab.ChannelConfig, error)
Config ...
func (*MockChannelService) EventHub ¶
func (cs *MockChannelService) EventHub() (fab.EventHub, error)
EventHub ...
func (*MockChannelService) Ledger ¶
func (cs *MockChannelService) Ledger() (fab.ChannelLedger, error)
Ledger ...
type MockConfig ¶
type MockConfig struct {
// contains filtered or unexported fields
}
MockConfig ...
func (*MockConfig) CAClientCertPath ¶
func (c *MockConfig) CAClientCertPath(org string) (string, error)
CAClientCertPath Read configuration option for the fabric CA client cert file
func (*MockConfig) CAClientCertPem ¶
func (c *MockConfig) CAClientCertPem(org string) (string, error)
CAClientCertPem Read configuration option for the fabric CA client cert from a string
func (*MockConfig) CAClientKeyPath ¶
func (c *MockConfig) CAClientKeyPath(org string) (string, error)
CAClientKeyPath Read configuration option for the fabric CA client key file
func (*MockConfig) CAClientKeyPem ¶
func (c *MockConfig) CAClientKeyPem(org string) (string, error)
CAClientKeyPem Read configuration option for the fabric CA client key from a string
func (*MockConfig) CAConfig ¶
func (c *MockConfig) CAConfig(org string) (*config.CAConfig, error)
CAConfig not implemented
func (*MockConfig) CAKeyStorePath ¶
func (c *MockConfig) CAKeyStorePath() string
CAKeyStorePath not implemented
func (*MockConfig) CAServerCertPaths ¶
func (c *MockConfig) CAServerCertPaths(org string) ([]string, error)
CAServerCertPaths Read configuration option for the server certificate files
func (*MockConfig) CAServerCertPems ¶
func (c *MockConfig) CAServerCertPems(org string) ([]string, error)
CAServerCertPems Read configuration option for the server certificate embedded pems
func (*MockConfig) ChannelConfig ¶
func (c *MockConfig) ChannelConfig(name string) (*config.ChannelConfig, error)
ChannelConfig returns the channel configuration
func (*MockConfig) ChannelOrderers ¶
func (c *MockConfig) ChannelOrderers(name string) ([]config.OrdererConfig, error)
ChannelOrderers returns a list of channel orderers
func (*MockConfig) ChannelPeers ¶
func (c *MockConfig) ChannelPeers(name string) ([]config.ChannelPeer, error)
ChannelPeers returns the channel peers configuration
func (*MockConfig) CryptoConfigPath ¶
func (c *MockConfig) CryptoConfigPath() string
CryptoConfigPath ...
func (*MockConfig) IsSecurityEnabled ¶
func (c *MockConfig) IsSecurityEnabled() bool
IsSecurityEnabled ...
func (*MockConfig) MspID ¶
func (c *MockConfig) MspID(org string) (string, error)
MspID not implemented
func (*MockConfig) NetworkConfig ¶
func (c *MockConfig) NetworkConfig() (*config.NetworkConfig, error)
NetworkConfig not implemented
func (*MockConfig) NetworkPeers ¶
func (c *MockConfig) NetworkPeers() ([]config.NetworkPeer, error)
NetworkPeers returns the mock network peers configuration
func (*MockConfig) OrdererConfig ¶
func (c *MockConfig) OrdererConfig(name string) (*config.OrdererConfig, error)
OrdererConfig not implemented
func (*MockConfig) OrderersConfig ¶
func (c *MockConfig) OrderersConfig() ([]config.OrdererConfig, error)
OrderersConfig returns a list of defined orderers
func (*MockConfig) PeerConfig ¶
func (c *MockConfig) PeerConfig(org string, name string) (*config.PeerConfig, error)
PeerConfig Retrieves a specific peer from the configuration by org and name
func (*MockConfig) PeerMspID ¶
func (c *MockConfig) PeerMspID(name string) (string, error)
PeerMspID not implemented
func (*MockConfig) PeersConfig ¶
func (c *MockConfig) PeersConfig(org string) ([]config.PeerConfig, error)
PeersConfig Retrieves the fabric peers from the config file provided
func (*MockConfig) RandomOrdererConfig ¶
func (c *MockConfig) RandomOrdererConfig() (*config.OrdererConfig, error)
RandomOrdererConfig not implemented
func (*MockConfig) SecurityAlgorithm ¶
func (c *MockConfig) SecurityAlgorithm() string
SecurityAlgorithm ...
func (*MockConfig) SecurityProvider ¶
func (c *MockConfig) SecurityProvider() string
SecurityProvider ...
func (*MockConfig) SecurityProviderLabel ¶
func (c *MockConfig) SecurityProviderLabel() string
SecurityProviderLabel ...
func (*MockConfig) SecurityProviderLibPath ¶
func (c *MockConfig) SecurityProviderLibPath() string
SecurityProviderLibPath will be set only if provider is PKCS11
func (*MockConfig) SecurityProviderPin ¶
func (c *MockConfig) SecurityProviderPin() string
SecurityProviderPin ...
func (*MockConfig) SetTLSCACertPool ¶
func (c *MockConfig) SetTLSCACertPool(pool *sm2.CertPool)
SetTLSCACertPool ...
func (*MockConfig) TLSCACertPool ¶
func (c *MockConfig) TLSCACertPool(cert ...*sm2.Certificate) (*sm2.CertPool, error)
TLSCACertPool ...
func (*MockConfig) TLSClientCerts ¶
func (c *MockConfig) TLSClientCerts() ([]tls.Certificate, error)
TLSClientCerts ...
func (*MockConfig) TimeoutOrDefault ¶
func (c *MockConfig) TimeoutOrDefault(arg config.TimeoutType) time.Duration
TimeoutOrDefault not implemented
type MockConfigBlockBuilder ¶
type MockConfigBlockBuilder struct { MockConfigGroupBuilder Index uint64 LastConfigIndex uint64 }
MockConfigBlockBuilder is used to build a mock Chain configuration block
func (*MockConfigBlockBuilder) Build ¶
func (b *MockConfigBlockBuilder) Build() *common.Block
Build creates a mock Chain configuration Block
type MockConfigGroupBuilder ¶
type MockConfigGroupBuilder struct { Version uint64 ModPolicy string OrdererAddress string MSPNames []string RootCA string Groups map[string]*common.ConfigGroup }
MockConfigGroupBuilder is used to build a mock ConfigGroup
type MockConfigUpdateEnvelopeBuilder ¶
type MockConfigUpdateEnvelopeBuilder struct { MockConfigGroupBuilder ChannelID string }
MockConfigUpdateEnvelopeBuilder builds a mock ConfigUpdateEnvelope
func (*MockConfigUpdateEnvelopeBuilder) Build ¶
func (b *MockConfigUpdateEnvelopeBuilder) Build() *common.Envelope
Build builds an Envelope that contains a mock ConfigUpdateEnvelope
func (*MockConfigUpdateEnvelopeBuilder) BuildBytes ¶
func (b *MockConfigUpdateEnvelopeBuilder) BuildBytes() []byte
BuildBytes builds an Envelope that contains a mock ConfigUpdateEnvelope and returns the marshaled bytes
func (*MockConfigUpdateEnvelopeBuilder) BuildConfigUpdateBytes ¶
func (b *MockConfigUpdateEnvelopeBuilder) BuildConfigUpdateBytes() []byte
BuildConfigUpdateBytes builds an mock ConfigUpdate returns the marshaled bytes
type MockContext ¶
type MockContext struct { *MockProviderContext fab.IdentityContext }
MockContext holds core providers and identity to enable mocking.
func NewMockContext ¶
func NewMockContext(ic fab.IdentityContext) *MockContext
NewMockContext creates a MockContext consisting of defaults and an identity
type MockCredentialManager ¶
type MockCredentialManager struct { }
MockCredentialManager is a mock CredentialManager
func (*MockCredentialManager) GetSigningIdentity ¶
func (mgr *MockCredentialManager) GetSigningIdentity(userName string) (*apifabclient.SigningIdentity, error)
GetSigningIdentity will sign the given object with provided key,
type MockCryptoSuite ¶
type MockCryptoSuite struct { }
MockCryptoSuite implementation
func (*MockCryptoSuite) GetHash ¶
func (m *MockCryptoSuite) GetHash(opts apicryptosuite.HashOpts) (h hash.Hash, err error)
GetHash mock get hash
func (*MockCryptoSuite) GetKey ¶
func (m *MockCryptoSuite) GetKey(ski []byte) (k apicryptosuite.Key, err error)
GetKey mock get key
func (*MockCryptoSuite) Hash ¶
func (m *MockCryptoSuite) Hash(msg []byte, opts apicryptosuite.HashOpts) (hash []byte, err error)
Hash mock hash
func (*MockCryptoSuite) KeyGen ¶
func (m *MockCryptoSuite) KeyGen(opts apicryptosuite.KeyGenOpts) (k apicryptosuite.Key, err error)
KeyGen mock key gen
func (*MockCryptoSuite) KeyImport ¶
func (m *MockCryptoSuite) KeyImport(raw interface{}, opts apicryptosuite.KeyImportOpts) (k apicryptosuite.Key, err error)
KeyImport mock key import
func (*MockCryptoSuite) Sign ¶
func (m *MockCryptoSuite) Sign(k apicryptosuite.Key, digest []byte, opts apicryptosuite.SignerOpts) (signature []byte, err error)
Sign mock signing
func (*MockCryptoSuite) Verify ¶
func (m *MockCryptoSuite) Verify(k apicryptosuite.Key, signature, digest []byte, opts apicryptosuite.SignerOpts) (valid bool, err error)
Verify mock verify implementation
type MockEndorserServer ¶
MockEndorserServer mock endoreser server to process endorsement proposals
func StartEndorserServer ¶
func StartEndorserServer(endorserTestURL string) *MockEndorserServer
StartEndorserServer starts mock server for unit testing purpose
func (*MockEndorserServer) ProcessProposal ¶
func (m *MockEndorserServer) ProcessProposal(context context.Context, proposal *pb.SignedProposal) (*pb.ProposalResponse, error)
ProcessProposal mock implementation that returns success if error is not set error if it is
type MockEventHub ¶
type MockEventHub struct {
RegisteredTxCallbacks chan func(string, pb.TxValidationCode, error)
}
MockEventHub Mock EventHub
func NewMockEventHub ¶
func NewMockEventHub() *MockEventHub
NewMockEventHub creates a new mock EventHub
func (*MockEventHub) Disconnect ¶
func (m *MockEventHub) Disconnect() error
Disconnect not implemented
func (*MockEventHub) IsConnected ¶
func (m *MockEventHub) IsConnected() bool
IsConnected not implemented
func (*MockEventHub) RegisterBlockEvent ¶
func (m *MockEventHub) RegisterBlockEvent(callback func(*common.Block))
RegisterBlockEvent not implemented
func (*MockEventHub) RegisterChaincodeEvent ¶
func (m *MockEventHub) RegisterChaincodeEvent(ccid string, eventname string, callback func(*apifabclient.ChaincodeEvent)) *apifabclient.ChainCodeCBE
RegisterChaincodeEvent not implemented
func (*MockEventHub) RegisterTxEvent ¶
func (m *MockEventHub) RegisterTxEvent(txnID apifabclient.TransactionID, callback func(string, pb.TxValidationCode, error))
RegisterTxEvent not implemented
func (*MockEventHub) SetPeerAddr ¶
func (m *MockEventHub) SetPeerAddr(peerURL string, certificate *sm2.Certificate, serverHostOverride string)
SetPeerAddr not implemented
func (*MockEventHub) UnregisterBlockEvent ¶
func (m *MockEventHub) UnregisterBlockEvent(callback func(*common.Block))
UnregisterBlockEvent not implemented
func (*MockEventHub) UnregisterChaincodeEvent ¶
func (m *MockEventHub) UnregisterChaincodeEvent(cbe *apifabclient.ChainCodeCBE)
UnregisterChaincodeEvent not implemented
func (*MockEventHub) UnregisterTxEvent ¶
func (m *MockEventHub) UnregisterTxEvent(txnID apifabclient.TransactionID)
UnregisterTxEvent not implemented
type MockEventServer ¶
type MockEventServer struct {
// contains filtered or unexported fields
}
MockEventServer ...
func StartMockEventServer ¶
func StartMockEventServer(testAddress string) (*MockEventServer, error)
StartMockEventServer will start mock event server for unit testing purpose
func (*MockEventServer) Chat ¶
func (m *MockEventServer) Chat(srv pb.Events_ChatServer) error
Chat for event chatting
func (*MockEventServer) SendMockEvent ¶
func (m *MockEventServer) SendMockEvent(event *pb.Event)
SendMockEvent used for sending mock events to event server
type MockIdentity ¶
type MockIdentity struct {
Err error
}
MockIdentity implements identity
func (*MockIdentity) ExpiresAt ¶
func (id *MockIdentity) ExpiresAt() time.Time
ExpiresAt returns the time at which the Identity expires.
func (*MockIdentity) GetIdentifier ¶
func (id *MockIdentity) GetIdentifier() *msp.IdentityIdentifier
GetIdentifier returns the identifier (MSPID/IDID) for this instance
func (*MockIdentity) GetMSPIdentifier ¶
func (id *MockIdentity) GetMSPIdentifier() string
GetMSPIdentifier returns the MSP identifier for this instance
func (*MockIdentity) GetOrganizationalUnits ¶
func (id *MockIdentity) GetOrganizationalUnits() []*msp.OUIdentifier
GetOrganizationalUnits returns the OU for this instance
func (*MockIdentity) SatisfiesPrincipal ¶
func (id *MockIdentity) SatisfiesPrincipal(principal *msp_protos.MSPPrincipal) error
SatisfiesPrincipal returns null if this instance matches the supplied principal or an error otherwise
func (*MockIdentity) Serialize ¶
func (id *MockIdentity) Serialize() ([]byte, error)
Serialize returns a byte array representation of this identity
func (*MockIdentity) Validate ¶
func (id *MockIdentity) Validate() error
Validate returns nil if this instance is a valid identity or an error otherwise
type MockMSP ¶
type MockMSP struct {
Err error
}
MockMSP implements mock msp
func (*MockMSP) DeserializeIdentity ¶
DeserializeIdentity mocks deserialize identity
func (*MockMSP) GetDefaultSigningIdentity ¶
func (m *MockMSP) GetDefaultSigningIdentity() (msp.SigningIdentity, error)
GetDefaultSigningIdentity returns the default signing identity
func (*MockMSP) GetIdentifier ¶
GetIdentifier returns the provider identifier
func (*MockMSP) GetSigningIdentity ¶
func (m *MockMSP) GetSigningIdentity(identifier *msp.IdentityIdentifier) (msp.SigningIdentity, error)
GetSigningIdentity returns a signing identity corresponding to the provided identifier
func (*MockMSP) GetTLSIntermediateCerts ¶
GetTLSIntermediateCerts returns the TLS intermediate root certificates for this MSP
func (*MockMSP) GetTLSRootCerts ¶
GetTLSRootCerts returns the TLS root certificates for this MSP
func (*MockMSP) GetType ¶
func (m *MockMSP) GetType() msp.ProviderType
GetType returns the provider type
func (*MockMSP) GetVersion ¶
func (m *MockMSP) GetVersion() msp.MSPVersion
GetVersion returns the version of this MSP
func (*MockMSP) IsWellFormed ¶
func (m *MockMSP) IsWellFormed(identity *msp_protos.SerializedIdentity) error
IsWellFormed checks if the given identity can be deserialized into its provider-specific form
func (*MockMSP) SatisfiesPrincipal ¶
func (m *MockMSP) SatisfiesPrincipal(id msp.Identity, principal *msp_protos.MSPPrincipal) error
SatisfiesPrincipal checks whether the identity matches the description supplied in MSPPrincipal.
type MockMSPManager ¶
MockMSPManager implements mock msp manager
func NewMockMSPManager ¶
func NewMockMSPManager(msps map[string]msp.MSP) *MockMSPManager
NewMockMSPManager mocks msp manager
func NewMockMSPManagerWithError ¶
func NewMockMSPManagerWithError(msps map[string]msp.MSP, err error) *MockMSPManager
NewMockMSPManagerWithError mocks msp manager
func (*MockMSPManager) DeserializeIdentity ¶
func (mgr *MockMSPManager) DeserializeIdentity(serializedIdentity []byte) (msp.Identity, error)
DeserializeIdentity mocks deserialize identity
func (*MockMSPManager) GetMSPs ¶
func (mgr *MockMSPManager) GetMSPs() (map[string]msp.MSP, error)
GetMSPs Provides a list of Membership Service providers
func (*MockMSPManager) IsWellFormed ¶
func (mgr *MockMSPManager) IsWellFormed(identity *msp_protos.SerializedIdentity) error
IsWellFormed checks if the given identity can be deserialized into its provider-specific form
type MockOrderer ¶
type MockOrderer interface { fab.Orderer // Enqueues a mock error to be returned to the client calling SendBroadcast EnqueueSendBroadcastError(err error) // Enqueues a mock value (block or error) for delivery EnqueueForSendDeliver(value interface{}) }
MockOrderer is a mock fabricclient.Orderer Nothe that calling broadcast doesn't deliver anythng. This implies that the broadcast side and the deliver side are totally independent from the mocking point of view.
type MockPeer ¶
type MockPeer struct { RWLock *sync.RWMutex Error error MockName string MockURL string MockRoles []string MockCert *pem.Block Payload []byte ResponseMessage string MockMSP string Status int32 ProcessProposalCalls int Endorser []byte }
MockPeer is a mock fabricsdk.Peer.
func NewMockPeer ¶
NewMockPeer creates basic mock peer
func (*MockPeer) EnrollmentCertificate ¶
EnrollmentCertificate returns the mock peer's mock enrollment certificate
func (*MockPeer) ProcessTransactionProposal ¶
func (p *MockPeer) ProcessTransactionProposal(tp apifabclient.TransactionProposal) (apifabclient.TransactionProposalResponse, error)
ProcessTransactionProposal does not send anything anywhere but returns an empty mock ProposalResponse
func (*MockPeer) SetEnrollmentCertificate ¶
SetEnrollmentCertificate sets the mock peer's mock enrollment certificate
type MockProviderContext ¶
type MockProviderContext struct {
// contains filtered or unexported fields
}
MockProviderContext holds core providers to enable mocking.
func NewMockProviderContext ¶
func NewMockProviderContext() *MockProviderContext
NewMockProviderContext creates a MockProviderContext consisting of defaults
func NewMockProviderContextCustom ¶
func NewMockProviderContextCustom(config config.Config, cryptoSuite apicryptosuite.CryptoSuite, signer fab.SigningManager) *MockProviderContext
NewMockProviderContextCustom creates a MockProviderContext consisting of the arguments
func (*MockProviderContext) Config ¶
func (pc *MockProviderContext) Config() config.Config
Config returns the mock configuration.
func (*MockProviderContext) CryptoSuite ¶
func (pc *MockProviderContext) CryptoSuite() apicryptosuite.CryptoSuite
CryptoSuite returns the mock crypto suite.
func (*MockProviderContext) SetConfig ¶
func (pc *MockProviderContext) SetConfig(config config.Config)
SetConfig sets the mock configuration.
func (*MockProviderContext) SigningManager ¶
func (pc *MockProviderContext) SigningManager() fab.SigningManager
SigningManager returns the mock signing manager.
type MockResource ¶
type MockResource struct {
// contains filtered or unexported fields
}
MockResource ...
func NewMockInvalidResource ¶
func NewMockInvalidResource() *MockResource
NewMockInvalidResource ...
func (*MockResource) CreateChannel ¶
func (c *MockResource) CreateChannel(request fab.CreateChannelRequest) (fab.TransactionID, error)
CreateChannel ...
func (*MockResource) ExtractChannelConfig ¶
func (c *MockResource) ExtractChannelConfig(configEnvelope []byte) ([]byte, error)
ExtractChannelConfig ...
func (*MockResource) GenesisBlockFromOrderer ¶
func (c *MockResource) GenesisBlockFromOrderer(channelName string, orderer fab.Orderer) (*common.Block, error)
GenesisBlockFromOrderer returns the genesis block from the defined orderer that may be used in a join request
func (*MockResource) InstallChaincode ¶
func (c *MockResource) InstallChaincode(req fab.InstallChaincodeRequest) ([]*fab.TransactionProposalResponse, string, error)
InstallChaincode mocks install chaincode
func (*MockResource) JoinChannel ¶
func (c *MockResource) JoinChannel(request fab.JoinChannelRequest) error
JoinChannel sends a join channel proposal to the target peer.
func (*MockResource) QueryChannels ¶
func (c *MockResource) QueryChannels(peer fab.ProposalProcessor) (*pb.ChannelQueryResponse, error)
QueryChannels ...
func (*MockResource) QueryInstalledChaincodes ¶
func (c *MockResource) QueryInstalledChaincodes(peer fab.ProposalProcessor) (*pb.ChaincodeQueryResponse, error)
QueryInstalledChaincodes mocks query installed chaincodes
func (*MockResource) SignChannelConfig ¶
func (c *MockResource) SignChannelConfig(config []byte, signer fab.IdentityContext) (*common.ConfigSignature, error)
SignChannelConfig ...
type MockSigningIdentity ¶
type MockSigningIdentity struct { // we embed everything from a base identity MockIdentity // signer corresponds to the object that can produce signatures from this identity Signer crypto.Signer }
MockSigningIdentity ...
func (*MockSigningIdentity) GetPublicVersion ¶
func (id *MockSigningIdentity) GetPublicVersion() msp.Identity
GetPublicVersion ...
type MockSigningManager ¶
type MockSigningManager struct {
// contains filtered or unexported fields
}
MockSigningManager is mock signing manager
func (*MockSigningManager) Sign ¶
func (mgr *MockSigningManager) Sign(object []byte, key apicryptosuite.Key) ([]byte, error)
Sign will sign the given object using provided key
type MockUser ¶
type MockUser struct {
// contains filtered or unexported fields
}
MockUser ...
func (*MockUser) EnrollmentCertificate ¶
EnrollmentCertificate ... *
- Returns the underlying ECert representing this user’s identity.
func (*MockUser) GenerateTcerts ¶
GenerateTcerts ... *
- Gets a batch of TCerts to use for transaction. there is a 1-to-1 relationship between
- TCert and Transaction. The TCert can be generated locally by the SDK using the user’s crypto materials.
- @param {int} count how many in the batch to obtain
- @param {[]string} attributes list of attributes to include in the TCert
- @return {[]tcert} An array of TCerts
func (*MockUser) PrivateKey ¶
func (u *MockUser) PrivateKey() apicryptosuite.Key
PrivateKey ... *
- deprecated.
func (*MockUser) SetEnrollmentCertificate ¶
SetEnrollmentCertificate ... *
- Set the user’s Enrollment Certificate.
func (*MockUser) SetPrivateKey ¶
func (u *MockUser) SetPrivateKey(privateKey apicryptosuite.Key)
SetPrivateKey ... *
- deprecated.
Source Files
¶
- mockbroadcastserver.go
- mockchconfig.go
- mockchprovider.go
- mockconfig.go
- mockcontext.go
- mockcredentialmgr.go
- mockcryptosuite.go
- mockdata.go
- mockendorserserver.go
- mockeventhub.go
- mockeventserver.go
- mockidentity.go
- mockmsp.go
- mockmspmanager.go
- mockorderer.go
- mockpeer.go
- mockresource.go
- mocksigningmgr.go
- mockuser.go