loopout: cancel swap with server when off-chain fails

This commit is contained in:
carla 2021-05-24 08:46:03 +02:00
parent 6b732bacee
commit f166ce899d
No known key found for this signature in database
GPG key ID: 4CA7FE54A6213C91
4 changed files with 264 additions and 2 deletions

View file

@ -3,6 +3,7 @@ package loop
import (
"context"
"errors"
"testing"
"time"
@ -15,6 +16,7 @@ import (
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
"github.com/lightningnetwork/lnd/zpay32"
"github.com/stretchr/testify/require"
)
var (
@ -124,10 +126,17 @@ func (s *serverMock) GetLoopOutQuote(ctx context.Context, amt btcutil.Amount,
}
func getInvoice(hash lntypes.Hash, amt btcutil.Amount, memo string) (string, error) {
// Set different payment addresses for swap invoices.
payAddr := [32]byte{1, 2, 3}
if memo == swapInvoiceDesc {
payAddr = [32]byte{3, 2, 1}
}
req, err := zpay32.NewInvoice(
&chaincfg.TestNet3Params, hash, testTime,
zpay32.Description(memo),
zpay32.Amount(lnwire.MilliSatoshi(1000*amt)),
zpay32.PaymentAddr(payAddr),
)
if err != nil {
return "", err
@ -190,6 +199,10 @@ func (s *serverMock) CancelLoopOutSwap(ctx context.Context,
return nil
}
func (s *serverMock) assertSwapCanceled(t *testing.T, details *outCancelDetails) {
require.Equal(t, details, <-s.cancelSwap)
}
func (s *serverMock) GetLoopInTerms(ctx context.Context) (
*LoopInTerms, error) {