mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
test: assert raw output signing requests
This commit is contained in:
parent
cecb26c495
commit
a05e46697d
5 changed files with 28 additions and 0 deletions
|
|
@ -265,6 +265,9 @@ func testSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,
|
|||
// Publish tick.
|
||||
ctx.expiryChan <- testTime
|
||||
|
||||
// Expect a signing request.
|
||||
<-ctx.Lnd.SignOutputRawChannel
|
||||
|
||||
if !preimageRevealed {
|
||||
ctx.assertStatus(loopdb.StatePreimageRevealed)
|
||||
ctx.assertStorePreimageReveal()
|
||||
|
|
|
|||
|
|
@ -175,6 +175,9 @@ func TestLoopInTimeout(t *testing.T) {
|
|||
// Let htlc expire.
|
||||
ctx.blockEpochChan <- swap.LoopInContract.CltvExpiry
|
||||
|
||||
// Expect a signing request.
|
||||
<-ctx.lnd.SignOutputRawChannel
|
||||
|
||||
// Expect timeout tx to be published.
|
||||
timeoutTx := <-ctx.lnd.TxPublishChannel
|
||||
|
||||
|
|
|
|||
|
|
@ -192,6 +192,9 @@ func TestCustomSweepConfTarget(t *testing.T) {
|
|||
|
||||
expiryChan <- time.Now()
|
||||
|
||||
// Expect a signing request for the HTLC success transaction.
|
||||
<-ctx.Lnd.SignOutputRawChannel
|
||||
|
||||
cfg.store.(*storeMock).assertLoopOutState(loopdb.StatePreimageRevealed)
|
||||
status := <-statusChan
|
||||
if status.State != loopdb.StatePreimageRevealed {
|
||||
|
|
@ -247,6 +250,9 @@ func TestCustomSweepConfTarget(t *testing.T) {
|
|||
blockEpochChan <- int32(defaultConfTargetHeight)
|
||||
expiryChan <- time.Now()
|
||||
|
||||
// Expect another signing request.
|
||||
<-ctx.Lnd.SignOutputRawChannel
|
||||
|
||||
// We should expect to see another sweep using the higher fee since the
|
||||
// spend hasn't been confirmed yet.
|
||||
sweepTx := assertSweepTx(DefaultSweepConfTarget)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/loop/lndclient"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/zpay32"
|
||||
|
|
@ -57,6 +58,8 @@ func NewMockLnd() *LndMockServices {
|
|||
RouterSendPaymentChannel: make(chan RouterPaymentChannelMessage),
|
||||
TrackPaymentChannel: make(chan TrackPaymentMessage),
|
||||
|
||||
SignOutputRawChannel: make(chan SignOutputRawRequest),
|
||||
|
||||
FailInvoiceChannel: make(chan lntypes.Hash, 2),
|
||||
epochChannel: make(chan int32),
|
||||
Height: testStartingHeight,
|
||||
|
|
@ -109,6 +112,12 @@ type SingleInvoiceSubscription struct {
|
|||
Err chan error
|
||||
}
|
||||
|
||||
// SignOutputRawRequest contains input data for a tx signing request.
|
||||
type SignOutputRawRequest struct {
|
||||
Tx *wire.MsgTx
|
||||
SignDescriptors []*input.SignDescriptor
|
||||
}
|
||||
|
||||
// LndMockServices provides a full set of mocked lnd services.
|
||||
type LndMockServices struct {
|
||||
lndclient.LndServices
|
||||
|
|
@ -130,6 +139,8 @@ type LndMockServices struct {
|
|||
RouterSendPaymentChannel chan RouterPaymentChannelMessage
|
||||
TrackPaymentChannel chan TrackPaymentMessage
|
||||
|
||||
SignOutputRawChannel chan SignOutputRawRequest
|
||||
|
||||
Height int32
|
||||
NodePubkey string
|
||||
Signature []byte
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ type mockSigner struct {
|
|||
func (s *mockSigner) SignOutputRaw(ctx context.Context, tx *wire.MsgTx,
|
||||
signDescriptors []*input.SignDescriptor) ([][]byte, error) {
|
||||
|
||||
s.lnd.SignOutputRawChannel <- SignOutputRawRequest{
|
||||
Tx: tx,
|
||||
SignDescriptors: signDescriptors,
|
||||
}
|
||||
|
||||
rawSigs := [][]byte{{1, 2, 3}}
|
||||
|
||||
return rawSigs, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue