Documentation ¶
Index ¶
- Constants
- Variables
- func IdentityFromFile(mspID string, file string, readFile ReadFile) (*identity.CertIdentity, error)
- func MustConvertFromBytes(bb []byte, target interface{}) interface{}
- func MustIdentityFromPem(mspID string, certPEM []byte) *identity.CertIdentity
- func MustJSONMarshal(val interface{}) []byte
- func MustProtoMarshal(pb proto.Message) []byte
- func MustProtoTimestamp(t time.Time) *timestamp.Timestamp
- func MustProtoUnmarshal(bb []byte, pm proto.Message) proto.Message
- func TransformCreator(txCreator ...interface{}) (mspID string, certPEM []byte, err error)
- type ChannelMockStubs
- type ChannelsMockStubs
- type CreatorTransformer
- type EventSubscription
- type Identities
- type MockStub
- func (stub *MockStub) AddTransient(transient map[string][]byte) *MockStub
- func (stub *MockStub) ClearEvents()
- func (stub *MockStub) DelPrivateData(collection string, key string) error
- func (stub *MockStub) EventSubscription() chan *peer.ChaincodeEvent
- func (stub *MockStub) From(txCreator ...interface{}) *MockStub
- func (stub *MockStub) GetArgs() [][]byte
- func (stub *MockStub) GetCreator() ([]byte, error)
- func (stub *MockStub) GetFunctionAndParameters() (function string, params []string)
- func (stub *MockStub) GetPrivateDataByPartialCompositeKey(collection, objectType string, attributes []string) (shim.StateQueryIteratorInterface, error)
- func (stub *MockStub) GetStringArgs() []string
- func (stub *MockStub) GetTransient() (map[string][]byte, error)
- func (stub *MockStub) Init(iargs ...interface{}) peer.Response
- func (stub *MockStub) InitBytes(args ...[]byte) peer.Response
- func (stub *MockStub) Invoke(funcName string, iargs ...interface{}) peer.Response
- func (stub *MockStub) InvokeBytes(args ...[]byte) peer.Response
- func (stub *MockStub) InvokeChaincode(chaincodeName string, args [][]byte, channel string) peer.Response
- func (stub *MockStub) MockCreator(mspID string, certPEM []byte)
- func (stub *MockStub) MockInit(uuid string, args [][]byte) peer.Response
- func (stub *MockStub) MockInvoke(uuid string, args [][]byte) peer.Response
- func (stub *MockStub) MockPeerChaincode(invokableChaincodeName string, otherStub *MockStub)
- func (stub *MockStub) MockQuery(uuid string, args [][]byte) peer.Response
- func (stub *MockStub) MockedPeerChaincodes() []string
- func (stub *MockStub) PutPrivateData(collection string, key string, value []byte) error
- func (stub *MockStub) Query(funcName string, iargs ...interface{}) peer.Response
- func (stub *MockStub) QueryBytes(args ...[]byte) peer.Response
- func (stub *MockStub) RegisterCreatorTransformer(creatorTransformer CreatorTransformer) *MockStub
- func (stub *MockStub) SetArgs(args [][]byte)
- func (stub *MockStub) SetEvent(name string, payload []byte) error
- func (stub *MockStub) WithTransient(transient map[string][]byte) *MockStub
- type MockedPeer
- func (mi *MockedPeer) Chaincode(channel string, chaincode string) (*MockStub, error)
- func (mi *MockedPeer) Invoke(ctx context.Context, from msp.SigningIdentity, channel string, ...) (*peer.Response, api.ChaincodeTx, error)
- func (mi *MockedPeer) Query(ctx context.Context, from msp.SigningIdentity, channel string, ...) (*peer.Response, error)
- func (mi *MockedPeer) Subscribe(ctx context.Context, from msp.SigningIdentity, channel, chaincode string) (api.EventCCSubscription, error)
- func (mi *MockedPeer) WithChannel(channel string, mockStubs ...*MockStub) *MockedPeer
- type PrivateMockStateRangeQueryIterator
- type ReadFile
- type TxHandler
- func (p *TxHandler) From(creator ...interface{}) *TxHandler
- func (p *TxHandler) Init(txHdl func() (interface{}, error)) *TxResult
- func (p *TxHandler) Invoke(invoke func() (interface{}, error)) *TxResult
- func (p *TxHandler) SvcExpect(res interface{}, err error) *expect.TxRes
- func (p *TxHandler) Tx(tx func())
- func (p *TxHandler) TxEvent() *peer.ChaincodeEvent
- func (p *TxHandler) TxTimestamp() *timestamp.Timestamp
- type TxResult
Constants ¶
const EventChannelBufferSize = 100
Variables ¶
var ( // ErrChaincodeNotExists occurs when attempting to invoke a nonexostent external chaincode ErrChaincodeNotExists = errors.New(`chaincode not exists`) // ErrUnknownFromArgsType occurs when attempting to set unknown args in From func ErrUnknownFromArgsType = errors.New(`unknown args type to cckit.MockStub.From func`) // ErrKeyAlreadyExistsInTransientMap occurs when attempting to set existing key in transient map ErrKeyAlreadyExistsInTransientMap = errors.New(`key already exists in transient map`) )
Functions ¶
func IdentityFromFile ¶ added in v0.5.2
IdentityFromFile returns Identity struct containing mspId and certificate
func MustConvertFromBytes ¶ added in v0.4.4
func MustConvertFromBytes(bb []byte, target interface{}) interface{}
func MustIdentityFromPem ¶ added in v0.4.5
func MustIdentityFromPem(mspID string, certPEM []byte) *identity.CertIdentity
func MustJSONMarshal ¶ added in v0.4.5
func MustJSONMarshal(val interface{}) []byte
func MustProtoMarshal ¶ added in v0.4.1
MustProtoMarshal marshals proto.Message, panics if error
func MustProtoTimestamp ¶ added in v0.4.1
MustProtoTimestamp, creates proto.Timestamp, panics if error
func MustProtoUnmarshal ¶ added in v0.4.3
MustProtoUnmarshal unmarshals proto.Message, panics if error
func TransformCreator ¶
TransformCreator transforms arbitrary tx creator (pmsp.SerializedIdentity etc) to mspID string, certPEM []byte,
Types ¶
type ChannelMockStubs ¶ added in v0.4.4
type ChannelsMockStubs ¶ added in v0.4.4
type ChannelsMockStubs map[string]ChannelMockStubs
type CreatorTransformer ¶
type EventSubscription ¶ added in v0.4.4
type EventSubscription struct {
// contains filtered or unexported fields
}
func (*EventSubscription) Close ¶ added in v0.4.4
func (es *EventSubscription) Close() error
func (*EventSubscription) Errors ¶ added in v0.4.4
func (es *EventSubscription) Errors() chan error
func (*EventSubscription) Events ¶ added in v0.4.4
func (es *EventSubscription) Events() chan *peer.ChaincodeEvent
type Identities ¶ added in v0.4.4
func IdentitiesFromFiles ¶ added in v0.4.4
func IdentitiesFromFiles(mspID string, files map[string]string, readFile ReadFile) (Identities, error)
IdentitiesFromFiles returns map of CertIdentity, loaded from PEM files
func IdentitiesFromPem ¶ added in v0.4.4
func IdentitiesFromPem(mspID string, certPEMs map[string][]byte) (ids Identities, err error)
IdentitiesFromPem returns CertIdentity (MSP ID and X.509 cert) converted PEM content
func MustIdentitiesFromFiles ¶ added in v0.4.5
func MustIdentitiesFromFiles(mspID string, files map[string]string, readFile ReadFile) Identities
MustIdentitiesFromFiles
type MockStub ¶
type MockStub struct { shim.MockStub ClearCreatorAfterInvoke bool InvokablesFull map[string]*MockStub // invokable this version of MockStub ChaincodeEvent *peer.ChaincodeEvent // event in last tx PrivateKeys map[string]*list.List // contains filtered or unexported fields }
MockStub replacement of shim.MockStub with creator mocking facilities
func NewMockStub ¶
NewMockStub creates chaincode imitation
func (*MockStub) AddTransient ¶ added in v0.4.5
AddTransient adds key-value pairs to transient map
func (*MockStub) ClearEvents ¶
func (stub *MockStub) ClearEvents()
ClearEvents clears chaincode events channel
func (*MockStub) DelPrivateData ¶ added in v0.5.0
DelPrivateData mocked
func (*MockStub) EventSubscription ¶
func (stub *MockStub) EventSubscription() chan *peer.ChaincodeEvent
func (*MockStub) GetFunctionAndParameters ¶
GetFunctionAndParameters mocked
func (*MockStub) GetPrivateDataByPartialCompositeKey ¶ added in v0.5.0
func (stub *MockStub) GetPrivateDataByPartialCompositeKey(collection, objectType string, attributes []string) (shim.StateQueryIteratorInterface, error)
GetPrivateDataByPartialCompositeKey mocked
func (*MockStub) GetStringArgs ¶
GetStringArgs get mocked args as strings
func (*MockStub) GetTransient ¶ added in v0.3.0
func (*MockStub) InvokeBytes ¶ added in v0.3.0
InvokeByte mock invoke with autogenerated tx uuid
func (*MockStub) InvokeChaincode ¶
func (stub *MockStub) InvokeChaincode(chaincodeName string, args [][]byte, channel string) peer.Response
InvokeChaincode using another MockStub
func (*MockStub) MockCreator ¶
MockCreator of tx
func (*MockStub) MockInvoke ¶
MockInvoke
func (*MockStub) MockPeerChaincode ¶
MockPeerChaincode link to another MockStub
func (*MockStub) MockedPeerChaincodes ¶ added in v0.4.5
MockedPeerChaincodes returns names of mocked chaincodes, available for invoke from current stub
func (*MockStub) PutPrivateData ¶ added in v0.5.0
PutPrivateData mocked
func (*MockStub) QueryBytes ¶ added in v0.4.1
QueryBytes mock query with autogenerated tx uuid
func (*MockStub) RegisterCreatorTransformer ¶
func (stub *MockStub) RegisterCreatorTransformer(creatorTransformer CreatorTransformer) *MockStub
RegisterCreatorTransformer that transforms creator data to MSP_ID and X.509 certificate
type MockedPeer ¶ added in v0.4.5
type MockedPeer struct { // channel name -> chaincode name ChannelCC ChannelsMockStubs // contains filtered or unexported fields }
func NewPeer ¶ added in v0.4.5
func NewPeer() *MockedPeer
NewInvoker implements Invoker interface from hlf-sdk-go
func (*MockedPeer) Chaincode ¶ added in v0.4.5
func (mi *MockedPeer) Chaincode(channel string, chaincode string) (*MockStub, error)
func (*MockedPeer) Subscribe ¶ added in v0.4.5
func (mi *MockedPeer) Subscribe( ctx context.Context, from msp.SigningIdentity, channel, chaincode string) (api.EventCCSubscription, error)
func (*MockedPeer) WithChannel ¶ added in v0.4.5
func (mi *MockedPeer) WithChannel(channel string, mockStubs ...*MockStub) *MockedPeer
type PrivateMockStateRangeQueryIterator ¶ added in v0.5.0
type PrivateMockStateRangeQueryIterator struct { Closed bool Stub *MockStub StartKey string EndKey string Current *list.Element Collection string }
func NewPrivateMockStateRangeQueryIterator ¶ added in v0.5.0
func NewPrivateMockStateRangeQueryIterator(stub *MockStub, collection string, startKey string, endKey string) *PrivateMockStateRangeQueryIterator
func (*PrivateMockStateRangeQueryIterator) Close ¶ added in v0.5.0
func (iter *PrivateMockStateRangeQueryIterator) Close() error
Close closes the range query iterator. This should be called when done reading from the iterator to free up resources.
func (*PrivateMockStateRangeQueryIterator) HasNext ¶ added in v0.5.0
func (iter *PrivateMockStateRangeQueryIterator) HasNext() bool
HasNext returns true if the range query iterator contains additional keys and values.
func (*PrivateMockStateRangeQueryIterator) Next ¶ added in v0.5.0
func (iter *PrivateMockStateRangeQueryIterator) Next() (*queryresult.KV, error)
Next returns the next key and value in the range query iterator.
func (*PrivateMockStateRangeQueryIterator) Print ¶ added in v0.5.0
func (iter *PrivateMockStateRangeQueryIterator) Print()
type TxHandler ¶ added in v0.6.7
type TxHandler struct { MockStub *MockStub Logger *shim.ChaincodeLogger }
func (*TxHandler) TxEvent ¶ added in v0.6.7
func (p *TxHandler) TxEvent() *peer.ChaincodeEvent
TxEvent returs last tx event
func (*TxHandler) TxTimestamp ¶ added in v0.6.7
TxEvent returs last tx timestamp