fabric: github.com/hyperledger/fabric/common/mocks/peer Index | Files

package peer

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

Index

Package Files

mockccstream.go mockpeerccsupport.go

type MockCCComm Uses

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 Uses

func (s *MockCCComm) CloseSend() error

CloseSend closes send

func (*MockCCComm) GetRecvStream Uses

func (s *MockCCComm) GetRecvStream() chan *pb.ChaincodeMessage

GetRecvStream returns the recvStream

func (*MockCCComm) GetSendStream Uses

func (s *MockCCComm) GetSendStream() chan *pb.ChaincodeMessage

GetSendStream returns the sendStream

func (*MockCCComm) Quit Uses

func (s *MockCCComm) Quit()

Quit closes the channels...

func (*MockCCComm) Recv Uses

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

Recv receives a message

func (*MockCCComm) Run Uses

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

Run receives and sends indefinitely

func (*MockCCComm) Send Uses

func (s *MockCCComm) Send(msg *pb.ChaincodeMessage) error

Send sends a message

func (*MockCCComm) SetBailOnError Uses

func (s *MockCCComm) SetBailOnError(b bool)

SetBailOnError will cause Run to return on any error

func (*MockCCComm) SetKeepAlive Uses

func (s *MockCCComm) SetKeepAlive(ka *pb.ChaincodeMessage)

SetKeepAlive sets keepalive. This mut be done on the server only

func (*MockCCComm) SetName Uses

func (s *MockCCComm) SetName(newname string)

func (*MockCCComm) SetPong Uses

func (s *MockCCComm) SetPong(val bool)

SetPong pongs received keepalive. This mut be done on the chaincode only

func (*MockCCComm) SetResponses Uses

func (s *MockCCComm) SetResponses(respSet *MockResponseSet)

SetResponses sets responses for an Init or Invoke

type MockPeerCCSupport Uses

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

MockPeerCCSupport provides CC support for peer interfaces.

func NewMockPeerSupport Uses

func NewMockPeerSupport() *MockPeerCCSupport

NewMockPeerSupport getsa mock peer support

func (*MockPeerCCSupport) AddCC Uses

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 Uses

func (mp *MockPeerCCSupport) GetCC(name string) (*MockCCComm, error)

GetCC gets a cc from the MockPeerCCSupport

func (*MockPeerCCSupport) GetCCMirror Uses

func (mp *MockPeerCCSupport) GetCCMirror(name string) *MockCCComm

GetCCMirror creates a MockCCStream with streans switched

func (*MockPeerCCSupport) RemoveAll Uses

func (mp *MockPeerCCSupport) RemoveAll() error

RemoveAll removes all ccs

func (*MockPeerCCSupport) RemoveCC Uses

func (mp *MockPeerCCSupport) RemoveCC(name string) error

RemoveCC removes a cc

type MockResponse Uses

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

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

type MockResponseSet Uses

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

Package peer imports 4 packages (graph). Updated 2019-11-19. Refresh now. Tools for package owners.