mock

package
v0.12.5-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientStateActive = iota
	ClientStateInactive
	ClientStateRevoked
)
View Source
const Subsystem = "AUTO"

Variables

View Source
var RateLimitRule = &RuleRanges{
	Default: &rules.RateLimit{
		WriteLimit: &rules.Rate{
			Iterations: 1,
			NumHours:   1,
		},
		ReadLimit: &rules.Rate{
			Iterations: 10,
			NumHours:   1,
		},
	},
	MinVal: &rules.RateLimit{
		WriteLimit: &rules.Rate{
			Iterations: 0,
			NumHours:   1,
		},
		ReadLimit: &rules.Rate{
			Iterations: 1,
			NumHours:   1,
		},
	},
	MaxVal: &rules.RateLimit{
		WriteLimit: &rules.Rate{
			Iterations: 10,
			NumHours:   1,
		},
		ReadLimit: &rules.Rate{
			Iterations: 1000,
			NumHours:   1,
		},
	},
}

Functions

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type ClientState

type ClientState uint8

type Feature

type Feature struct {
	Description string
	Rules       map[string]*RuleRanges
	Permissions map[string][]bakery.Op
}

Feature is a feature that the autopilot server could return.

type RuleRanges

type RuleRanges struct {
	Default rules.Values
	MinVal  rules.Values
	MaxVal  rules.Values
}

type Server

type Server struct {
	autopilotserverrpc.AutopilotServer
	// contains filtered or unexported fields
}

Server implements the autopilotserverrpc.AutopilotServer interface and is used to mock the autopilot server in tests.

func NewServer

func NewServer() *Server

NewServer constructs a new MockAutoPilotServer.

func (*Server) GetClientState

func (m *Server) GetClientState(remoteKey *btcec.PublicKey) (
	ClientState, error)

func (*Server) GetPort

func (m *Server) GetPort() int

GetPort returns the port number that the mock server is serving its grpc server on.

func (*Server) GetPrivKey

func (m *Server) GetPrivKey(remoteKey *btcec.PublicKey) (
	*btcec.PrivateKey, error)

GetPrivKey can be used to extract the private key that the autopilot created for the given litd static key.

func (*Server) ListFeatures

ListFeatures converts the mockFeatures into the form that the autopilot server would.

Note: this is part of the autopilotrpc.AutopilotServer interface.

func (*Server) RegisterSession

RegisterSession will create a new priv key for the autopilot server and return the corresponding public key.

Note: this is part of the autopilotrpc.AutopilotServer interface.

func (*Server) ResetDefaultFeatures

func (m *Server) ResetDefaultFeatures()

ResetDefaultFeatures resets the servers features set to the default set.

func (*Server) RevokeSession

RevokeSession revokes a single session and also stops it if it is currently active.

Note: this is part of the autopilotrpc.AutopilotServer interface.

func (*Server) SetClientState

func (m *Server) SetClientState(remoteKey *btcec.PublicKey,
	s ClientState) error

func (*Server) SetFeatures

func (m *Server) SetFeatures(f map[string]*Feature)

SetFeatures can be used to override the feature set served by the mock autopilot server.

func (*Server) Start

func (m *Server) Start() error

Start kicks off the mock autopilot grpc server.

func (*Server) Stop

func (m *Server) Stop()

Stop cleans up any resources held by the mock server.

func (*Server) Terms

Terms returns any meta data from the autopilot server.

Note: this is part of the autopilotrpc.AutopilotServer interface.

Jump to

Keyboard shortcuts

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