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 NewMockConfig() config.Config
- func NewMockConfigCustomized(tlsEnabled bool, errorCase bool) config.Config
- func NewMockOrderer(url string, broadcastListener chan *fab.SignedEnvelope) fab.Orderer
- func NewMockSigningManager() apifabclient.SigningManager
- func NewMockUser(name string) ca.User
- func NewMockUserWithMSPID(name string, mspid string) ca.User
- func NewSimpleMockBlock() *common.Block
- func NewSimpleMockError() error
- type MockBroadcastServer
- type MockClient
- func (c *MockClient) Channel(id string) fab.Channel
- func (c *MockClient) Config() config.Config
- func (c *MockClient) CreateChannel(request fab.CreateChannelRequest) (apitxn.TransactionID, error)
- func (c *MockClient) CryptoSuite() bccsp.BCCSP
- func (c *MockClient) ExtractChannelConfig(configEnvelope []byte) ([]byte, error)
- func (c *MockClient) InstallChaincode(chaincodeName string, chaincodePath string, chaincodeVersion string, ...) ([]*apitxn.TransactionProposalResponse, string, error)
- func (c *MockClient) LoadUserFromStateStore(name string) (fab.User, error)
- func (c *MockClient) NewChannel(name string) (fab.Channel, error)
- func (c *MockClient) NewTxnID() (apitxn.TransactionID, error)
- func (c *MockClient) QueryChannelInfo(name string, peers []fab.Peer) (fab.Channel, error)
- func (c *MockClient) QueryChannels(peer fab.Peer) (*pb.ChannelQueryResponse, error)
- func (c *MockClient) QueryInstalledChaincodes(peer fab.Peer) (*pb.ChaincodeQueryResponse, error)
- func (c *MockClient) SaveUserToStateStore(user fab.User, skipPersistence bool) error
- func (c *MockClient) SetCryptoSuite(cryptoSuite bccsp.BCCSP)
- func (c *MockClient) SetSigningManager(signingMgr fab.SigningManager)
- func (c *MockClient) SetStateStore(stateStore fab.KeyValueStore)
- func (c *MockClient) SetUserContext(user fab.User)
- func (c *MockClient) SignChannelConfig(config []byte) (*common.ConfigSignature, error)
- func (c *MockClient) SigningManager() fab.SigningManager
- func (c *MockClient) StateStore() fab.KeyValueStore
- func (c *MockClient) UserContext() fab.User
- type MockConfig
- func (c *MockConfig) CAClientCertFile(org string) (string, error)
- func (c *MockConfig) CAClientKeyFile(org string) (string, error)
- func (c *MockConfig) CAConfig(org string) (*config.CAConfig, error)
- func (c *MockConfig) CAKeyStorePath() string
- func (c *MockConfig) CAServerCertFiles(org string) ([]string, error)
- func (c *MockConfig) CSPConfig() *bccspFactory.FactoryOpts
- func (c *MockConfig) ChannelConfig(name string) (*config.ChannelConfig, 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) 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) 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 *x509.CertPool)
- func (c *MockConfig) SoftVerify() bool
- func (c *MockConfig) TLSCACertPool(tlsCertificate string) (*x509.CertPool, error)
- func (c *MockConfig) TcertBatchSize() int
- func (c *MockConfig) TimeoutOrDefault(arg config.TimeoutType) time.Duration
- type MockConfigBlockBuilder
- type MockConfigGroupBuilder
- type MockConfigUpdateEnvelopeBuilder
- type MockCryptoSuite
- func (m *MockCryptoSuite) Decrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error)
- func (m *MockCryptoSuite) Encrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) (ciphertext []byte, err error)
- func (m *MockCryptoSuite) GetHash(opts bccsp.HashOpts) (h hash.Hash, err error)
- func (m *MockCryptoSuite) GetKey(ski []byte) (k bccsp.Key, err error)
- func (m *MockCryptoSuite) Hash(msg []byte, opts bccsp.HashOpts) (hash []byte, err error)
- func (m *MockCryptoSuite) KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error)
- func (m *MockCryptoSuite) KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error)
- func (m *MockCryptoSuite) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error)
- func (m *MockCryptoSuite) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signature []byte, err error)
- func (m *MockCryptoSuite) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error)
- type MockEndorserServer
- type MockEventServer
- 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 apitxn.TransactionProposal) (apitxn.TransactionProposalResult, 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 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() bccsp.Key
- func (u *MockUser) Roles() []string
- func (u *MockUser) SetEnrollmentCertificate(cert []byte)
- func (u *MockUser) SetMspID(mspID string)
- func (u *MockUser) SetPrivateKey(privateKey bccsp.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 NewMockOrderer ¶
func NewMockOrderer(url string, broadcastListener chan *fab.SignedEnvelope) fab.Orderer
NewMockOrderer ...
func NewMockSigningManager ¶
func NewMockSigningManager() apifabclient.SigningManager
NewMockSigningManager Constructor for a mock signing manager.
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 MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient ...
func NewMockClient ¶
func NewMockClient() *MockClient
NewMockClient ...
- Returns a FabricClient instance
func NewMockInvalidClient ¶
func NewMockInvalidClient() *MockClient
NewMockInvalidClient : Returns new Mock FabricClient with error flag on used to test invalid scenarios
func (*MockClient) CreateChannel ¶
func (c *MockClient) CreateChannel(request fab.CreateChannelRequest) (apitxn.TransactionID, error)
CreateChannel ...
func (*MockClient) ExtractChannelConfig ¶
func (c *MockClient) ExtractChannelConfig(configEnvelope []byte) ([]byte, error)
ExtractChannelConfig ...
func (*MockClient) InstallChaincode ¶
func (c *MockClient) InstallChaincode(chaincodeName string, chaincodePath string, chaincodeVersion string, chaincodePackage []byte, targets []fab.Peer) ([]*apitxn.TransactionProposalResponse, string, error)
InstallChaincode ...
func (*MockClient) LoadUserFromStateStore ¶
func (c *MockClient) LoadUserFromStateStore(name string) (fab.User, error)
LoadUserFromStateStore ...
func (*MockClient) NewChannel ¶
func (c *MockClient) NewChannel(name string) (fab.Channel, error)
NewChannel ...
func (*MockClient) NewTxnID ¶
func (c *MockClient) NewTxnID() (apitxn.TransactionID, error)
NewTxnID computes a TransactionID for the current user context
func (*MockClient) QueryChannelInfo ¶
QueryChannelInfo ...
func (*MockClient) QueryChannels ¶
func (c *MockClient) QueryChannels(peer fab.Peer) (*pb.ChannelQueryResponse, error)
QueryChannels ...
func (*MockClient) QueryInstalledChaincodes ¶
func (c *MockClient) QueryInstalledChaincodes(peer fab.Peer) (*pb.ChaincodeQueryResponse, error)
QueryInstalledChaincodes ...
func (*MockClient) SaveUserToStateStore ¶
func (c *MockClient) SaveUserToStateStore(user fab.User, skipPersistence bool) error
SaveUserToStateStore ...
func (*MockClient) SetCryptoSuite ¶
func (c *MockClient) SetCryptoSuite(cryptoSuite bccsp.BCCSP)
SetCryptoSuite ...
func (*MockClient) SetSigningManager ¶
func (c *MockClient) SetSigningManager(signingMgr fab.SigningManager)
SetSigningManager mocks setting signing manager
func (*MockClient) SetStateStore ¶
func (c *MockClient) SetStateStore(stateStore fab.KeyValueStore)
SetStateStore ...
func (*MockClient) SetUserContext ¶
func (c *MockClient) SetUserContext(user fab.User)
SetUserContext ...
func (*MockClient) SignChannelConfig ¶
func (c *MockClient) SignChannelConfig(config []byte) (*common.ConfigSignature, error)
SignChannelConfig ...
func (*MockClient) SigningManager ¶
func (c *MockClient) SigningManager() fab.SigningManager
SigningManager returns the signing manager
type MockConfig ¶
type MockConfig struct {
// contains filtered or unexported fields
}
MockConfig ...
func (*MockConfig) CAClientCertFile ¶
func (c *MockConfig) CAClientCertFile(org string) (string, error)
CAClientCertFile Read configuration option for the fabric CA client cert file
func (*MockConfig) CAClientKeyFile ¶
func (c *MockConfig) CAClientKeyFile(org string) (string, error)
CAClientKeyFile Read configuration option for the fabric CA client key file
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) CAServerCertFiles ¶
func (c *MockConfig) CAServerCertFiles(org string) ([]string, error)
CAServerCertFiles Read configuration option for the server certificate files
func (*MockConfig) CSPConfig ¶
func (c *MockConfig) CSPConfig() *bccspFactory.FactoryOpts
CSPConfig ...
func (*MockConfig) ChannelConfig ¶
func (c *MockConfig) ChannelConfig(name string) (*config.ChannelConfig, error)
ChannelConfig returns the channel configuration
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) NetworkConfig ¶
func (c *MockConfig) NetworkConfig() (*config.NetworkConfig, error)
NetworkConfig not implemented
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) 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 *x509.CertPool)
SetTLSCACertPool ...
func (*MockConfig) TLSCACertPool ¶
func (c *MockConfig) TLSCACertPool(tlsCertificate string) (*x509.CertPool, error)
TLSCACertPool ...
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 MockCryptoSuite ¶
type MockCryptoSuite struct { }
MockCryptoSuite implementation
func (*MockCryptoSuite) Decrypt ¶
func (m *MockCryptoSuite) Decrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error)
Decrypt mock decrypt
func (*MockCryptoSuite) Encrypt ¶
func (m *MockCryptoSuite) Encrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) (ciphertext []byte, err error)
Encrypt mock encrypt
func (*MockCryptoSuite) GetKey ¶
func (m *MockCryptoSuite) GetKey(ski []byte) (k bccsp.Key, err error)
GetKey mock get key
func (*MockCryptoSuite) KeyDeriv ¶
func (m *MockCryptoSuite) KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error)
KeyDeriv mock key derivation
func (*MockCryptoSuite) KeyGen ¶
func (m *MockCryptoSuite) KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error)
KeyGen mock key gen
func (*MockCryptoSuite) KeyImport ¶
func (m *MockCryptoSuite) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error)
KeyImport mock key import
func (*MockCryptoSuite) Sign ¶
func (m *MockCryptoSuite) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signature []byte, err error)
Sign mock signing
func (*MockCryptoSuite) Verify ¶
func (m *MockCryptoSuite) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error)
Verify mock verify
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 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 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 { MockName string MockURL string MockRoles []string MockCert *pem.Block Payload []byte MockMSP string }
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 apitxn.TransactionProposal) (apitxn.TransactionProposalResult, 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 MockSigningManager ¶
type MockSigningManager struct {
// contains filtered or unexported fields
}
MockSigningManager is mock signing manager
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) SetEnrollmentCertificate ¶
SetEnrollmentCertificate ... *
- Set the user’s Enrollment Certificate.