testutils

package
v0.0.0-...-1bfa4a9 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func BatchRequest

func BatchRequest(size int) []jsonrpc.Request

func CheckTableExistence

func CheckTableExistence(dbName, tableName string, db *sql.DB) error

CheckTableExistence checks the underlying `db` object if there exists a table with given name.

func ErrorResponse

func ErrorResponse(id interface{}) jsonrpc.Response

ErrorResponse constructs a basic valid `jsonrpc.Response` that contains a simple error message.

func MockBindings

func MockBindings(logger logrus.FieldLogger, maxAttemptsUntilConfirmed int) *binding.Callbacks

func MockBurnParamSubmitTxV0BTC

func MockBurnParamSubmitTxV0BTC() v0.ParamsSubmitTx

func MockEngineState

func MockEngineState() map[string]engine.XState

func MockParamSubmitTxV0BCH

func MockParamSubmitTxV0BCH() v0.ParamsSubmitTx

func MockParamSubmitTxV0BTC

func MockParamSubmitTxV0BTC() v0.ParamsSubmitTx

func MockParamSubmitTxV0ZEC

func MockParamSubmitTxV0ZEC() v0.ParamsSubmitTx

func MockParamsSubmitGatewayFil

func MockParamsSubmitGatewayFil() resolver.ParamsSubmitGateway

func MockQueryBlockStateResponse

func MockQueryBlockStateResponse() jsonrpc.ResponseQueryBlockState

func MockQueryTxResponse

func MockQueryTxResponse() jsonrpc.ResponseQueryTx

func MockSystemState

func MockSystemState() engine.SystemState

func NewInspector

func NewInspector(cap int) (phi.Task, <-chan phi.Message)

NewInspector constructs a new `Inspector` task.

func NewMockCacher

func NewMockCacher() phi.Task

func NewMockDispatcher

func NewMockDispatcher(fail bool) phi.Task

func NumOfDataEntries

func NumOfDataEntries(db *sql.DB, name string) (int, error)

NumOfDataEntries returns the number of data entries in the queried table.

func RandomMethod

func RandomMethod() string

func RandomRequest

func RandomRequest(method string) jsonrpc.Request

func RandomResponse

func RandomResponse(good bool, result []byte) jsonrpc.Response

func RandomSubmitTxParams

func RandomSubmitTxParams() jsonrpc.ParamsSubmitTx

func SendRequestAsync

func SendRequestAsync(req jsonrpc.Request, to string) (chan *jsonrpc.Response, error)

SendRequestAsync send the request to the target address. It returns a chan of jsonrpc.Response without any blocking, actual response(or error) will be sent to the channel while received.

func SimpleHandler

func SimpleHandler(alwaysSuccess bool, requests chan jsonrpc.Request) http.HandlerFunc

func TimeoutHandler

func TimeoutHandler(timeout time.Duration) http.HandlerFunc

TimeoutHandler returns a simple `http.HandlerFunc` which sleeps a certain amount of time before responding.

func UpdateTxCreatedTime

func UpdateTxCreatedTime(db *sql.DB, name string, txHash id.Hash, createdTime int64) error

UpdateTxCreatedTime of given tx hash.

func ValidRequest

func ValidRequest(method string) (id interface{}, params interface{})

ValidRequest constructs a basic but valid `jsonrpc.Request` of the given method.

Types

type ChanWriter

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

ChanWriter is a io.Writer which writes all messages to an output channel.

func NewChanWriter

func NewChanWriter() (ChanWriter, chan string)

NewChanWriter returns a new ChanWriter and the output channel.

func (ChanWriter) Write

func (cl ChanWriter) Write(p []byte) (n int, err error)

ChanWriter implements the `io.Writer` interface.

type Inspector

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

An Inspector is a mock task that will simply write all of its received messages out on to a channel for inspection.

func (*Inspector) Handle

func (inspector *Inspector) Handle(_ phi.Task, message phi.Message)

Handle implements the `phi.Handler` interface.

type MockCacher

type MockCacher struct {
}

func (*MockCacher) Handle

func (cacher *MockCacher) Handle(_ phi.Task, message phi.Message)

Handle implements the `phi.Handler` interface. We respond with darknode v1 responses to test the compat endpoints

type MockDarknode

type MockDarknode struct {
	Me    wire.Address
	Store store.MultiAddrStore
}

func NewMockDarknode

func NewMockDarknode(serverURL string, store store.MultiAddrStore) *MockDarknode

type MockDispatcher

type MockDispatcher struct {
	Fail bool
}

func (*MockDispatcher) Handle

func (dispatcher *MockDispatcher) Handle(_ phi.Task, message phi.Message)

Handle implements the `phi.Handler` interface.

type MockSender

type MockSender struct {
	Messages chan phi.Message
}

func NewMockSender

func NewMockSender() *MockSender

func (*MockSender) Send

func (m *MockSender) Send(message phi.Message) bool

Jump to

Keyboard shortcuts

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