mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
test: allow intercepting PublishTransaction
This commit is contained in:
parent
cd599b0cea
commit
09d28b50dd
2 changed files with 14 additions and 1 deletions
|
|
@ -129,6 +129,11 @@ type SignOutputRawRequest struct {
|
|||
SignDescriptors []*lndclient.SignDescriptor
|
||||
}
|
||||
|
||||
// PublishHandler is optional transaction handler function called upon calling
|
||||
// the method PublishTransaction.
|
||||
type PublishHandler func(ctx context.Context, tx *wire.MsgTx,
|
||||
label string) error
|
||||
|
||||
// LndMockServices provides a full set of mocked lnd services.
|
||||
type LndMockServices struct {
|
||||
lndclient.LndServices
|
||||
|
|
@ -174,6 +179,8 @@ type LndMockServices struct {
|
|||
|
||||
WaitForFinished func()
|
||||
|
||||
PublishHandler PublishHandler
|
||||
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,13 @@ func (m *mockWalletKit) NextAddr(context.Context, string, walletrpc.AddressType,
|
|||
}
|
||||
|
||||
func (m *mockWalletKit) PublishTransaction(ctx context.Context, tx *wire.MsgTx,
|
||||
_ string) error {
|
||||
label string) error {
|
||||
|
||||
if m.lnd.PublishHandler != nil {
|
||||
if err := m.lnd.PublishHandler(ctx, tx, label); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
m.lnd.AddTx(tx)
|
||||
m.lnd.TxPublishChannel <- tx
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue