Help us shape the future of Go! Take the 2026 Go Developer Survey

testing

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EventChannelBufferSize = 100

Variables

View Source
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 TransformCreator

func TransformCreator(txCreator ...interface{}) (mspID string, certPEM []byte, err error)

TransformCreator transforms arbitrary tx creator (pmsp.SerializedIdentity etc) to mspID string, certPEM []byte,

Types

type CreatorTransformer

type CreatorTransformer func(...interface{}) (mspID string, certPEM []byte, err 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
	// contains filtered or unexported fields
}

MockStub replacement of shim.MockStub with creator mocking facilities

func NewMockStub

func NewMockStub(name string, cc shim.Chaincode) *MockStub

NewMockStub creates MockStub

func (*MockStub) ClearEvents

func (stub *MockStub) ClearEvents()

ClearEvents clears chaincode events channel -

func (*MockStub) EventSubscription

func (stub *MockStub) EventSubscription() chan *peer.ChaincodeEvent

func (*MockStub) From

func (stub *MockStub) From(txCreator ...interface{}) *MockStub

From mock tx creator

func (*MockStub) GetArgs

func (stub *MockStub) GetArgs() [][]byte

GetArgs mocked args

func (*MockStub) GetCreator

func (stub *MockStub) GetCreator() ([]byte, error)

GetCreator mocked

func (*MockStub) GetFunctionAndParameters

func (stub *MockStub) GetFunctionAndParameters() (function string, params []string)

GetFunctionAndParameters mocked

func (*MockStub) GetStringArgs

func (stub *MockStub) GetStringArgs() []string

GetStringArgs get mocked args as strings

func (*MockStub) Init

func (stub *MockStub) Init(iargs ...interface{}) peer.Response

Init func of chaincode - sugared version with autogenerated tx uuid

func (*MockStub) Invoke

func (stub *MockStub) Invoke(funcName string, iargs ...interface{}) peer.Response

Invoke sugared invoke function 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

func (stub *MockStub) MockCreator(mspID string, certPEM []byte)

MockCreator of tx

func (*MockStub) MockInit

func (stub *MockStub) MockInit(uuid string, args [][]byte) peer.Response

MockInit mocked init function

func (*MockStub) MockInvoke

func (stub *MockStub) MockInvoke(uuid string, args [][]byte) peer.Response

MockInvoke mocket init function

func (*MockStub) MockPeerChaincode

func (stub *MockStub) MockPeerChaincode(invokableChaincodeName string, otherStub *MockStub)

MockPeerChaincode link to another MockStub

func (*MockStub) MockedPeerChancodes

func (stub *MockStub) MockedPeerChancodes() []string

MockedPeerChancodes returns names of mocked chaincodes, available for invoke from current stub

func (*MockStub) Query

func (stub *MockStub) Query(funcName string, iargs ...interface{}) peer.Response

func (*MockStub) RegisterCreatorTransformer

func (stub *MockStub) RegisterCreatorTransformer(creatorTransformer CreatorTransformer) *MockStub

RegisterCreatorTransformer that transforms creator data to MSP_ID and X.509 certificate

func (*MockStub) SetArgs

func (stub *MockStub) SetArgs(args [][]byte)

SetArgs set mocked args

func (*MockStub) SetEvent

func (stub *MockStub) SetEvent(name string, payload []byte) error

SetEvent sets chaincode event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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