itest: extract multi-hop tests into sub tests

This commit is contained in:
Johan T. Halseth committed 2020-03-23 11:13:26 +01:00
1 parent 5a0f2d004a
commit 1ce4abc0a9
2 files changed
+65 -36

No files matched your search

@@ -5,6 +5,7 @@ package itest
import (
"context"
"fmt"
"testing"
"time"
"github.com/btcsuite/btcd/wire"
@@ -17,6 +18,68 @@ import (
"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
// 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
+2 -36
View File
@@ -14551,42 +14551,8 @@ var testsCases = []*testCase{
test: testBidirectionalAsyncPayments,
},
{
// bob: outgoing our commit timeout
// carol: incoming their commit watch and see timeout
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: "test multi-hop htlc",
test: testMultiHopHtlcClaims,
},
{
name: "switch circuit persistence",