itest: extract multi-hop tests into sub tests
This commit is contained in:
2 files changed
+65
-36
No files matched your search
@@ -5,6 +5,7 @@ package itest
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
@@ -17,6 +18,68 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func testMultiHopHtlcClaims(net *lntest.NetworkHarness, t *harnessTest) {
|
||||||
|
|
||||||
|
type testCase struct {
|
||||||
|
name string
|
||||||
|
test func(net *lntest.NetworkHarness, t *harnessTest)
|
||||||
|
}
|
||||||
|
|
||||||
|
subTests := []testCase{
|
||||||
|
{
|
||||||
|
// bob: outgoing our commit timeout
|
||||||
|
// carol: incoming their commit watch and see timeout
|
||||||
|
name: "local force close immediate expiry",
|
||||||
|
test: testMultiHopHtlcLocalTimeout,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// bob: outgoing watch and see, they sweep on chain
|
||||||
|
// carol: incoming our commit, know preimage
|
||||||
|
name: "receiver chain claim",
|
||||||
|
test: testMultiHopReceiverChainClaim,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// bob: outgoing our commit watch and see timeout
|
||||||
|
// carol: incoming their commit watch and see timeout
|
||||||
|
name: "local force close on-chain htlc timeout",
|
||||||
|
test: testMultiHopLocalForceCloseOnChainHtlcTimeout,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// bob: outgoing their commit watch and see timeout
|
||||||
|
// carol: incoming our commit watch and see timeout
|
||||||
|
name: "remote force close on-chain htlc timeout",
|
||||||
|
test: testMultiHopRemoteForceCloseOnChainHtlcTimeout,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// bob: outgoing our commit watch and see, they sweep on chain
|
||||||
|
// bob: incoming our commit watch and learn preimage
|
||||||
|
// carol: incoming their commit know preimage
|
||||||
|
name: "local chain claim",
|
||||||
|
test: testMultiHopHtlcLocalChainClaim,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// bob: outgoing their commit watch and see, they sweep on chain
|
||||||
|
// bob: incoming their commit watch and learn preimage
|
||||||
|
// carol: incoming our commit know preimage
|
||||||
|
name: "remote chain claim",
|
||||||
|
test: testMultiHopHtlcRemoteChainClaim,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, subTest := range subTests {
|
||||||
|
subTest := subTest
|
||||||
|
|
||||||
|
success := t.t.Run(subTest.name, func(t *testing.T) {
|
||||||
|
ht := newHarnessTest(t, net)
|
||||||
|
|
||||||
|
subTest.test(net, ht)
|
||||||
|
})
|
||||||
|
if !success {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// testMultiHopHtlcLocalChainClaim tests that in a multi-hop HTLC scenario, if
|
// testMultiHopHtlcLocalChainClaim tests that in a multi-hop HTLC scenario, if
|
||||||
// we force close a channel with an incoming HTLC, and later find out the
|
// we force close a channel with an incoming HTLC, and later find out the
|
||||||
// preimage via the witness beacon, we properly settle the HTLC on-chain using
|
// preimage via the witness beacon, we properly settle the HTLC on-chain using
|
||||||
|
|||||||
@@ -14551,42 +14551,8 @@ var testsCases = []*testCase{
|
|||||||
test: testBidirectionalAsyncPayments,
|
test: testBidirectionalAsyncPayments,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// bob: outgoing our commit timeout
|
name: "test multi-hop htlc",
|
||||||
// carol: incoming their commit watch and see timeout
|
test: testMultiHopHtlcClaims,
|
||||||
name: "test multi-hop htlc local force close immediate expiry",
|
|
||||||
test: testMultiHopHtlcLocalTimeout,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// bob: outgoing watch and see, they sweep on chain
|
|
||||||
// carol: incoming our commit, know preimage
|
|
||||||
name: "test multi-hop htlc receiver chain claim",
|
|
||||||
test: testMultiHopReceiverChainClaim,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// bob: outgoing our commit watch and see timeout
|
|
||||||
// carol: incoming their commit watch and see timeout
|
|
||||||
name: "test multi-hop local force close on-chain htlc timeout",
|
|
||||||
test: testMultiHopLocalForceCloseOnChainHtlcTimeout,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// bob: outgoing their commit watch and see timeout
|
|
||||||
// carol: incoming our commit watch and see timeout
|
|
||||||
name: "test multi-hop remote force close on-chain htlc timeout",
|
|
||||||
test: testMultiHopRemoteForceCloseOnChainHtlcTimeout,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// bob: outgoing our commit watch and see, they sweep on chain
|
|
||||||
// bob: incoming our commit watch and learn preimage
|
|
||||||
// carol: incoming their commit know preimage
|
|
||||||
name: "test multi-hop htlc local chain claim",
|
|
||||||
test: testMultiHopHtlcLocalChainClaim,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// bob: outgoing their commit watch and see, they sweep on chain
|
|
||||||
// bob: incoming their commit watch and learn preimage
|
|
||||||
// carol: incoming our commit know preimage
|
|
||||||
name: "test multi-hop htlc remote chain claim",
|
|
||||||
test: testMultiHopHtlcRemoteChainClaim,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "switch circuit persistence",
|
name: "switch circuit persistence",
|
||||||
|
|||||||
Reference in new issue
Block a user