...

Package peer

import "github.com/hyperledger/fabric/common/mocks/peer"
Overview
Index

Overview ▾

type MockCCComm

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.

type MockCCComm struct {
    // contains filtered or unexported fields
}

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

MockPeerCCSupport provides CC support for peer interfaces.

type MockPeerCCSupport struct {
    // contains filtered or unexported fields
}

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

MockResponse contains the expected received message (optional) and response to send (optional)

type MockResponse struct {
    RecvMsg *pb.ChaincodeMessage
    RespMsg interface{}
}

type MockResponseSet

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

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
}