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 ChannelMockStubs
- type ChannelsMockStubs
- type CreatorTransformer
- type EventSubscription
- type 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 MockInvoker
- func (mi *MockInvoker) Chaincode(channel string, chaincode string) (*MockStub, error)
- func (mi *MockInvoker) Invoke(ctx context.Context, from msp.SigningIdentity, channel string, ...) (*peer.Response, api.ChaincodeTx, error)
- func (mi *MockInvoker) Query(ctx context.Context, from msp.SigningIdentity, channel string, ...) (*peer.Response, error)
- func (mi *MockInvoker) Subscribe(ctx context.Context, from msp.SigningIdentity, channel, chaincode string) (api.EventCCSubscription, error)
- func (mi *MockInvoker) WithChannel(channel string, mockStubs ...*MockStub) *MockInvoker
- type MockStub
- func (stub *MockStub) ClearEvents()
- 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) GetStringArgs() []string
- func (stub *MockStub) GetTransient() (map[string][]byte, error)
- func (stub *MockStub) Init(iargs ...interface{}) 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) MockedPeerChancodes() []string
- 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
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`) )
Functions ¶
func MustConvertFromBytes ¶ added in v0.4.4
func MustConvertFromBytes(bb []byte, target interface{}) interface{}
func MustJsonMarshal ¶ added in v0.4.4
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, getContent identity.GetContent) (Identities, error)
ActorsFromPemFile returns map of CertIdentity, loaded from PEM files
func IdentitiesFromPem ¶ added in v0.4.4
func IdentitiesFromPem(mspID string, certPEMs map[string][]byte) (Identities, error)
ActorsFromPem returns CertIdentity (MSP ID and X.509 cert) converted PEM content
type Identity ¶ added in v0.4.4
type Identity struct { MspId string Certificate *x509.Certificate }
implements msp.SigningIdentity
func NewIdentity ¶ added in v0.4.4
func NewIdentity(mspId string, cert *x509.Certificate) *Identity
func (*Identity) GetIdentifier ¶ added in v0.4.4
func (i *Identity) GetIdentifier() *msp.IdentityIdentifier
func (*Identity) GetMSPIdentifier ¶ added in v0.4.4
GetMSPIdentifier returns current MspID of identity
func (*Identity) GetOrganizationalUnits ¶ added in v0.4.4
func (i *Identity) GetOrganizationalUnits() []*msp.OUIdentifier
func (*Identity) GetPublicVersion ¶ added in v0.4.4
func (*Identity) GetSubject ¶ added in v0.4.4
func (*Identity) SatisfiesPrincipal ¶ added in v0.4.4
func (i *Identity) SatisfiesPrincipal(principal *msppb.MSPPrincipal) error
type MockInvoker ¶ added in v0.4.4
type MockInvoker struct { // channel name -> chaincode name ChannelCC ChannelsMockStubs // contains filtered or unexported fields }
func (*MockInvoker) Chaincode ¶ added in v0.4.4
func (mi *MockInvoker) Chaincode(channel string, chaincode string) (*MockStub, error)
func (*MockInvoker) Subscribe ¶ added in v0.4.4
func (mi *MockInvoker) Subscribe(ctx context.Context, from msp.SigningIdentity, channel, chaincode string) (api.EventCCSubscription, error)
func (*MockInvoker) WithChannel ¶ added in v0.4.4
func (mi *MockInvoker) WithChannel(channel string, mockStubs ...*MockStub) *MockInvoker
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 // contains filtered or unexported fields }
MockStub replacement of shim.MockStub with creator mocking facilities
func NewMockStub ¶
NewMockStub creates chaincode imitation
func (*MockStub) ClearEvents ¶
func (stub *MockStub) ClearEvents()
ClearEvents clears chaincode events channel -
func (*MockStub) EventSubscription ¶
func (stub *MockStub) EventSubscription() chan *peer.ChaincodeEvent
func (*MockStub) GetFunctionAndParameters ¶
GetFunctionAndParameters 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) MockedPeerChancodes ¶
MockedPeerChancodes returns names of mocked chaincodes, available for invoke from current stub
func (*MockStub) QueryBytes ¶ added in v0.4.1
func (*MockStub) RegisterCreatorTransformer ¶
func (stub *MockStub) RegisterCreatorTransformer(creatorTransformer CreatorTransformer) *MockStub
RegisterCreatorTransformer that transforms creator data to MSP_ID and X.509 certificate