mocks

package
v0.0.0-...-e171dc0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2018 License: Apache-2.0 Imports: 29 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 NewMockConfig

func NewMockConfig() config.Config

NewMockConfig ...

func NewMockConfigCustomized

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

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

func (c *MockClient) Channel(id string) fab.Channel

Channel ...

func (*MockClient) Config

func (c *MockClient) Config() config.Config

Config ...

func (*MockClient) CreateChannel

func (c *MockClient) CreateChannel(request fab.CreateChannelRequest) (apitxn.TransactionID, error)

CreateChannel ...

func (*MockClient) CryptoSuite

func (c *MockClient) CryptoSuite() bccsp.BCCSP

CryptoSuite ...

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

func (c *MockClient) QueryChannelInfo(name string, peers []fab.Peer) (fab.Channel, error)

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

func (*MockClient) StateStore

func (c *MockClient) StateStore() fab.KeyValueStore

StateStore ...

func (*MockClient) UserContext

func (c *MockClient) UserContext() fab.User

UserContext ...

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

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) 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 *x509.CertPool)

SetTLSCACertPool ...

func (*MockConfig) SoftVerify

func (c *MockConfig) SoftVerify() bool

SoftVerify flag

func (*MockConfig) TLSCACertPool

func (c *MockConfig) TLSCACertPool(tlsCertificate string) (*x509.CertPool, error)

TLSCACertPool ...

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

func (m *MockCryptoSuite) GetHash(opts bccsp.HashOpts) (h hash.Hash, err error)

GetHash mock get hash

func (*MockCryptoSuite) GetKey

func (m *MockCryptoSuite) GetKey(ski []byte) (k bccsp.Key, err error)

GetKey mock get key

func (*MockCryptoSuite) Hash

func (m *MockCryptoSuite) Hash(msg []byte, opts bccsp.HashOpts) (hash []byte, err error)

Hash mock hash

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

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

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

func (p *MockPeer) ProcessTransactionProposal(tp apitxn.TransactionProposal) (apitxn.TransactionProposalResult, error)

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 MockSigningManager

type MockSigningManager struct {
	// contains filtered or unexported fields
}

MockSigningManager is mock signing manager

func (*MockSigningManager) Sign

func (mgr *MockSigningManager) Sign(object []byte, key bccsp.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() bccsp.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 bccsp.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