mocks

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2019 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCollDataReqMsg

func NewCollDataReqMsg(channelID string, reqID uint64, keys ...*store.Key) *protoext.SignedGossipMessage

NewCollDataReqMsg returns a mock collection data request message

func NewCollDataResMsg

func NewCollDataResMsg(channelID string, reqID uint64, keyVals ...*KeyVal) *protoext.SignedGossipMessage

NewCollDataResMsg returns a mock collection data response message

func NewDataMsg

func NewDataMsg(channelID string) *protoext.SignedGossipMessage

NewDataMsg returns a mock data message

func NewMember

func NewMember(endpoint string, pkiID []byte, roles ...string) discovery.NetworkMember

NewMember creates a new network member

Types

type BlockBuilder

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

BlockBuilder builds a mock Block

func NewBlockBuilder

func NewBlockBuilder(channelID string, blockNum uint64) *BlockBuilder

NewBlockBuilder returns a new mock BlockBuilder

func (*BlockBuilder) Build

func (b *BlockBuilder) Build() *cb.Block

Build builds the block

func (*BlockBuilder) ConfigUpdate

func (b *BlockBuilder) ConfigUpdate() *ConfigUpdateBuilder

ConfigUpdate adds a config update

func (*BlockBuilder) Transaction

func (b *BlockBuilder) Transaction(txID string, validationCode pb.TxValidationCode) *TxBuilder

Transaction adds a new transaction

type ChaincodeActionBuilder

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

ChaincodeActionBuilder builds a mock Chaincode Action

func NewChaincodeActionBuilder

func NewChaincodeActionBuilder(ccID, txID string) *ChaincodeActionBuilder

NewChaincodeActionBuilder returns a new ChaincodeActionBuilder

func (*ChaincodeActionBuilder) Build

func (b *ChaincodeActionBuilder) Build() []byte

Build builds the chaincode action

func (*ChaincodeActionBuilder) ChaincodeEvent

func (b *ChaincodeActionBuilder) ChaincodeEvent(eventName string, payload []byte) *ChaincodeActionBuilder

ChaincodeEvent adds a chaincode event to the chaincode action

func (*ChaincodeActionBuilder) Collection

Collection starts a new collection read/write set

func (*ChaincodeActionBuilder) Delete

Delete adds a KV write (with delete=true) to the read/write set

func (*ChaincodeActionBuilder) Read

Read adds a KV read to the read/write set

func (*ChaincodeActionBuilder) Response

func (b *ChaincodeActionBuilder) Response(response *pb.Response) *ChaincodeActionBuilder

Response sets the chaincode response

func (*ChaincodeActionBuilder) Write

func (b *ChaincodeActionBuilder) Write(key string, value []byte) *ChaincodeActionBuilder

Write adds a KV write to the read/write set

type CollectionBuilder

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

CollectionBuilder is a utility that builds a CollectionConfig and private data read/write sets for unit testing

func NewPvtReadWriteSetCollectionBuilder

func NewPvtReadWriteSetCollectionBuilder(name string) *CollectionBuilder

NewPvtReadWriteSetCollectionBuilder returns a new private read-write set collection builder

func (*CollectionBuilder) Build

Build builds the collection private read-write set

func (*CollectionBuilder) DCASConfig

func (c *CollectionBuilder) DCASConfig(policy string, requiredPeerCount, maximumPeerCount int32, ttl string) *CollectionBuilder

DCASConfig sets the DCAS collection config

func (*CollectionBuilder) Delete

func (c *CollectionBuilder) Delete(key string) *CollectionBuilder

Delete adds a new write with 'IsDelete=true' to the collection

func (*CollectionBuilder) OffLedgerConfig

func (c *CollectionBuilder) OffLedgerConfig(policy string, requiredPeerCount, maximumPeerCount int32, ttl string) *CollectionBuilder

OffLedgerConfig sets the off-ledger collection config

func (*CollectionBuilder) Read

func (c *CollectionBuilder) Read(key string, blockNum uint64, txIdx uint64) *CollectionBuilder

Read adds a new read to the collection

func (*CollectionBuilder) StaticConfig

func (c *CollectionBuilder) StaticConfig(policy string, requiredPeerCount, maximumPeerCount int32, btl uint64) *CollectionBuilder

StaticConfig sets the static collection config

func (*CollectionBuilder) TransientConfig

func (c *CollectionBuilder) TransientConfig(policy string, requiredPeerCount, maximumPeerCount int32, ttl string) *CollectionBuilder

TransientConfig sets the transient collection config

func (*CollectionBuilder) WithMarshalError

func (c *CollectionBuilder) WithMarshalError() *CollectionBuilder

WithMarshalError simulates a marshalling error

func (*CollectionBuilder) Write

func (c *CollectionBuilder) Write(key string, value []byte) *CollectionBuilder

Write adds a new write to the collection

type ConfigUpdateBuilder

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

ConfigUpdateBuilder builds a mock config update envelope

func NewConfigUpdateBuilder

func NewConfigUpdateBuilder(channelID string) *ConfigUpdateBuilder

NewConfigUpdateBuilder returns a new mock ConfigUpdateBuilder

func (*ConfigUpdateBuilder) Build

func (b *ConfigUpdateBuilder) Build() []byte

Build builds a config update envelope

type DataProvider

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

DataProvider is a mock transient data provider

func NewDataProvider

func NewDataProvider() *DataProvider

NewDataProvider returns a new Data Provider

func (*DataProvider) RetrieverForChannel

func (p *DataProvider) RetrieverForChannel(channel string) storeapi.Retriever

RetrieverForChannel returns the retriever for the given channel

func (*DataProvider) WithData

func (p *DataProvider) WithData(key *storeapi.Key, value *storeapi.ExpiringValue) *DataProvider

WithData sets the data to be returned by the retriever

func (*DataProvider) WithError

func (p *DataProvider) WithError(err error) *DataProvider

WithError sets the error to be returned by the retriever

func (*DataProvider) WithQueryResults

func (p *DataProvider) WithQueryResults(key *storeapi.QueryKey, results []*storeapi.QueryResult) *DataProvider

WithQueryResults sets the mock query results for the given query string

type DataStore

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

DataStore implements a mock data store

func NewDataStore

func NewDataStore() *DataStore

NewDataStore returns a mock transient data store

func (*DataStore) Close

func (m *DataStore) Close()

Close closes the store

func (*DataStore) Data

func (m *DataStore) Data(key *storeapi.Key, value *storeapi.ExpiringValue) *DataStore

Data sets the data for the given key

func (*DataStore) Error

func (m *DataStore) Error(err error) *DataStore

Error sets an err

func (*DataStore) GetData

func (m *DataStore) GetData(key *storeapi.Key) (*storeapi.ExpiringValue, error)

GetData gets the value for the given DCAS item

func (*DataStore) GetDataMultipleKeys

func (m *DataStore) GetDataMultipleKeys(key *storeapi.MultiKey) (storeapi.ExpiringValues, error)

GetDataMultipleKeys gets the values for the multiple DCAS items in a single call

func (*DataStore) GetTransientData

func (m *DataStore) GetTransientData(key *storeapi.Key) (*storeapi.ExpiringValue, error)

GetTransientData gets the value for the given transient data item

func (*DataStore) GetTransientDataMultipleKeys

func (m *DataStore) GetTransientDataMultipleKeys(key *storeapi.MultiKey) (storeapi.ExpiringValues, error)

GetTransientDataMultipleKeys gets the values for the multiple transient data items in a single call

func (*DataStore) Persist

func (m *DataStore) Persist(txid string, privateSimulationResultsWithConfig *proto.TxPvtReadWriteSetWithConfigInfo) error

Persist stores the private write set of a transaction along with the collection config in the transient store based on txid and the block height the private data was received at

func (*DataStore) PutData

func (m *DataStore) PutData(config *cb.StaticCollectionConfig, key *storeapi.Key, value *storeapi.ExpiringValue) error

PutData stores the key/value

func (*DataStore) Query

Query is not implemented and will panic if called.

func (*DataStore) TransientData

func (m *DataStore) TransientData(key *storeapi.Key, value *storeapi.ExpiringValue) *DataStore

TransientData sets the transient data for the given key

type KVIterator

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

KVIterator is a mock key-value iterator

func NewKVIterator

func NewKVIterator(kvs []*statedb.VersionedKV) *KVIterator

NewKVIterator returns a mock key-value iterator

func (*KVIterator) Close

func (it *KVIterator) Close()

Close releases resources occupied by the iterator

func (*KVIterator) Next

func (it *KVIterator) Next() (commonledger.QueryResult, error)

Next returns the next item in the result set. The `QueryResult` is expected to be nil when the iterator gets exhausted

func (*KVIterator) WithError

func (it *KVIterator) WithError(err error) *KVIterator

WithError injects an error

type KeyVal

type KeyVal struct {
	*store.Key
	*store.ExpiringValue
}

KeyVal stores a key and a value

func NewKeyValue

func NewKeyValue(key *store.Key, value *store.ExpiringValue) *KeyVal

NewKeyValue creates a new KeyVal

type Ledger

type Ledger struct {
	QueryExecutor  *QueryExecutor
	TxSimulator    *TxSimulator
	BlockchainInfo *common.BlockchainInfo
	Error          error
	BcInfoError    error
}

Ledger is a struct which is used to retrieve data using query

func (*Ledger) CheckpointBlock

func (m *Ledger) CheckpointBlock(block *common.Block) error

CheckpointBlock updates checkpoint info to given block

func (*Ledger) Close

func (m *Ledger) Close()

Close closes the ledger

func (*Ledger) CommitPvtDataOfOldBlocks

func (m *Ledger) CommitPvtDataOfOldBlocks(blockPvtData []*ledger2.BlockPvtData) ([]*ledger2.PvtdataHashMismatch, error)

CommitPvtDataOfOldBlocks commits the private data of old blocks

func (*Ledger) CommitWithPvtData

func (m *Ledger) CommitWithPvtData(blockAndPvtdata *ledger2.BlockAndPvtData) error

CommitWithPvtData commits the private data

func (*Ledger) GetBlockByHash

func (m *Ledger) GetBlockByHash(blockHash []byte) (*common.Block, error)

GetBlockByHash returns the block by hash

func (*Ledger) GetBlockByNumber

func (m *Ledger) GetBlockByNumber(blockNumber uint64) (*common.Block, error)

GetBlockByNumber returns the block by number

func (*Ledger) GetBlockByTxID

func (m *Ledger) GetBlockByTxID(txID string) (*common.Block, error)

GetBlockByTxID gets the block by transaction id

func (*Ledger) GetBlockchainInfo

func (m *Ledger) GetBlockchainInfo() (*common.BlockchainInfo, error)

GetBlockchainInfo returns the block chain info

func (*Ledger) GetBlocksIterator

func (m *Ledger) GetBlocksIterator(startBlockNumber uint64) (ledger.ResultsIterator, error)

GetBlocksIterator returns the block iterator

func (*Ledger) GetConfigHistoryRetriever

func (m *Ledger) GetConfigHistoryRetriever() (ledger2.ConfigHistoryRetriever, error)

GetConfigHistoryRetriever returns the config history retriever

func (*Ledger) GetMissingPvtDataTracker

func (m *Ledger) GetMissingPvtDataTracker() (ledger2.MissingPvtDataTracker, error)

GetMissingPvtDataTracker returns the private data tracker

func (*Ledger) GetPvtDataAndBlockByNum

func (m *Ledger) GetPvtDataAndBlockByNum(blockNum uint64, filter ledger2.PvtNsCollFilter) (*ledger2.BlockAndPvtData, error)

GetPvtDataAndBlockByNum gets private data and block by block number

func (*Ledger) GetPvtDataByNum

func (m *Ledger) GetPvtDataByNum(blockNum uint64, filter ledger2.PvtNsCollFilter) ([]*ledger2.TxPvtData, error)

GetPvtDataByNum gets private data by number

func (*Ledger) GetTransactionByID

func (m *Ledger) GetTransactionByID(txID string) (*peer.ProcessedTransaction, error)

GetTransactionByID gets the transaction by id

func (*Ledger) GetTxValidationCodeByTxID

func (m *Ledger) GetTxValidationCodeByTxID(txID string) (peer.TxValidationCode, error)

GetTxValidationCodeByTxID gets the validation code

func (*Ledger) NewHistoryQueryExecutor

func (m *Ledger) NewHistoryQueryExecutor() (ledger2.HistoryQueryExecutor, error)

NewHistoryQueryExecutor returns the history query executor

func (*Ledger) NewQueryExecutor

func (m *Ledger) NewQueryExecutor() (ledger2.QueryExecutor, error)

NewQueryExecutor returns the query executor

func (*Ledger) NewTxSimulator

func (m *Ledger) NewTxSimulator(txid string) (ledger2.TxSimulator, error)

NewTxSimulator returns the transaction simulator

type MessageHandler

type MessageHandler func(msg *gossipproto.GossipMessage)

MessageHandler defines a function that handles a gossip message.

type MockAccessPolicy

type MockAccessPolicy struct {
	ReqPeerCount int
	MaxPeerCount int
	Orgs         []string
	OnlyRead     bool
	OnlyWrite    bool
	Filter       privdata.Filter
}

MockAccessPolicy implements a mock CollectionAccessPolicy

func (*MockAccessPolicy) AccessFilter

func (m *MockAccessPolicy) AccessFilter() privdata.Filter

AccessFilter returns a member filter function for a collection

func (*MockAccessPolicy) IsMemberOnlyRead

func (m *MockAccessPolicy) IsMemberOnlyRead() bool

IsMemberOnlyRead returns a true if only collection members can read the private data

func (*MockAccessPolicy) IsMemberOnlyWrite

func (m *MockAccessPolicy) IsMemberOnlyWrite() bool

IsMemberOnlyWrite returns a true if only collection members can write the private data

func (*MockAccessPolicy) MaximumPeerCount

func (m *MockAccessPolicy) MaximumPeerCount() int

MaximumPeerCount The maximum number of peers that private data will be sent to upon endorsement. This number has to be bigger than RequiredPeerCount().

func (*MockAccessPolicy) MemberOrgs

func (m *MockAccessPolicy) MemberOrgs() []string

MemberOrgs returns the collection's members as MSP IDs. This serves as a human-readable way of quickly identifying who is part of a collection.

func (*MockAccessPolicy) RequiredPeerCount

func (m *MockAccessPolicy) RequiredPeerCount() int

RequiredPeerCount The minimum number of peers private data will be sent to upon endorsement. The endorsement would fail if dissemination to at least this number of peers is not achieved.

type MockBlockHandler

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

MockBlockHandler is a mock block handler

func NewMockBlockHandler

func NewMockBlockHandler() *MockBlockHandler

NewMockBlockHandler returns a mock Block Handler

func (*MockBlockHandler) HandleChaincodeEvent

func (m *MockBlockHandler) HandleChaincodeEvent(txMetadata api.TxMetadata, event *pb.ChaincodeEvent) error

HandleChaincodeEvent handle a chaincode event by incrementing the CC event counter

func (*MockBlockHandler) HandleChaincodeUpgradeEvent

func (m *MockBlockHandler) HandleChaincodeUpgradeEvent(txMetadata api.TxMetadata, chaincodeName string) error

HandleChaincodeUpgradeEvent handles a chaincode upgrade event by incrementing the chaincode upgrade counter

func (*MockBlockHandler) HandleConfigUpdate

func (m *MockBlockHandler) HandleConfigUpdate(blockNum uint64, configUpdate *cb.ConfigUpdate) error

HandleConfigUpdate handles a config update by incrementing the config update counter

func (*MockBlockHandler) HandleLSCCWrite

func (m *MockBlockHandler) HandleLSCCWrite(txMetadata api.TxMetadata, chaincodeName string, ccData *ccprovider.ChaincodeData, ccp *cb.CollectionConfigPackage) error

HandleLSCCWrite handles an LSCC write by incrementing the LSCC write counter

func (*MockBlockHandler) HandleRead

func (m *MockBlockHandler) HandleRead(txMetadata api.TxMetadata, namespace string, kvRead *kvrwset.KVRead) error

HandleRead handles a read event by incrementing the read counter

func (*MockBlockHandler) HandleWrite

func (m *MockBlockHandler) HandleWrite(txMetadata api.TxMetadata, namespace string, kvWrite *kvrwset.KVWrite) error

HandleWrite handles a write event by incrementing the write counter

func (*MockBlockHandler) NumCCEvents

func (m *MockBlockHandler) NumCCEvents() int

NumCCEvents returns the number of chaincode events handled

func (*MockBlockHandler) NumCCUpgradeEvents

func (m *MockBlockHandler) NumCCUpgradeEvents() int

NumCCUpgradeEvents returns the number of chaincode upgrades handled

func (*MockBlockHandler) NumConfigUpdates

func (m *MockBlockHandler) NumConfigUpdates() int

NumConfigUpdates returns the number of configuration updates handled

func (*MockBlockHandler) NumLSCCWrites

func (m *MockBlockHandler) NumLSCCWrites() int

NumLSCCWrites returns the number of LSCC writes handled

func (*MockBlockHandler) NumReads

func (m *MockBlockHandler) NumReads() int

NumReads returns the number of reads handled

func (*MockBlockHandler) NumWrites

func (m *MockBlockHandler) NumWrites() int

NumWrites returns the number of writes handled

func (*MockBlockHandler) WithError

func (m *MockBlockHandler) WithError(err error) *MockBlockHandler

WithError sets an error

type MockBlockPublisher

type MockBlockPublisher struct {
	HandleUpgrade      gossipapi.ChaincodeUpgradeHandler
	HandleConfigUpdate gossipapi.ConfigUpdateHandler
	HandleWrite        gossipapi.WriteHandler
	HandleRead         gossipapi.ReadHandler
	HandleLSCCWrite    gossipapi.LSCCWriteHandler
	HandleCCEvent      gossipapi.ChaincodeEventHandler
}

MockBlockPublisher is a mock block publisher

func NewBlockPublisher

func NewBlockPublisher() *MockBlockPublisher

NewBlockPublisher returns a mock block publisher

func (*MockBlockPublisher) AddCCEventHandler

func (m *MockBlockPublisher) AddCCEventHandler(handler gossipapi.ChaincodeEventHandler)

AddCCEventHandler adds a chaincode event handler

func (*MockBlockPublisher) AddCCUpgradeHandler

func (m *MockBlockPublisher) AddCCUpgradeHandler(handler gossipapi.ChaincodeUpgradeHandler)

AddCCUpgradeHandler adds a chaincode upgrade handler

func (*MockBlockPublisher) AddConfigUpdateHandler

func (m *MockBlockPublisher) AddConfigUpdateHandler(handler gossipapi.ConfigUpdateHandler)

AddConfigUpdateHandler adds a config update handler

func (*MockBlockPublisher) AddLSCCWriteHandler

func (m *MockBlockPublisher) AddLSCCWriteHandler(handler gossipapi.LSCCWriteHandler)

AddLSCCWriteHandler adds a write handler

func (*MockBlockPublisher) AddReadHandler

func (m *MockBlockPublisher) AddReadHandler(handler gossipapi.ReadHandler)

AddReadHandler adds a read handler

func (*MockBlockPublisher) AddWriteHandler

func (m *MockBlockPublisher) AddWriteHandler(handler gossipapi.WriteHandler)

AddWriteHandler adds a write handler

func (*MockBlockPublisher) LedgerHeight

func (m *MockBlockPublisher) LedgerHeight() uint64

LedgerHeight is not implemented and panics if invoked

func (*MockBlockPublisher) Publish

func (m *MockBlockPublisher) Publish(block *common.Block)

Publish is not implemented and panics if invoked

type MockBlockPublisherProvider

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

MockBlockPublisherProvider is a mock block publisher provider

func NewBlockPublisherProvider

func NewBlockPublisherProvider() *MockBlockPublisherProvider

NewBlockPublisherProvider returns a mock block publisher provider

func (*MockBlockPublisherProvider) ForChannel

func (m *MockBlockPublisherProvider) ForChannel(channelID string) gossipapi.BlockPublisher

ForChannel returns the mock block publisher

type MockGossipAdapter

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

MockGossipAdapter is the gossip adapter

func NewMockGossipAdapter

func NewMockGossipAdapter() *MockGossipAdapter

NewMockGossipAdapter returns the adapter

func (*MockGossipAdapter) IdentityInfo

func (m *MockGossipAdapter) IdentityInfo() gossipapi.PeerIdentitySet

IdentityInfo returns the identitySet of this adapter

func (*MockGossipAdapter) Member

Member adds the network member

func (*MockGossipAdapter) MemberWithNoPKIID

func (m *MockGossipAdapter) MemberWithNoPKIID(mspID string, member discovery.NetworkMember) *MockGossipAdapter

MemberWithNoPKIID appends the member

func (*MockGossipAdapter) MessageHandler

func (m *MockGossipAdapter) MessageHandler(handler MessageHandler) *MockGossipAdapter

MessageHandler sets the handler

func (*MockGossipAdapter) PeersOfChannel

PeersOfChannel returns the members

func (*MockGossipAdapter) Self

Self discovers a network member

func (*MockGossipAdapter) SelfMembershipInfo

func (m *MockGossipAdapter) SelfMembershipInfo() discovery.NetworkMember

SelfMembershipInfo returns self

func (*MockGossipAdapter) Send

func (m *MockGossipAdapter) Send(msg *gossipproto.GossipMessage, peers ...*comm.RemotePeer)

Send sends a message to remote peers

type MockReceivedMessage

type MockReceivedMessage struct {
	Message   *protoext.SignedGossipMessage
	RespondTo func(msg *gproto.GossipMessage)
	Member    discovery.NetworkMember
}

MockReceivedMessage mocks the Gossip received message

func (*MockReceivedMessage) Ack

func (m *MockReceivedMessage) Ack(err error)

Ack is a noop

func (*MockReceivedMessage) GetConnectionInfo

func (m *MockReceivedMessage) GetConnectionInfo() *protoext.ConnectionInfo

GetConnectionInfo returns the connection information of the source of the message

func (*MockReceivedMessage) GetGossipMessage

func (m *MockReceivedMessage) GetGossipMessage() *protoext.SignedGossipMessage

GetGossipMessage returns the mock signed gossip message

func (*MockReceivedMessage) GetSourceEnvelope

func (m *MockReceivedMessage) GetSourceEnvelope() *gproto.Envelope

GetSourceEnvelope is not implemented

func (*MockReceivedMessage) Respond

func (m *MockReceivedMessage) Respond(msg *gproto.GossipMessage)

Respond responds to the given request

type MockSupport

type MockSupport struct {
	CollPolicy  privdata.CollectionAccessPolicy
	CollConfigs []*cb.StaticCollectionConfig
	Err         error
	Publisher   *MockBlockPublisher
}

MockSupport is a holder of policy, config and error

func NewMockSupport

func NewMockSupport() *MockSupport

NewMockSupport returns a new MockSupport

func (*MockSupport) BlockPublisher

func (s *MockSupport) BlockPublisher(channelID string) gossipapi.BlockPublisher

BlockPublisher returns a mock block publisher for the given channel

func (*MockSupport) CollectionConfig

func (s *MockSupport) CollectionConfig(collConfig *cb.StaticCollectionConfig) *MockSupport

CollectionConfig sets the collection config for the given collection

func (*MockSupport) CollectionPolicy

func (s *MockSupport) CollectionPolicy(collPolicy privdata.CollectionAccessPolicy) *MockSupport

CollectionPolicy sets the collection access policy for the given collection

func (*MockSupport) Config

func (s *MockSupport) Config(channelID, ns, coll string) (*cb.StaticCollectionConfig, error)

Config returns the collection config for the given collection

func (*MockSupport) Policy

func (s *MockSupport) Policy(channelID, ns, coll string) (privdata.CollectionAccessPolicy, error)

Policy returns the collection access policy for the given collection

type NamespaceBuilder

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

NamespaceBuilder is a utility that builds a CollectionPvtReadWriteSet and CollectionConfigPackage for unit testing

func NewNamespaceBuilder

func NewNamespaceBuilder(name string) *NamespaceBuilder

NewNamespaceBuilder returns a new namespace builder

func (*NamespaceBuilder) BuildCollectionConfig

func (b *NamespaceBuilder) BuildCollectionConfig() *common.CollectionConfigPackage

BuildCollectionConfig builds the collection config package for the namespace

func (*NamespaceBuilder) BuildCollectionHashedRWSets

func (b *NamespaceBuilder) BuildCollectionHashedRWSets() []*rwset.CollectionHashedReadWriteSet

BuildCollectionHashedRWSets builds the collection-hashed read-write sets

func (*NamespaceBuilder) BuildNSReadWriteSets

func (b *NamespaceBuilder) BuildNSReadWriteSets() []byte

BuildNSReadWriteSets builds the read-write sets

func (*NamespaceBuilder) BuildReadWriteSets

func (b *NamespaceBuilder) BuildReadWriteSets() []*rwset.CollectionPvtReadWriteSet

BuildReadWriteSets builds the collection read-write sets for the namespace

func (*NamespaceBuilder) Collection

func (b *NamespaceBuilder) Collection(name string) *CollectionBuilder

Collection adds a new collection

func (*NamespaceBuilder) Delete

func (b *NamespaceBuilder) Delete(key string) *NamespaceBuilder

Delete adds a new write with 'IsDelete=true' to the namespace

func (*NamespaceBuilder) Read

func (b *NamespaceBuilder) Read(key string, blockNum uint64, txIdx uint64) *NamespaceBuilder

Read adds a new read to the namespace

func (*NamespaceBuilder) WithMarshalError

func (b *NamespaceBuilder) WithMarshalError() *NamespaceBuilder

WithMarshalError simulates a marshalling error

func (*NamespaceBuilder) Write

func (b *NamespaceBuilder) Write(key string, value []byte) *NamespaceBuilder

Write adds a new write to the namespace

type NamespaceRWSetBuilder

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

NamespaceRWSetBuilder builds a mock read/write set for a given namespace

func NewNamespaceRWSetBuilder

func NewNamespaceRWSetBuilder(ns string) *NamespaceRWSetBuilder

NewNamespaceRWSetBuilder returns a new namespace read/write set builder

func (*NamespaceRWSetBuilder) Build

Build builds a namespace read/write set

func (*NamespaceRWSetBuilder) Delete

Delete adds a KV write (with delete=true) to the read/write set

func (*NamespaceRWSetBuilder) Read

Read adds a KV read to the read/write set

func (*NamespaceRWSetBuilder) Write

func (b *NamespaceRWSetBuilder) Write(key string, value []byte) *NamespaceRWSetBuilder

Write adds a KV write to the read/write set

type PvtReadWriteSetBuilder

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

PvtReadWriteSetBuilder is a utility that builds a TxPvtReadWriteSetWithConfigInfo for unit testing

func NewPvtReadWriteSetBuilder

func NewPvtReadWriteSetBuilder() *PvtReadWriteSetBuilder

NewPvtReadWriteSetBuilder returns a new PvtReadWriteSetBuilder

func (*PvtReadWriteSetBuilder) Build

Build builds a TxPvtReadWriteSetWithConfigInfo

func (*PvtReadWriteSetBuilder) BuildCollectionConfigs

func (b *PvtReadWriteSetBuilder) BuildCollectionConfigs() map[string]*common.CollectionConfigPackage

BuildCollectionConfigs builds the collection config package

func (*PvtReadWriteSetBuilder) BuildReadWriteSet

func (b *PvtReadWriteSetBuilder) BuildReadWriteSet() *rwset.TxPvtReadWriteSet

BuildReadWriteSet builds the private read-write sets

func (*PvtReadWriteSetBuilder) Namespace

func (b *PvtReadWriteSetBuilder) Namespace(name string) *NamespaceBuilder

Namespace returns a new NamespaceBuilder

type QueryExecutor

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

QueryExecutor is a mock query executor

func NewQueryExecutor

func NewQueryExecutor() *QueryExecutor

NewQueryExecutor returns a new mock query executor

func (*QueryExecutor) Done

func (m *QueryExecutor) Done()

Done does nothing

func (*QueryExecutor) ExecuteQuery

func (m *QueryExecutor) ExecuteQuery(namespace, query string) (commonledger.ResultsIterator, error)

ExecuteQuery returns mock results for the given query

func (*QueryExecutor) ExecuteQueryOnPrivateData

func (m *QueryExecutor) ExecuteQueryOnPrivateData(namespace, collection, query string) (commonledger.ResultsIterator, error)

ExecuteQueryOnPrivateData returns mock results for the given query

func (*QueryExecutor) ExecuteQueryWithMetadata

func (m *QueryExecutor) ExecuteQueryWithMetadata(namespace, query string, metadata map[string]interface{}) (ledger.QueryResultsIterator, error)

ExecuteQueryWithMetadata is not currently implemented and will panic if called

func (*QueryExecutor) GetPrivateData

func (m *QueryExecutor) GetPrivateData(namespace, collection, key string) ([]byte, error)

GetPrivateData returns the private data for the given namespace, collection, and key

func (*QueryExecutor) GetPrivateDataHash

func (m *QueryExecutor) GetPrivateDataHash(namespace, collection, key string) ([]byte, error)

GetPrivateDataHash is not currently implemented and will panic if called

func (*QueryExecutor) GetPrivateDataMetadata

func (m *QueryExecutor) GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error)

GetPrivateDataMetadata is not currently implemented and will panic if called

func (*QueryExecutor) GetPrivateDataMetadataByHash

func (m *QueryExecutor) GetPrivateDataMetadataByHash(namespace, collection string, keyhash []byte) (map[string][]byte, error)

GetPrivateDataMetadataByHash is not currently implemented and will panic if called

func (*QueryExecutor) GetPrivateDataMultipleKeys

func (m *QueryExecutor) GetPrivateDataMultipleKeys(namespace, collection string, keys []string) ([][]byte, error)

GetPrivateDataMultipleKeys returns the private data for the given namespace, collection, and keys

func (*QueryExecutor) GetPrivateDataRangeScanIterator

func (m *QueryExecutor) GetPrivateDataRangeScanIterator(namespace, collection, startKey, endKey string) (commonledger.ResultsIterator, error)

GetPrivateDataRangeScanIterator is not currently implemented and will panic if called

func (*QueryExecutor) GetState

func (m *QueryExecutor) GetState(namespace string, key string) ([]byte, error)

GetState returns the mock state for the given namespace and key

func (*QueryExecutor) GetStateMetadata

func (m *QueryExecutor) GetStateMetadata(namespace, key string) (map[string][]byte, error)

GetStateMetadata is not currently implemented and will panic if called

func (*QueryExecutor) GetStateMultipleKeys

func (m *QueryExecutor) GetStateMultipleKeys(namespace string, keys []string) ([][]byte, error)

GetStateMultipleKeys returns the mock state for the given namespace and keys

func (*QueryExecutor) GetStateRangeScanIterator

func (m *QueryExecutor) GetStateRangeScanIterator(namespace string, startKey string, endKey string) (commonledger.ResultsIterator, error)

GetStateRangeScanIterator returns an iterator for mock results ranging from startKey (inclusive) to endKey (exclusive)

func (*QueryExecutor) GetStateRangeScanIteratorWithMetadata

func (m *QueryExecutor) GetStateRangeScanIteratorWithMetadata(namespace string, startKey, endKey string, metadata map[string]interface{}) (ledger.QueryResultsIterator, error)

GetStateRangeScanIteratorWithMetadata is not currently implemented and will panic if called

func (*QueryExecutor) WithDeletedPrivateState

func (m *QueryExecutor) WithDeletedPrivateState(ns, collection, key string) *QueryExecutor

WithDeletedPrivateState deletes the state

func (*QueryExecutor) WithDeletedState

func (m *QueryExecutor) WithDeletedState(ns, key string) *QueryExecutor

WithDeletedState deletes the state

func (*QueryExecutor) WithError

func (m *QueryExecutor) WithError(err error) *QueryExecutor

WithError injects an error to the mock executor

func (*QueryExecutor) WithIteratorProvider

func (m *QueryExecutor) WithIteratorProvider(p func() *ResultsIterator) *QueryExecutor

WithIteratorProvider sets the results iterator provider

func (*QueryExecutor) WithKVIteratorProvider

func (m *QueryExecutor) WithKVIteratorProvider(p func(kvs []*statedb.VersionedKV) *KVIterator) *QueryExecutor

WithKVIteratorProvider sets the KV iterator provider

func (*QueryExecutor) WithPrivateQueryResults

func (m *QueryExecutor) WithPrivateQueryResults(ns, coll, query string, results []*queryresult.KV) *QueryExecutor

WithPrivateQueryResults sets the query results for a given query on a private collection

func (*QueryExecutor) WithPrivateState

func (m *QueryExecutor) WithPrivateState(ns, collection, key string, value []byte) *QueryExecutor

WithPrivateState sets the private state

func (*QueryExecutor) WithQueryError

func (m *QueryExecutor) WithQueryError(err error) *QueryExecutor

WithQueryError injects an error to the mock executor for queries

func (*QueryExecutor) WithQueryResults

func (m *QueryExecutor) WithQueryResults(ns, query string, results []*queryresult.KV) *QueryExecutor

WithQueryResults sets the query results for a given query on a namespace

func (*QueryExecutor) WithState

func (m *QueryExecutor) WithState(ns, key string, value []byte) *QueryExecutor

WithState sets the state

type QueryExecutorProvider

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

QueryExecutorProvider is a mock query executor provider

func NewQueryExecutorProvider

func NewQueryExecutorProvider() *QueryExecutorProvider

NewQueryExecutorProvider returns a mock query executor provider

func (*QueryExecutorProvider) GetQueryExecutorForLedger

func (m *QueryExecutorProvider) GetQueryExecutorForLedger(channelID string) (ledger.QueryExecutor, error)

GetQueryExecutorForLedger returns the query executor for the given channel ID

func (*QueryExecutorProvider) WithError

WithError injects an error into the mock provider

func (*QueryExecutorProvider) WithMockQueryExecutor

func (m *QueryExecutorProvider) WithMockQueryExecutor(qe *QueryExecutor) *QueryExecutorProvider

WithMockQueryExecutor sets the mock query executor

type ReadWriteSetBuilder

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

ReadWriteSetBuilder is a utility that builds a TxReadWriteSet for unit testing

func NewReadWriteSetBuilder

func NewReadWriteSetBuilder() *ReadWriteSetBuilder

NewReadWriteSetBuilder returns a new ReadWriteSetBuilder

func (*ReadWriteSetBuilder) Build

Build builds the read-write sets

func (*ReadWriteSetBuilder) Namespace

func (b *ReadWriteSetBuilder) Namespace(name string) *NamespaceBuilder

Namespace returns a new NamespaceBuilder

type ResultsIterator

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

ResultsIterator is a mock key-value iterator

func NewResultsIterator

func NewResultsIterator() *ResultsIterator

NewResultsIterator returns a mock key-value iterator

func (*ResultsIterator) Close

func (m *ResultsIterator) Close()

Close releases resources occupied by the iterator

func (*ResultsIterator) Next

Next returns the next item in the result set. The `QueryResult` is expected to be nil when the iterator gets exhausted

func (*ResultsIterator) WithError

func (m *ResultsIterator) WithError(err error) *ResultsIterator

WithError injects an error

func (*ResultsIterator) WithResults

func (m *ResultsIterator) WithResults(results []*queryresult.KV) *ResultsIterator

WithResults sets the mock results

type TxBuilder

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

TxBuilder builds a mock Transaction

func NewTxBuilder

func NewTxBuilder(channelID, txID string, validationCode pb.TxValidationCode) *TxBuilder

NewTxBuilder returns a new mock TxBuilder

func (*TxBuilder) Build

func (b *TxBuilder) Build() ([]byte, pb.TxValidationCode)

Build builds a transaction

func (*TxBuilder) ChaincodeAction

func (b *TxBuilder) ChaincodeAction(ccID string) *ChaincodeActionBuilder

ChaincodeAction adds a chaincode action to the transaction

type TxSimulator

type TxSimulator struct {
	ledgermocks.MockQueryExecutor
	SimulationResults *ledger.TxSimulationResults
	Error             error
	SimError          error
}

TxSimulator implements a mock transaction simulator

func (*TxSimulator) DeletePrivateData

func (m *TxSimulator) DeletePrivateData(namespace, collection, key string) error

DeletePrivateData is not currently implemented and will panic if called

func (*TxSimulator) DeletePrivateDataMetadata

func (m *TxSimulator) DeletePrivateDataMetadata(namespace, collection, key string) error

DeletePrivateDataMetadata is not currently implemented and will panic if called

func (*TxSimulator) DeleteState

func (m *TxSimulator) DeleteState(namespace string, key string) error

DeleteState is not currently implemented and will panic if called

func (*TxSimulator) DeleteStateMetadata

func (m *TxSimulator) DeleteStateMetadata(namespace, key string) error

DeleteStateMetadata is not currently implemented and will panic if called

func (*TxSimulator) ExecuteUpdate

func (m *TxSimulator) ExecuteUpdate(query string) error

ExecuteUpdate is not currently implemented and will panic if called

func (*TxSimulator) GetTxSimulationResults

func (m *TxSimulator) GetTxSimulationResults() (*ledger.TxSimulationResults, error)

GetTxSimulationResults returns the mock simulation results

func (*TxSimulator) SetPrivateData

func (m *TxSimulator) SetPrivateData(namespace, collection, key string, value []byte) error

SetPrivateData is not currently implemented and will panic if called

func (*TxSimulator) SetPrivateDataMetadata

func (m *TxSimulator) SetPrivateDataMetadata(namespace, collection, key string, metadata map[string][]byte) error

SetPrivateDataMetadata is not currently implemented and will panic if called

func (*TxSimulator) SetPrivateDataMultipleKeys

func (m *TxSimulator) SetPrivateDataMultipleKeys(namespace, collection string, kvs map[string][]byte) error

SetPrivateDataMultipleKeys currently does nothing except return the mock error (if any)

func (*TxSimulator) SetState

func (m *TxSimulator) SetState(namespace string, key string, value []byte) error

SetState is not currently implemented and will panic if called

func (*TxSimulator) SetStateMetadata

func (m *TxSimulator) SetStateMetadata(namespace, key string, metadata map[string][]byte) error

SetStateMetadata is not currently implemented and will panic if called

func (*TxSimulator) SetStateMultipleKeys

func (m *TxSimulator) SetStateMultipleKeys(namespace string, kvs map[string][]byte) error

SetStateMultipleKeys is not currently implemented and will panic if called

Jump to

Keyboard shortcuts

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