peer

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

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) CloseSend

func (s *MockCCComm) CloseSend() error

CloseSend closes send

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...

func (*MockCCComm) Recv

func (s *MockCCComm) Recv() (*pb.ChaincodeMessage, error)

Recv receives a message

func (*MockCCComm) Run

func (s *MockCCComm) Run(done <-chan struct{}) error

Run receives and sends indefinitely

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

Jump to

Keyboard shortcuts

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