Documentation ¶
Index ¶
- Constants
- type Call
- type CoreServer
- type ExpectFunc
- func And(fns ...ExpectFunc) ExpectFunc
- func BodyShouldBeEmpty() ExpectFunc
- func BodyShouldBeSame(v interface{}) ExpectFunc
- func Debug() ExpectFunc
- func JRPCParamsEmpty() ExpectFunc
- func JRPCRequest(fns ...func(ctx context.Context, req btcjson.Request) error) ExpectFunc
- func QueryShouldHave(expectedVales url.Values) ExpectFunc
- type HTTPServer
- type HandlerFunc
- type HandlerOptionFunc
- func Body(body []byte) HandlerOptionFunc
- func ContentType(val string) HandlerOptionFunc
- func Header(key string, values ...string) HandlerOptionFunc
- func JRPCResult(v interface{}) HandlerOptionFunc
- func JSONBody(v interface{}) HandlerOptionFunc
- func JSONContentType() HandlerOptionFunc
- func OnMethod(fn func(ctx context.Context, req btcjson.Request) (interface{}, error)) HandlerOptionFunc
- type JRPCServer
- type MethodFunc
- func WithGetNetworkInfoMethod(cs CoreServer, times int) MethodFunc
- func WithMasternodeMethod(cs CoreServer, times int) MethodFunc
- func WithPingMethod(cs CoreServer, times int) MethodFunc
- func WithQuorumInfoMethod(cs CoreServer, times int) MethodFunc
- func WithQuorumSignMethod(cs CoreServer, times int, quorumType btcjson.LLMQType) MethodFunc
- func WithQuorumVerifyMethod(cs CoreServer, times int) MethodFunc
- type MockCoreServer
- func (c *MockCoreServer) GetNetworkInfo(_ context.Context, _ btcjson.GetNetworkInfoCmd) btcjson.GetNetworkInfoResult
- func (c *MockCoreServer) MasternodeStatus(ctx context.Context, _ btcjson.MasternodeCmd) btcjson.MasternodeStatusResult
- func (c *MockCoreServer) Ping(_ context.Context, _ btcjson.PingCmd) error
- func (c *MockCoreServer) QuorumInfo(ctx context.Context, cmd btcjson.QuorumCmd) btcjson.QuorumInfoResult
- func (c *MockCoreServer) QuorumSign(ctx context.Context, cmd btcjson.QuorumCmd) btcjson.QuorumSignResult
- func (c *MockCoreServer) QuorumVerify(ctx context.Context, cmd btcjson.QuorumCmd) btcjson.QuorumVerifyResult
- type MockServer
- type StaticCoreServer
- func (c *StaticCoreServer) GetNetworkInfo(_ context.Context, _ btcjson.GetNetworkInfoCmd) btcjson.GetNetworkInfoResult
- func (c *StaticCoreServer) MasternodeStatus(_ context.Context, _ btcjson.MasternodeCmd) btcjson.MasternodeStatusResult
- func (c *StaticCoreServer) Ping(_ context.Context, _cmd btcjson.PingCmd) error
- func (c *StaticCoreServer) QuorumInfo(_ context.Context, _ btcjson.QuorumCmd) btcjson.QuorumInfoResult
- func (c *StaticCoreServer) QuorumSign(_ context.Context, _ btcjson.QuorumCmd) btcjson.QuorumSignResult
- func (c *StaticCoreServer) QuorumVerify(_ context.Context, _ btcjson.QuorumCmd) btcjson.QuorumVerifyResult
Constants ¶
const Endless = -1
Endless ...
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
Call is a call expectation structure
func (*Call) Expect ¶
func (c *Call) Expect(fn ExpectFunc) *Call
Expect sets an expectation on a request
func (*Call) Respond ¶
func (c *Call) Respond(opts ...HandlerOptionFunc) *Call
Respond sets a response by a request
type CoreServer ¶
type CoreServer interface { QuorumInfo(ctx context.Context, cmd btcjson.QuorumCmd) btcjson.QuorumInfoResult QuorumSign(ctx context.Context, cmd btcjson.QuorumCmd) btcjson.QuorumSignResult QuorumVerify(ctx context.Context, cmd btcjson.QuorumCmd) btcjson.QuorumVerifyResult MasternodeStatus(ctx context.Context, cmd btcjson.MasternodeCmd) btcjson.MasternodeStatusResult GetNetworkInfo(ctx context.Context, cmd btcjson.GetNetworkInfoCmd) btcjson.GetNetworkInfoResult Ping(ctx context.Context, cmd btcjson.PingCmd) error }
CoreServer is an interface of a mock core-server
type ExpectFunc ¶
func BodyShouldBeEmpty ¶
func BodyShouldBeEmpty() ExpectFunc
BodyShouldBeEmpty expects that a request body should be empty
func BodyShouldBeSame ¶
func BodyShouldBeSame(v interface{}) ExpectFunc
BodyShouldBeSame compares a body from received request and passed byte slice
func JRPCParamsEmpty ¶
func JRPCParamsEmpty() ExpectFunc
JRPCParamsEmpty is a request expectation of empty JRPC params
func JRPCRequest ¶
JRPCRequest transforms http.Request into btcjson.Request and executes passed list of functions
func QueryShouldHave ¶
func QueryShouldHave(expectedVales url.Values) ExpectFunc
QueryShouldHave expects that a request query values should match on passed values
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer is a mock http server the idea is to use this server in a test flow to check requests and passed response
func NewHTTPServer ¶
func NewHTTPServer(addr string) *HTTPServer
NewHTTPServer returns a mock http server
func (*HTTPServer) On ¶
func (s *HTTPServer) On(pattern string) *Call
On returns a call structure to setup afterwards
func (*HTTPServer) WaitReady ¶
func (s *HTTPServer) WaitReady()
WaitReady waits a signal in a channel that a server is ready
type HandlerFunc ¶
type HandlerFunc func(w http.ResponseWriter, req *http.Request) error
type HandlerOptionFunc ¶
type JRPCServer ¶
type JRPCServer struct {
// contains filtered or unexported fields
}
JRPCServer is a mock JRPC server implementation
func NewJRPCServer ¶
func NewJRPCServer(addr, endpointURL string) *JRPCServer
NewJRPCServer creates and returns a new mock of JRPC server
func WithMethods ¶
func WithMethods(srv *JRPCServer, methods ...func(srv *JRPCServer)) *JRPCServer
WithMethods ...
func (*JRPCServer) Start ¶
func (s *JRPCServer) Start()
Start starts listening and handling JRPC requests
type MethodFunc ¶
type MethodFunc func(srv *JRPCServer)
MethodFunc ...
func WithGetNetworkInfoMethod ¶
func WithGetNetworkInfoMethod(cs CoreServer, times int) MethodFunc
WithGetNetworkInfoMethod ...
func WithMasternodeMethod ¶
func WithMasternodeMethod(cs CoreServer, times int) MethodFunc
WithMasternodeMethod ...
func WithQuorumInfoMethod ¶
func WithQuorumInfoMethod(cs CoreServer, times int) MethodFunc
WithQuorumInfoMethod ...
func WithQuorumSignMethod ¶
func WithQuorumSignMethod(cs CoreServer, times int, quorumType btcjson.LLMQType) MethodFunc
WithQuorumSignMethod ...
func WithQuorumVerifyMethod ¶
func WithQuorumVerifyMethod(cs CoreServer, times int) MethodFunc
WithQuorumVerifyMethod ...
type MockCoreServer ¶
MockCoreServer is an implementation of a mock core-server
func (*MockCoreServer) GetNetworkInfo ¶
func (c *MockCoreServer) GetNetworkInfo(_ context.Context, _ btcjson.GetNetworkInfoCmd) btcjson.GetNetworkInfoResult
GetNetworkInfo returns network-info result
func (*MockCoreServer) MasternodeStatus ¶
func (c *MockCoreServer) MasternodeStatus(ctx context.Context, _ btcjson.MasternodeCmd) btcjson.MasternodeStatusResult
MasternodeStatus returns a masternode-status result
func (*MockCoreServer) QuorumInfo ¶
func (c *MockCoreServer) QuorumInfo(ctx context.Context, cmd btcjson.QuorumCmd) btcjson.QuorumInfoResult
QuorumInfo returns a quorum-info result
func (*MockCoreServer) QuorumSign ¶
func (c *MockCoreServer) QuorumSign(ctx context.Context, cmd btcjson.QuorumCmd) btcjson.QuorumSignResult
QuorumSign returns a quorum-sign result
func (*MockCoreServer) QuorumVerify ¶
func (c *MockCoreServer) QuorumVerify(ctx context.Context, cmd btcjson.QuorumCmd) btcjson.QuorumVerifyResult
QuorumVerify returns a quorum-verify result
type MockServer ¶
MockServer ...
type StaticCoreServer ¶
type StaticCoreServer struct { QuorumInfoResult btcjson.QuorumInfoResult QuorumSignResult btcjson.QuorumSignResult QuorumVerifyResult btcjson.QuorumVerifyResult MasternodeStatusResult btcjson.MasternodeStatusResult GetNetworkInfoResult btcjson.GetNetworkInfoResult }
StaticCoreServer is a mock of core-server with static result data
func (*StaticCoreServer) GetNetworkInfo ¶
func (c *StaticCoreServer) GetNetworkInfo(_ context.Context, _ btcjson.GetNetworkInfoCmd) btcjson.GetNetworkInfoResult
GetNetworkInfo returns constant network-info result
func (*StaticCoreServer) MasternodeStatus ¶
func (c *StaticCoreServer) MasternodeStatus(_ context.Context, _ btcjson.MasternodeCmd) btcjson.MasternodeStatusResult
MasternodeStatus returns constant masternode-status result
func (*StaticCoreServer) QuorumInfo ¶
func (c *StaticCoreServer) QuorumInfo(_ context.Context, _ btcjson.QuorumCmd) btcjson.QuorumInfoResult
QuorumInfo returns constant quorum-info result
func (*StaticCoreServer) QuorumSign ¶
func (c *StaticCoreServer) QuorumSign(_ context.Context, _ btcjson.QuorumCmd) btcjson.QuorumSignResult
QuorumSign returns constant quorum-sign result
func (*StaticCoreServer) QuorumVerify ¶
func (c *StaticCoreServer) QuorumVerify(_ context.Context, _ btcjson.QuorumCmd) btcjson.QuorumVerifyResult
QuorumVerify returns constant quorum-sign result