Documentation ¶
Index ¶
- Constants
- Variables
- func MustConvertFromBytes(bb []byte, target interface{}) interface{}
- 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 CCService
- type ChannelMockStubs
- type ChannelsMockStubs
- type CreatorTransformer
- type EventSubscription
- type Identities
- func IdentitiesFromFiles(mspID string, files map[string]string, getContent identity.GetContent) (Identities, error)
- func IdentitiesFromPem(mspID string, certPEMs map[string][]byte) (ids Identities, err error)
- func MustIdentitiesFromFiles(mspID string, files map[string]string, getContent identity.GetContent) Identities
- type Identity
- func (i *Identity) Anonymous() bool
- func (i *Identity) ExpiresAt() time.Time
- func (i *Identity) GetID() string
- func (i *Identity) GetIdentifier() *msp.IdentityIdentifier
- func (i *Identity) GetMSPIdentifier() string
- func (i *Identity) GetOrganizationalUnits() []*msp.OUIdentifier
- func (i *Identity) GetPEM() []byte
- func (i *Identity) GetPublicVersion() msp.Identity
- func (i *Identity) GetSubject() string
- func (i *Identity) SatisfiesPrincipal(principal *msppb.MSPPrincipal) error
- func (i *Identity) Serialize() ([]byte, error)
- func (i *Identity) Sign(msg []byte) ([]byte, error)
- func (i *Identity) Validate() error
- func (i *Identity) Verify(msg []byte, sig []byte) error
- 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 TxMiddleware
- 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 MustConvertFromBytes ¶
func MustConvertFromBytes(bb []byte, target interface{}) interface{}
func MustJSONMarshal ¶
func MustJSONMarshal(val interface{}) []byte
func MustProtoMarshal ¶
MustProtoMarshal marshals proto.Message, panics if error
func MustProtoTimestamp ¶
MustProtoTimestamp, creates proto.Timestamp, panics if error
func MustProtoUnmarshal ¶
MustProtoUnmarshal unmarshals proto.Message, panics if error
func TransformCreator ¶
TransformCreator transforms arbitrary tx creator (pmsp.SerializedIdentity etc) to mspID string, certPEM []byte,
Types ¶
type CCService ¶
type CCService struct { MockStub *MockStub Logger *shim.ChaincodeLogger }
func NewCCService ¶
type ChannelMockStubs ¶
type ChannelsMockStubs ¶
type ChannelsMockStubs map[string]ChannelMockStubs
type CreatorTransformer ¶
type EventSubscription ¶
type EventSubscription struct {
// contains filtered or unexported fields
}
func (*EventSubscription) Close ¶
func (es *EventSubscription) Close() error
func (*EventSubscription) Errors ¶
func (es *EventSubscription) Errors() chan error
func (*EventSubscription) Events ¶
func (es *EventSubscription) Events() chan *peer.ChaincodeEvent
type Identities ¶
func IdentitiesFromFiles ¶
func IdentitiesFromFiles(mspID string, files map[string]string, getContent identity.GetContent) (Identities, error)
IdentitiesFromFiles returns map of CertIdentity, loaded from PEM files
func IdentitiesFromPem ¶
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 ¶
func MustIdentitiesFromFiles(mspID string, files map[string]string, getContent identity.GetContent) Identities
MustIdentitiesFromFiles
type Identity ¶
type Identity struct { MspId string Certificate *x509.Certificate }
implements msp.SigningIdentity
func IdentityFromFile ¶
IdentityFromFile returns Identity struct containing mspId and certificate
func MustIdentityFromPem ¶
func NewIdentity ¶
func NewIdentity(mspID string, cert *x509.Certificate) *Identity
func (*Identity) GetIdentifier ¶
func (i *Identity) GetIdentifier() *msp.IdentityIdentifier
func (*Identity) GetMSPIdentifier ¶
GetMSPIdentifier returns current MspID of identity
func (*Identity) GetOrganizationalUnits ¶
func (i *Identity) GetOrganizationalUnits() []*msp.OUIdentifier
func (*Identity) GetPublicVersion ¶
func (*Identity) GetSubject ¶
func (*Identity) SatisfiesPrincipal ¶
func (i *Identity) SatisfiesPrincipal(principal *msppb.MSPPrincipal) error
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 ¶
AddTransient adds key-value pairs to transient map
func (*MockStub) ClearEvents ¶
func (stub *MockStub) ClearEvents()
ClearEvents clears chaincode events channel
func (*MockStub) DelPrivateData ¶
DelPrivateData mocked
func (*MockStub) EventSubscription ¶
func (stub *MockStub) EventSubscription() chan *peer.ChaincodeEvent
func (*MockStub) GetFunctionAndParameters ¶
GetFunctionAndParameters mocked
func (*MockStub) GetPrivateDataByPartialCompositeKey ¶
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) InvokeBytes ¶
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 ¶
MockedPeerChaincodes returns names of mocked chaincodes, available for invoke from current stub
func (*MockStub) PutPrivateData ¶
PutPrivateData mocked
func (*MockStub) QueryBytes ¶
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 ¶
type MockedPeer struct { // channel name -> chaincode name ChannelCC ChannelsMockStubs // contains filtered or unexported fields }
func (*MockedPeer) Chaincode ¶
func (mi *MockedPeer) Chaincode(channel string, chaincode string) (*MockStub, error)
func (*MockedPeer) Subscribe ¶
func (mi *MockedPeer) Subscribe( ctx context.Context, from msp.SigningIdentity, channel, chaincode string) (api.EventCCSubscription, error)
func (*MockedPeer) WithChannel ¶
func (mi *MockedPeer) WithChannel(channel string, mockStubs ...*MockStub) *MockedPeer
type PrivateMockStateRangeQueryIterator ¶
type PrivateMockStateRangeQueryIterator struct { Closed bool Stub *MockStub StartKey string EndKey string Current *list.Element Collection string }
func NewPrivateMockStateRangeQueryIterator ¶
func NewPrivateMockStateRangeQueryIterator(stub *MockStub, collection string, startKey string, endKey string) *PrivateMockStateRangeQueryIterator
func (*PrivateMockStateRangeQueryIterator) Close ¶
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 ¶
func (iter *PrivateMockStateRangeQueryIterator) HasNext() bool
HasNext returns true if the range query iterator contains additional keys and values.
func (*PrivateMockStateRangeQueryIterator) Next ¶
func (iter *PrivateMockStateRangeQueryIterator) Next() (*queryresult.KV, error)
Next returns the next key and value in the range query iterator.
func (*PrivateMockStateRangeQueryIterator) Print ¶
func (iter *PrivateMockStateRangeQueryIterator) Print()
type TxMiddleware ¶
type TxMiddleware func(*TxResult)
type TxResult ¶
type TxResult struct { Result interface{} Err error Event *peer.ChaincodeEvent }