mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-30 15:02:29 +02:00
itest/test: update remote force close timeout to use hodl inv
This commit updates our multi-hop force close test to use a hodl invoice so that we can reproduce some bugs which will require the preimage for the invoice that is timed out on chain.
This commit is contained in:
parent
5a82340a03
commit
fff6f83f23
@ -5,9 +5,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
|
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,14 +45,21 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// We'll now send a single HTLC across our multi-hop network.
|
// We'll now send a single HTLC across our multi-hop network.
|
||||||
carolPubKey := carol.PubKey[:]
|
preimage := lntypes.Preimage{1, 2, 3}
|
||||||
payHash := makeFakePayHash(t)
|
payHash := preimage.Hash()
|
||||||
_, err := alice.RouterClient.SendPaymentV2(
|
invoiceReq := &invoicesrpc.AddHoldInvoiceRequest{
|
||||||
|
Value: int64(htlcAmt),
|
||||||
|
CltvExpiry: 40,
|
||||||
|
Hash: payHash[:],
|
||||||
|
}
|
||||||
|
|
||||||
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
carolInvoice, err := carol.AddHoldInvoice(ctxt, invoiceReq)
|
||||||
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
|
_, err = alice.RouterClient.SendPaymentV2(
|
||||||
ctx, &routerrpc.SendPaymentRequest{
|
ctx, &routerrpc.SendPaymentRequest{
|
||||||
Dest: carolPubKey,
|
PaymentRequest: carolInvoice.PaymentRequest,
|
||||||
Amt: int64(htlcAmt),
|
|
||||||
PaymentHash: payHash,
|
|
||||||
FinalCltvDelta: finalCltvDelta,
|
|
||||||
TimeoutSeconds: 60,
|
TimeoutSeconds: 60,
|
||||||
FeeLimitMsat: noFeeLimitMsat,
|
FeeLimitMsat: noFeeLimitMsat,
|
||||||
},
|
},
|
||||||
@ -61,7 +70,7 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
|
|||||||
// show that the HTLC has been locked in.
|
// show that the HTLC has been locked in.
|
||||||
nodes := []*lntest.HarnessNode{alice, bob, carol}
|
nodes := []*lntest.HarnessNode{alice, bob, carol}
|
||||||
err = wait.NoError(func() error {
|
err = wait.NoError(func() error {
|
||||||
return assertActiveHtlcs(nodes, payHash)
|
return assertActiveHtlcs(nodes, payHash[:])
|
||||||
}, defaultTimeout)
|
}, defaultTimeout)
|
||||||
require.NoError(t.t, err)
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
@ -73,7 +82,7 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
|
|||||||
// transaction. This will let us exercise that Bob is able to sweep the
|
// transaction. This will let us exercise that Bob is able to sweep the
|
||||||
// expired HTLC on Carol's version of the commitment transaction. If
|
// expired HTLC on Carol's version of the commitment transaction. If
|
||||||
// Carol has an anchor, it will be swept too.
|
// Carol has an anchor, it will be swept too.
|
||||||
ctxt, _ := context.WithTimeout(ctxb, channelCloseTimeout)
|
ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout)
|
||||||
closeChannelAndAssertType(
|
closeChannelAndAssertType(
|
||||||
ctxt, t, net, carol, bobChanPoint, c == commitTypeAnchors,
|
ctxt, t, net, carol, bobChanPoint, c == commitTypeAnchors,
|
||||||
true,
|
true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user