Documentation ¶
Index ¶
- type MockCCComm
- func (s *MockCCComm) CloseSend() error
- func (s *MockCCComm) GetRecvStream() chan *pb.ChaincodeMessage
- func (s *MockCCComm) GetSendStream() chan *pb.ChaincodeMessage
- func (s *MockCCComm) Quit()
- func (s *MockCCComm) Recv() (*pb.ChaincodeMessage, error)
- func (s *MockCCComm) Run() error
- func (s *MockCCComm) Send(msg *pb.ChaincodeMessage) error
- func (s *MockCCComm) SetBailOnError(b bool)
- func (s *MockCCComm) SetKeepAlive(ka *pb.ChaincodeMessage)
- func (s *MockCCComm) SetName(newname string)
- func (s *MockCCComm) SetPong(val bool)
- func (s *MockCCComm) SetResponses(respSet *MockResponseSet)
- type MockPeerCCSupport
- func (mp *MockPeerCCSupport) AddCC(name string, recv chan *pb.ChaincodeMessage, send chan *pb.ChaincodeMessage) (*MockCCComm, error)
- func (mp *MockPeerCCSupport) GetCC(name string) (*MockCCComm, error)
- func (mp *MockPeerCCSupport) GetCCMirror(name string) *MockCCComm
- func (mp *MockPeerCCSupport) RemoveAll() error
- func (mp *MockPeerCCSupport) RemoveCC(name string) error
- type MockResponse
- type MockResponseSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockCCComm ¶
type MockCCComm struct {
// contains filtered or unexported fields
}
MockCCComm implements the mock communication between chaincode and peer We'd need two MockCCComm for communication. The receiver and sender will be switched between the two.
func (*MockCCComm) GetRecvStream ¶
func (s *MockCCComm) GetRecvStream() chan *pb.ChaincodeMessage
GetRecvStream returns the recvStream
func (*MockCCComm) GetSendStream ¶
func (s *MockCCComm) GetSendStream() chan *pb.ChaincodeMessage
GetSendStream returns the sendStream
func (*MockCCComm) Quit ¶
func (s *MockCCComm) Quit()
Quit closes the channels...this will also close chaincode side
func (*MockCCComm) Recv ¶
func (s *MockCCComm) Recv() (*pb.ChaincodeMessage, error)
Recv receives a message
func (*MockCCComm) Send ¶
func (s *MockCCComm) Send(msg *pb.ChaincodeMessage) error
Send sends a message
func (*MockCCComm) SetBailOnError ¶
func (s *MockCCComm) SetBailOnError(b bool)
SetBailOnError will cause Run to return on any error
func (*MockCCComm) SetKeepAlive ¶
func (s *MockCCComm) SetKeepAlive(ka *pb.ChaincodeMessage)
SetKeepAlive sets keepalive. This mut be done on the server only
func (*MockCCComm) SetName ¶
func (s *MockCCComm) SetName(newname string)
func (*MockCCComm) SetPong ¶
func (s *MockCCComm) SetPong(val bool)
SetPong pongs received keepalive. This mut be done on the chaincode only
func (*MockCCComm) SetResponses ¶
func (s *MockCCComm) SetResponses(respSet *MockResponseSet)
SetResponses sets responses for an Init or Invoke
type MockPeerCCSupport ¶
type MockPeerCCSupport struct {
// contains filtered or unexported fields
}
MockPeerCCSupport provides CC support for peer interfaces.
func NewMockPeerSupport ¶
func NewMockPeerSupport() *MockPeerCCSupport
NewMockPeerSupport getsa mock peer support
func (*MockPeerCCSupport) AddCC ¶
func (mp *MockPeerCCSupport) AddCC(name string, recv chan *pb.ChaincodeMessage, send chan *pb.ChaincodeMessage) (*MockCCComm, error)
AddCC adds a cc to the MockPeerCCSupport
func (*MockPeerCCSupport) GetCC ¶
func (mp *MockPeerCCSupport) GetCC(name string) (*MockCCComm, error)
GetCC gets a cc from the MockPeerCCSupport
func (*MockPeerCCSupport) GetCCMirror ¶
func (mp *MockPeerCCSupport) GetCCMirror(name string) *MockCCComm
GetCCMirror creates a MockCCStream with streans switched
func (*MockPeerCCSupport) RemoveAll ¶
func (mp *MockPeerCCSupport) RemoveAll() error
RemoveAll removes all ccs
func (*MockPeerCCSupport) RemoveCC ¶
func (mp *MockPeerCCSupport) RemoveCC(name string) error
RemoveCC removes a cc
type MockResponse ¶
type MockResponse struct { RecvMsg *pb.ChaincodeMessage RespMsg interface{} }
MockResponse contains the expected received message (optional) and response to send (optional)
type MockResponseSet ¶
type MockResponseSet struct { //DoneFunc is invoked when all I/O is done for this //response set DoneFunc func(int, error) //ErrorFunc is invoked at any step when the input does not //match the received message ErrorFunc func(int, error) //Responses contained the expected received message (optional) //and response to send (optional) Responses []*MockResponse }
MockResponseSet is used for processing CC to Peer comm such as GET/PUT/DEL state. The MockResponse contains the response to be returned for each input received.from the CC. Every stub call will generate a response