tests

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MockInvoice = "" /* 322-byte string literal not displayed */
View Source
const MockPaymentHash = "23277d5e13fce5534f9752c62fcf9337a2a6b0ebea9d21fa816a4c9d054cf93b" // for the above invoice
View Source
const MockPaymentHash500 = "be8ad5d0b82071d538dcd160e3a3af444bd890de68388a4d771ba23c01096f2a"

for the invoice: lnbcrt5u1pjuywzppp5h69dt59cypca2wxu69sw8ga0g39a3yx7dqug5nthrw3rcqgfdu4qdqqcqzzsxqyz5vqsp5gzlpzszyj2k30qmpme7jsfzr24wqlvt9xdmr7ay34lfelz050krs9qyyssq038x07nh8yuv8hdpjh5y8kqp7zcd62ql9na9xh7pla44htjyy02sz23q7qm2tza6ct4ypljk54w9k9qsrsu95usk8ce726ytep6vhhsq9mhf9a

View Source
const MockZeroAmountInvoice = "" /* 330-byte string literal not displayed */
View Source
const MockZeroAmountPaymentHash = "8c4859ba70ed96328bec21b6c2f97d5453dc8c88bc56533209711701a8ff4211"

Variables

View Source
var MockLNClientBalances = lnclient.BalancesResponse{
	Lightning: lnclient.LightningBalanceResponse{
		TotalSpendable: 21000,
	},
}
View Source
var MockLNClientHoldTransaction = &lnclient.Transaction{
	Type:            "incoming",
	Invoice:         "lntb10n1p5zg5p7dqud4hkx6eqdphkcepqd9h8vmmfvdjsnp4qw988hn4lhpu0my4rf0qkraft3wdx5aa0jnjmusgd23z3s0e9qv62pp5yaulxt6x83u4u0x2pck5pyg7fdxhjsd65c9lmu2a9r05qh0cgl6ssp5x57tsnnuc9hr99a9xzg5ylqma5fwvckxa50jqqay5zykqp83h9kq9qyysgqcqpcxqxf92hqqxh0avuskdnuzkk7mxslsdwem3qq3sf79a4ypmx0hax3rupp043yhv97h25vaarj0xrlcg2fdfdhpztsthettskyaylrz6vweztn0twqqv7kxmr",
	Description:     "mock hold invoice",
	DescriptionHash: "",
	Preimage:        "4aa083cad11038359b4f614f3a3d6a8298ae17d5275412bc3eca4f5f4d27f2d4",
	PaymentHash:     "2779f32f463c795e3cca0e2d40911e4b4d7941baa60bfdf15d28df405df847f5",
	Amount:          2000,
}
View Source
var MockLNClientTransaction = &MockLNClientTransactions[0]
View Source
var MockLNClientTransactions = []lnclient.Transaction{
	{
		Type:            "incoming",
		Invoice:         MockInvoice,
		Description:     "mock invoice 1",
		DescriptionHash: "hash1",
		Preimage:        "preimage1",
		PaymentHash:     MockPaymentHash,
		Amount:          1000,
		FeesPaid:        50,
		SettledAt:       &MockTimeUnix,
		Metadata: map[string]interface{}{
			"key1": "value1",
			"key2": 42,
		},
	},
	{
		Type:            "incoming",
		Invoice:         MockInvoice,
		Description:     "mock invoice 2",
		DescriptionHash: "hash2",
		Preimage:        "preimage2",
		PaymentHash:     MockPaymentHash,
		Amount:          2000,
		FeesPaid:        75,
		SettledAt:       &MockTimeUnix,
	},
}
View Source
var MockNodeInfo = lnclient.NodeInfo{
	Alias:       "bob",
	Color:       "#3399FF",
	Pubkey:      "123pubkey",
	Network:     "testnet",
	BlockHeight: 12,
	BlockHash:   "123blockhash",
}
View Source
var MockTime = time.Unix(1693876963, 0)
View Source
var MockTimeUnix = MockTime.Unix()

Functions

func CreateApp

func CreateApp(svc *TestService) (app *db.App, cipher *cipher.Nip47Cipher, err error)

func CreateAppWithPrivateKey added in v1.2.0

func CreateAppWithPrivateKey(svc *TestService, senderPrivkey, nip47Encryption string) (app *db.App, nip47Cipher *cipher.Nip47Cipher, err error)

func CreateAppWithSharedWalletPubkey added in v1.14.0

func CreateAppWithSharedWalletPubkey(svc *TestService, senderPrivkey, nip47Encryption string) (app *db.App, nip47Cipher *cipher.Nip47Cipher, err error)

func NewMockEventConsumer added in v1.6.0

func NewMockEventConsumer() *mockEventConsumer

func NewMockSimplePool added in v1.21.0

func NewMockSimplePool() *mockSimplePool

Types

type CreateAppFn added in v1.14.0

type CreateAppFn func(svc *TestService, senderPrivkey string, nip47Encryption string) (app *db.App, nip47Cipher *cipher.Nip47Cipher, err error)

type MockLn

type MockLn struct {
	PayInvoiceResponses        []*lnclient.PayInvoiceResponse
	PayInvoiceErrors           []error
	PaymentDelay               *time.Duration
	Pubkey                     string
	MockTransaction            *lnclient.Transaction
	SupportedNotificationTypes *[]string
}

func NewMockLn

func NewMockLn() (*MockLn, error)

func (*MockLn) CancelHoldInvoice added in v1.18.0

func (mln *MockLn) CancelHoldInvoice(ctx context.Context, paymentHash string) (err error)

func (*MockLn) CloseChannel

func (mln *MockLn) CloseChannel(ctx context.Context, closeChannelRequest *lnclient.CloseChannelRequest) (*lnclient.CloseChannelResponse, error)

func (*MockLn) ConnectPeer

func (mln *MockLn) ConnectPeer(ctx context.Context, connectPeerRequest *lnclient.ConnectPeerRequest) error

func (*MockLn) DisconnectPeer

func (mln *MockLn) DisconnectPeer(ctx context.Context, peerId string) error

func (*MockLn) ExecuteCustomNodeCommand added in v1.14.0

func (mln *MockLn) ExecuteCustomNodeCommand(ctx context.Context, command *lnclient.CustomNodeCommandRequest) (*lnclient.CustomNodeCommandResponse, error)

func (*MockLn) GetBalances

func (mln *MockLn) GetBalances(ctx context.Context, includeInactiveChannels bool) (*lnclient.BalancesResponse, error)

func (*MockLn) GetCustomNodeCommandDefinitions added in v1.14.0

func (mln *MockLn) GetCustomNodeCommandDefinitions() []lnclient.CustomNodeCommandDef

func (*MockLn) GetInfo

func (mln *MockLn) GetInfo(ctx context.Context) (info *lnclient.NodeInfo, err error)

func (*MockLn) GetLogOutput

func (mln *MockLn) GetLogOutput(ctx context.Context, maxLen int) ([]byte, error)

func (*MockLn) GetNetworkGraph

func (mln *MockLn) GetNetworkGraph(ctx context.Context, nodeIds []string) (lnclient.NetworkGraphResponse, error)

func (*MockLn) GetNewOnchainAddress

func (mln *MockLn) GetNewOnchainAddress(ctx context.Context) (string, error)

func (*MockLn) GetNodeConnectionInfo

func (mln *MockLn) GetNodeConnectionInfo(ctx context.Context) (nodeConnectionInfo *lnclient.NodeConnectionInfo, err error)

func (*MockLn) GetNodeStatus

func (mln *MockLn) GetNodeStatus(ctx context.Context) (nodeStatus *lnclient.NodeStatus, err error)

func (*MockLn) GetOnchainBalance

func (mln *MockLn) GetOnchainBalance(ctx context.Context) (*lnclient.OnchainBalanceResponse, error)

func (*MockLn) GetPubkey added in v1.2.0

func (mln *MockLn) GetPubkey() string

func (*MockLn) GetStorageDir

func (mln *MockLn) GetStorageDir() (string, error)

func (*MockLn) GetSupportedNIP47Methods

func (mln *MockLn) GetSupportedNIP47Methods() []string

func (*MockLn) GetSupportedNIP47NotificationTypes

func (mln *MockLn) GetSupportedNIP47NotificationTypes() []string

func (*MockLn) ListChannels

func (mln *MockLn) ListChannels(ctx context.Context) (channels []lnclient.Channel, err error)

func (*MockLn) ListOnchainTransactions added in v1.17.0

func (mln *MockLn) ListOnchainTransactions(ctx context.Context) ([]lnclient.OnchainTransaction, error)

func (*MockLn) ListPeers

func (mln *MockLn) ListPeers(ctx context.Context) ([]lnclient.PeerDetails, error)

func (*MockLn) ListTransactions

func (mln *MockLn) ListTransactions(ctx context.Context, from, until, limit, offset uint64, unpaid bool, invoiceType string) (invoices []lnclient.Transaction, err error)

func (*MockLn) LookupInvoice

func (mln *MockLn) LookupInvoice(ctx context.Context, paymentHash string) (transaction *lnclient.Transaction, err error)

func (*MockLn) MakeHoldInvoice added in v1.18.0

func (mln *MockLn) MakeHoldInvoice(ctx context.Context, amount int64, description string, descriptionHash string, expiry int64, paymentHash string) (transaction *lnclient.Transaction, err error)

func (*MockLn) MakeInvoice

func (mln *MockLn) MakeInvoice(ctx context.Context, amount int64, description string, descriptionHash string, expiry int64, throughNodePubkey *string) (transaction *lnclient.Transaction, err error)

func (*MockLn) MakeOffer added in v1.18.0

func (mln *MockLn) MakeOffer(ctx context.Context, description string) (string, error)

func (*MockLn) OpenChannel

func (mln *MockLn) OpenChannel(ctx context.Context, openChannelRequest *lnclient.OpenChannelRequest) (*lnclient.OpenChannelResponse, error)

func (*MockLn) RedeemOnchainFunds

func (mln *MockLn) RedeemOnchainFunds(ctx context.Context, toAddress string, amount uint64, feeRate *uint64, sendAll bool) (txId string, err error)

func (*MockLn) ResetRouter

func (mln *MockLn) ResetRouter(key string) error

func (*MockLn) SendKeysend

func (mln *MockLn) SendKeysend(amount uint64, destination string, custom_records []lnclient.TLVRecord, preimage string) (*lnclient.PayKeysendResponse, error)

func (*MockLn) SendPaymentProbes

func (mln *MockLn) SendPaymentProbes(ctx context.Context, invoice string) error

func (*MockLn) SendPaymentSync

func (mln *MockLn) SendPaymentSync(payReq string, amount *uint64) (*lnclient.PayInvoiceResponse, error)

func (*MockLn) SendSpontaneousPaymentProbes

func (mln *MockLn) SendSpontaneousPaymentProbes(ctx context.Context, amountMsat uint64, nodeId string) error

func (*MockLn) SettleHoldInvoice added in v1.18.0

func (mln *MockLn) SettleHoldInvoice(ctx context.Context, preimage string) (err error)

func (*MockLn) Shutdown

func (mln *MockLn) Shutdown() error

func (*MockLn) SignMessage

func (mln *MockLn) SignMessage(ctx context.Context, message string) (string, error)

func (*MockLn) UpdateChannel

func (mln *MockLn) UpdateChannel(ctx context.Context, updateChannelRequest *lnclient.UpdateChannelRequest) error

func (*MockLn) UpdateLastWalletSyncRequest

func (mln *MockLn) UpdateLastWalletSyncRequest()

type TestService

type TestService struct {
	Keys           keys.Keys
	Cfg            config.Config
	LNClient       lnclient.LNClient
	EventPublisher events.EventPublisher
	AppsService    apps.AppsService
	DB             *gorm.DB
}

func CreateTestService

func CreateTestService(t *testing.T) (svc *TestService, err error)

func CreateTestServiceWithMnemonic added in v1.11.0

func CreateTestServiceWithMnemonic(t *testing.T, mnemonic string, unlockPassword string) (svc *TestService, err error)

func (*TestService) Remove added in v1.14.0

func (s *TestService) Remove()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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