github.com/status-im/status-go@v1.1.0/services/ext/handler_mock.go (about)

     1  package ext
     2  
     3  import (
     4  	"github.com/status-im/status-go/eth-node/types"
     5  )
     6  
     7  type failureMessage struct {
     8  	IDs   [][]byte
     9  	Error error
    10  }
    11  
    12  func NewHandlerMock(buf int) HandlerMock {
    13  	return HandlerMock{
    14  		confirmations:     make(chan [][]byte, buf),
    15  		expirations:       make(chan failureMessage, buf),
    16  		requestsCompleted: make(chan types.Hash, buf),
    17  		requestsExpired:   make(chan types.Hash, buf),
    18  		requestsFailed:    make(chan types.Hash, buf),
    19  	}
    20  }
    21  
    22  type HandlerMock struct {
    23  	confirmations     chan [][]byte
    24  	expirations       chan failureMessage
    25  	requestsCompleted chan types.Hash
    26  	requestsExpired   chan types.Hash
    27  	requestsFailed    chan types.Hash
    28  }
    29  
    30  func (t HandlerMock) EnvelopeSent(ids [][]byte) {
    31  	t.confirmations <- ids
    32  }
    33  
    34  func (t HandlerMock) EnvelopeExpired(ids [][]byte, err error) {
    35  	t.expirations <- failureMessage{IDs: ids, Error: err}
    36  }
    37  
    38  func (t HandlerMock) MailServerRequestCompleted(requestID types.Hash, lastEnvelopeHash types.Hash, cursor []byte, err error) {
    39  	if err == nil {
    40  		t.requestsCompleted <- requestID
    41  	} else {
    42  		t.requestsFailed <- requestID
    43  	}
    44  }
    45  
    46  func (t HandlerMock) MailServerRequestExpired(hash types.Hash) {
    47  	t.requestsExpired <- hash
    48  }