lnd_test: extend chain claim test with invoice settled check
In this commit, we extend the remote/receiver chain claim integration test to assert that the on-disk representation of the invoice on the receiving side (Carol) is marked as settled due to the claiming the HTLC on-chain.
This commit is contained in:
parent
41f638c7cf
commit
016add6adc
57
lnd_test.go
57
lnd_test.go
@ -4,23 +4,20 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"sync/atomic"
|
|
||||||
|
|
||||||
"encoding/hex"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"crypto/rand"
|
|
||||||
"crypto/sha256"
|
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcjson"
|
"github.com/btcsuite/btcd/btcjson"
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
@ -9320,8 +9317,9 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
defer shutdownAndAssert(net, t, carol)
|
defer shutdownAndAssert(net, t, carol)
|
||||||
|
|
||||||
// With the network active, we'll now add a new invoice at Carol's end.
|
// With the network active, we'll now add a new invoice at Carol's end.
|
||||||
|
const invoiceAmt = 100000
|
||||||
invoiceReq := &lnrpc.Invoice{
|
invoiceReq := &lnrpc.Invoice{
|
||||||
Value: 100000,
|
Value: invoiceAmt,
|
||||||
}
|
}
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
carolInvoice, err := carol.AddInvoice(ctxt, invoiceReq)
|
carolInvoice, err := carol.AddInvoice(ctxt, invoiceReq)
|
||||||
@ -9527,6 +9525,25 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
t.Fatalf(predErr.Error())
|
t.Fatalf(predErr.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The invoice should show as settled for Carol, indicating that it was
|
||||||
|
// swept on-chain.
|
||||||
|
invoicesReq := &lnrpc.ListInvoiceRequest{}
|
||||||
|
invoicesResp, err := carol.ListInvoices(ctxb, invoicesReq)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to retrieve invoices: %v", err)
|
||||||
|
}
|
||||||
|
if len(invoicesResp.Invoices) != 1 {
|
||||||
|
t.Fatalf("expected 1 invoice, got %d", len(invoicesResp.Invoices))
|
||||||
|
}
|
||||||
|
invoice := invoicesResp.Invoices[0]
|
||||||
|
if invoice.State != lnrpc.Invoice_SETTLED {
|
||||||
|
t.Fatalf("expected invoice to be settled on chain")
|
||||||
|
}
|
||||||
|
if invoice.AmtPaidSat != invoiceAmt {
|
||||||
|
t.Fatalf("expected invoice to be settled with %d sat, got "+
|
||||||
|
"%d sat", invoiceAmt, invoice.AmtPaidSat)
|
||||||
|
}
|
||||||
|
|
||||||
// We'll close out the channel between Alice and Bob, then shutdown
|
// We'll close out the channel between Alice and Bob, then shutdown
|
||||||
// carol to conclude the test.
|
// carol to conclude the test.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout)
|
ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout)
|
||||||
@ -10368,8 +10385,9 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
|
|||||||
defer shutdownAndAssert(net, t, carol)
|
defer shutdownAndAssert(net, t, carol)
|
||||||
|
|
||||||
// With the network active, we'll now add a new invoice at Carol's end.
|
// With the network active, we'll now add a new invoice at Carol's end.
|
||||||
|
const invoiceAmt = 100000
|
||||||
invoiceReq := &lnrpc.Invoice{
|
invoiceReq := &lnrpc.Invoice{
|
||||||
Value: 100000,
|
Value: invoiceAmt,
|
||||||
}
|
}
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
carolInvoice, err := carol.AddInvoice(ctxt, invoiceReq)
|
carolInvoice, err := carol.AddInvoice(ctxt, invoiceReq)
|
||||||
@ -10611,6 +10629,25 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf(predErr.Error())
|
t.Fatalf(predErr.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The invoice should show as settled for Carol, indicating that it was
|
||||||
|
// swept on-chain.
|
||||||
|
invoicesReq := &lnrpc.ListInvoiceRequest{}
|
||||||
|
invoicesResp, err := carol.ListInvoices(ctxb, invoicesReq)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to retrieve invoices: %v", err)
|
||||||
|
}
|
||||||
|
if len(invoicesResp.Invoices) != 1 {
|
||||||
|
t.Fatalf("expected 1 invoice, got %d", len(invoicesResp.Invoices))
|
||||||
|
}
|
||||||
|
invoice := invoicesResp.Invoices[0]
|
||||||
|
if invoice.State != lnrpc.Invoice_SETTLED {
|
||||||
|
t.Fatalf("expected invoice to be settled on chain")
|
||||||
|
}
|
||||||
|
if invoice.AmtPaidSat != invoiceAmt {
|
||||||
|
t.Fatalf("expected invoice to be settled with %d sat, got "+
|
||||||
|
"%d sat", invoiceAmt, invoice.AmtPaidSat)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// testSwitchCircuitPersistence creates a multihop network to ensure the sender
|
// testSwitchCircuitPersistence creates a multihop network to ensure the sender
|
||||||
|
Loading…
Reference in New Issue
Block a user