mocks

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 NewMockChannelCfg

func NewMockChannelCfg(name string) fab.ChannelCfg

NewMockChannelCfg ...

func NewMockConfig

func NewMockConfig() config.Config

NewMockConfig ...

func NewMockConfigCustomized

func NewMockConfigCustomized(tlsEnabled, mutualTLSEnabled, errorCase bool) config.Config

NewMockConfigCustomized ...

func NewMockCredentialManager

func NewMockCredentialManager(orgName string, config apiconfig.Config, cryptoProvider apicryptosuite.CryptoSuite) (apifabclient.CredentialManager, error)

NewMockCredentialManager Constructor for a credential manager.

func NewMockIdentity

func NewMockIdentity(err error) (msp.Identity, error)

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 NewMockUser

func NewMockUser(name string) ca.User

NewMockUser ... *

  • Constructor for a user. *
  • @param {string} name - The user name

func NewMockUserWithMSPID

func NewMockUserWithMSPID(name string, mspid string) ca.User

NewMockUserWithMSPID to return mock user with MSP ids

func NewSimpleMockBlock

func NewSimpleMockBlock() *common.Block

NewSimpleMockBlock returns a simple mock block

func NewSimpleMockError

func NewSimpleMockError() error

NewSimpleMockError returns a error

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

Broadcast mock broadcast

func (*MockBroadcastServer) Deliver

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) Msps

func (cfg *MockChannelCfg) Msps() []*msp.MSPConfig

Msps returns msps

func (*MockChannelCfg) Name

func (cfg *MockChannelCfg) Name() string

Name returns name

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) Client

func (c *MockConfig) Client() (*config.ClientConfig, error)

Client ...

func (*MockConfig) CryptoConfigPath

func (c *MockConfig) CryptoConfigPath() string

CryptoConfigPath ...

func (*MockConfig) Ephemeral

func (c *MockConfig) Ephemeral() bool

Ephemeral flag

func (*MockConfig) IsSecurityEnabled

func (c *MockConfig) IsSecurityEnabled() bool

IsSecurityEnabled ...

func (*MockConfig) KeyStorePath

func (c *MockConfig) KeyStorePath() string

KeyStorePath ...

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) SecurityLevel

func (c *MockConfig) SecurityLevel() int

SecurityLevel ...

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) SoftVerify

func (c *MockConfig) SoftVerify() bool

SoftVerify flag

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) TcertBatchSize

func (c *MockConfig) TcertBatchSize() int

TcertBatchSize ...

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

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

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

type MockEndorserServer struct {
	ProposalError error
	AddkvWrite    bool
}

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) Connect

func (m *MockEventHub) Connect() error

Connect not implemented

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

Chat for event chatting

func (*MockEventServer) SendMockEvent

func (m *MockEventServer) SendMockEvent(event *pb.Event)

SendMockEvent used for sending mock events to event server

func (*MockEventServer) Stop

func (m *MockEventServer) Stop()

Stop mock event

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

func (*MockIdentity) Verify

func (id *MockIdentity) Verify(msg []byte, sig []byte) error

Verify checks against a signature and a message to determine whether this identity produced the signature; it returns nil if so or an error otherwise

type MockMSP

type MockMSP struct {
	Err error
}

MockMSP implements mock msp

func NewMockMSP

func NewMockMSP(err error) *MockMSP

NewMockMSP creates mock msp

func (*MockMSP) DeserializeIdentity

func (m *MockMSP) DeserializeIdentity(serializedIdentity []byte) (msp.Identity, error)

DeserializeIdentity mocks deserialize identity

func (*MockMSP) GetDefaultSigningIdentity

func (m *MockMSP) GetDefaultSigningIdentity() (msp.SigningIdentity, error)

GetDefaultSigningIdentity returns the default signing identity

func (*MockMSP) GetIdentifier

func (m *MockMSP) GetIdentifier() (string, error)

GetIdentifier returns the provider identifier

func (*MockMSP) GetMSPs

func (m *MockMSP) GetMSPs() (map[string]msp.MSP, error)

GetMSPs Provides a list of Membership Service providers

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

func (m *MockMSP) GetTLSIntermediateCerts() [][]byte

GetTLSIntermediateCerts returns the TLS intermediate root certificates for this MSP

func (*MockMSP) GetTLSRootCerts

func (m *MockMSP) GetTLSRootCerts() [][]byte

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.

func (*MockMSP) Setup

func (m *MockMSP) Setup(config *msp_protos.MSPConfig) error

Setup the MSP instance according to configuration information

func (*MockMSP) Validate

func (m *MockMSP) Validate(id msp.Identity) error

Validate checks whether the supplied identity is valid

type MockMSPManager

type MockMSPManager struct {
	MSPs map[string]msp.MSP
	Err  error
}

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

func (*MockMSPManager) Setup

func (mgr *MockMSPManager) Setup(msps []msp.MSP) error

Setup the MSP manager instance according to configuration information

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

func NewMockPeer(name string, url string) *MockPeer

NewMockPeer creates basic mock peer

func (*MockPeer) EnrollmentCertificate

func (p *MockPeer) EnrollmentCertificate() *pem.Block

EnrollmentCertificate returns the mock peer's mock enrollment certificate

func (*MockPeer) MSPID

func (p *MockPeer) MSPID() string

MSPID gets the Peer mspID.

func (MockPeer) Name

func (p MockPeer) Name() string

Name returns the mock peer's mock name

func (*MockPeer) ProcessTransactionProposal

ProcessTransactionProposal does not send anything anywhere but returns an empty mock ProposalResponse

func (*MockPeer) Roles

func (p *MockPeer) Roles() []string

Roles returns the mock peer's mock roles

func (*MockPeer) SetEnrollmentCertificate

func (p *MockPeer) SetEnrollmentCertificate(pem *pem.Block)

SetEnrollmentCertificate sets the mock peer's mock enrollment certificate

func (*MockPeer) SetMSPID

func (p *MockPeer) SetMSPID(mspID string)

SetMSPID sets the Peer mspID.

func (*MockPeer) SetName

func (p *MockPeer) SetName(name string)

SetName sets the mock peer's mock name

func (*MockPeer) SetRoles

func (p *MockPeer) SetRoles(roles []string)

SetRoles sets the mock peer's mock roles

func (*MockPeer) URL

func (p *MockPeer) URL() string

URL returns the mock peer's mock URL

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

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 NewMockResource

func NewMockResource() *MockResource

NewMockResource ...

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

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 ...

func (*MockSigningIdentity) Sign

func (id *MockSigningIdentity) Sign(msg []byte) ([]byte, error)

Sign produces a signature over msg, signed by this instance

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

func (u *MockUser) EnrollmentCertificate() []byte

EnrollmentCertificate ... *

  • Returns the underlying ECert representing this user’s identity.

func (*MockUser) GenerateTcerts

func (u *MockUser) GenerateTcerts(count int, attributes []string)

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) Identity

func (u *MockUser) Identity() ([]byte, error)

Identity returns MockUser's serialized identity

func (*MockUser) MspID

func (u *MockUser) MspID() string

MspID returns the MSP for this user

func (*MockUser) Name

func (u *MockUser) Name() string

Name ... *

  • Get the user name.
  • @returns {string} The user name.

func (*MockUser) PrivateKey

func (u *MockUser) PrivateKey() apicryptosuite.Key

PrivateKey ... *

  • deprecated.

func (*MockUser) Roles

func (u *MockUser) Roles() []string

Roles ... *

  • Get the roles.
  • @returns {[]string} The roles.

func (*MockUser) SetEnrollmentCertificate

func (u *MockUser) SetEnrollmentCertificate(cert []byte)

SetEnrollmentCertificate ... *

  • Set the user’s Enrollment Certificate.

func (*MockUser) SetMspID

func (u *MockUser) SetMspID(mspID string)

SetMspID sets the MSP for this user

func (*MockUser) SetPrivateKey

func (u *MockUser) SetPrivateKey(privateKey apicryptosuite.Key)

SetPrivateKey ... *

  • deprecated.

func (*MockUser) SetRoles

func (u *MockUser) SetRoles(roles []string)

SetRoles ... *

  • Set the roles.
  • @param roles {[]string} The roles.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL