Documentation
¶
Overview ¶
Package mock contains utilities for mocking lightning interactions within docker
Index ¶
- Constants
- func EnvArgs() []string
- func LnCLIPrefix() []string
- func MockLndInvoiceMainnet(t *testing.T) (encoded string, decoded *zpay32.Invoice)
- func Volumes() []string
- type BtcdContainer
- type LightningMocker
- func (c LightningMocker) CreateBtcdContainer() (ctn BtcdContainer, err error)
- func (c LightningMocker) CreateLndContainer(name string) (ctn LndContainer, err error)
- func (c *LightningMocker) CreateNetworks() (err error)
- func (c LightningMocker) CreateVolumes() error
- func (c *LightningMocker) Initialize() (err error)
- func (c LightningMocker) Teardown() error
- type LndContainer
- func (l *LndContainer) Address() (address string, err error)
- func (l *LndContainer) Connect(pubKey, host string) (err error)
- func (l *LndContainer) GetAdminMacaroon() (mac *macaroon.Macaroon, err error)
- func (l *LndContainer) GetPubKey() (pubKey string, err error)
- func (l *LndContainer) GetTLSCert() (cert *tls.Config, rawCert string, err error)
- func (l *LndContainer) GrpcConnection() (conn *grpc.ClientConn, err error)
- func (l *LndContainer) OpenChannel(pubKey, host string, amount int) (err error)
- func (l *LndContainer) RPCClient() (rpcClient lnrpc.LightningClient, err error)
- func (l *LndContainer) WaitForCondition(checker func(res *lnrpc.GetInfoResponse) bool) (err error)
- func (l *LndContainer) WaitForSync(chain, graph bool) (err error)
- type PortMap
Constants ¶
const MiningAddressName = "MINING_ADDRESS"
MiningAddressName is the name of the mining address argument passed to BtcdContainer
const NetworkName container.NetworkMode = "lightning-network"
NetworkName is the name of the network we use in docker
Variables ¶
This section is empty.
Functions ¶
func EnvArgs ¶
func EnvArgs() []string
EnvArgs defines a list of arguments that must be used with the rpc server this is a function to make it immutable
func LnCLIPrefix ¶ added in v0.16.0
func LnCLIPrefix() []string
LnCLIPrefix defines a constant for the network all command use this is a function to make it immutable
func MockLndInvoiceMainnet ¶ added in v0.13.0
MockLndInvoiceMainnet creates a mock lnd invoice on mainnet and returns the encoded and decoded *zpay32.Invoice object
Types ¶
type BtcdContainer ¶ added in v0.11.0
type BtcdContainer struct { // PortMap contains a list of ports on the host to the internal container port PortMap PortMap // contains filtered or unexported fields }
BtcdContainer object contains methods that allow us to interact with a created btcd container
func (*BtcdContainer) Mine ¶ added in v0.28.0
func (b *BtcdContainer) Mine(blocks int) (err error)
Mine a given number of blocks
func (*BtcdContainer) MineToAddress ¶ added in v0.11.0
func (b *BtcdContainer) MineToAddress(address string, blocks int) (err error)
MineToAddress mines a given number of block rewards to an address
type LightningMocker ¶
type LightningMocker struct { docker.Client // contains filtered or unexported fields }
LightningMocker defines the lnd mocker object
func NewLightningMocker ¶
func NewLightningMocker() LightningMocker
NewLightningMocker creates a new lightning mock object with a given session id
func (LightningMocker) CreateBtcdContainer ¶
func (c LightningMocker) CreateBtcdContainer() (ctn BtcdContainer, err error)
CreateBtcdContainer creates a BtcdContainer and starts it so it can respond to rpc requests. Mining must be done manually and a mining address should be set using BtcdContainer.MineToAddress.
func (LightningMocker) CreateLndContainer ¶
func (c LightningMocker) CreateLndContainer(name string) (ctn LndContainer, err error)
CreateLndContainer create's an lnd container with a given name and no channels
func (*LightningMocker) CreateNetworks ¶ added in v0.15.0
func (c *LightningMocker) CreateNetworks() (err error)
CreateNetworks sets up the networks needed for
func (LightningMocker) CreateVolumes ¶
func (c LightningMocker) CreateVolumes() error
CreateVolumes creates new volumes if they don't exist
func (*LightningMocker) Initialize ¶ added in v0.15.0
func (c *LightningMocker) Initialize() (err error)
Initialize creates common resources by calling CreateNetworks and CreateVolumes and returning an error if necessary
func (LightningMocker) Teardown ¶
func (c LightningMocker) Teardown() error
Teardown removes all containers created in the session
type LndContainer ¶ added in v0.11.0
type LndContainer struct { // PortMap is the mapping of ports to the host binding PortMap PortMap // contains filtered or unexported fields }
LndContainer object contains methods that allow us to interact with a created lnd container
func (*LndContainer) Address ¶ added in v0.11.0
func (l *LndContainer) Address() (address string, err error)
Address gets the address of the user
func (*LndContainer) Connect ¶ added in v0.15.0
func (l *LndContainer) Connect(pubKey, host string) (err error)
Connect connects to the lightning peer
func (*LndContainer) GetAdminMacaroon ¶ added in v0.16.0
func (l *LndContainer) GetAdminMacaroon() (mac *macaroon.Macaroon, err error)
GetAdminMacaroon fetches the admin macaroon from LndContainer
func (*LndContainer) GetPubKey ¶ added in v0.11.0
func (l *LndContainer) GetPubKey() (pubKey string, err error)
GetPubKey of instance
func (*LndContainer) GetTLSCert ¶ added in v0.16.0
func (l *LndContainer) GetTLSCert() (cert *tls.Config, rawCert string, err error)
GetTLSCert gets the tls cert for LndContainer
func (*LndContainer) GrpcConnection ¶ added in v0.16.0
func (l *LndContainer) GrpcConnection() (conn *grpc.ClientConn, err error)
GrpcConnection generates a grpc connection to a
func (*LndContainer) OpenChannel ¶ added in v0.11.0
func (l *LndContainer) OpenChannel(pubKey, host string, amount int) (err error)
OpenChannel connects to the peer and broadcasts a channel opening transaction to the mempool. Note: blocks must be mined for channel to be established
func (*LndContainer) RPCClient ¶ added in v0.16.0
func (l *LndContainer) RPCClient() (rpcClient lnrpc.LightningClient, err error)
RPCClient gets an authenticated
func (*LndContainer) WaitForCondition ¶ added in v0.28.0
func (l *LndContainer) WaitForCondition(checker func(res *lnrpc.GetInfoResponse) bool) (err error)
WaitForCondition waits for a custom condition from info. Useful for verifying chain states Use with caution. Loop will not terminate until checker is true
func (*LndContainer) WaitForSync ¶ added in v0.26.0
func (l *LndContainer) WaitForSync(chain, graph bool) (err error)
WaitForSync waits for a the chain to be synced
type PortMap ¶ added in v0.16.0
PortMap wraps nat.PortMap for easier port querying
func (PortMap) GetHostPort ¶ added in v0.16.0
GetHostPort will return a host port for any given container port