From 5e5bc3884a1b935efc31bfeda8e95fb8f57d4412 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 21 Nov 2016 21:13:03 -0600 Subject: [PATCH] test: modify closeChannelAndAssert to allow force close, return txid --- lnd_test.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lnd_test.go b/lnd_test.go index 5208e640..d443e603 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -161,9 +161,9 @@ func openChannelAndAssert(t *harnessTest, net *networkHarness, ctx context.Conte // detected as closed, an assertion checks that the transaction is found within // a block. func closeChannelAndAssert(t *harnessTest, net *networkHarness, ctx context.Context, - node *lightningNode, fundingChanPoint *lnrpc.ChannelPoint) { + node *lightningNode, fundingChanPoint *lnrpc.ChannelPoint, force bool) *wire.ShaHash { - closeUpdates, err := net.CloseChannel(ctx, node, fundingChanPoint, false) + closeUpdates, err := net.CloseChannel(ctx, node, fundingChanPoint, force) if err != nil { t.Fatalf("unable to close channel: %v", err) } @@ -179,6 +179,8 @@ func closeChannelAndAssert(t *harnessTest, net *networkHarness, ctx context.Cont } assertTxInBlock(t, block, closingTxid) + + return closingTxid } // testBasicChannelFunding performs a test exercising expected behavior from a @@ -204,7 +206,7 @@ func testBasicChannelFunding(net *networkHarness, t *harnessTest) { // block until the channel is closed and will additionally assert the // relevant channel closing post conditions. ctxt, _ = context.WithTimeout(ctxb, timeout) - closeChannelAndAssert(t, net, ctxt, net.Alice, chanPoint) + closeChannelAndAssert(t, net, ctxt, net.Alice, chanPoint, false) } // testChannelBalance creates a new channel between Alice and Bob, then @@ -255,7 +257,7 @@ func testChannelBalance(net *networkHarness, t *harnessTest) { // Finally close the channel between Alice and Bob, asserting that the // channel has been properly closed on-chain. ctx, _ = context.WithTimeout(context.Background(), timeout) - closeChannelAndAssert(t, net, ctx, net.Alice, chanPoint) + closeChannelAndAssert(t, net, ctx, net.Alice, chanPoint, false) } // testChannelForceClosure performs a test to exercise the behavior of "force" @@ -459,7 +461,7 @@ func testSingleHopInvoice(net *networkHarness, t *harnessTest) { } ctxt, _ = context.WithTimeout(ctxb, timeout) - closeChannelAndAssert(t, net, ctxt, net.Alice, chanPoint) + closeChannelAndAssert(t, net, ctxt, net.Alice, chanPoint, false) } func testMultiHopPayments(net *networkHarness, t *harnessTest) { @@ -696,9 +698,9 @@ func testMultiHopPayments(net *networkHarness, t *harnessTest) { assertAsymmetricBalance(carol, carolFundPoint, sourceBal, sinkBal) ctxt, _ = context.WithTimeout(ctxb, timeout) - closeChannelAndAssert(t, net, ctxt, net.Alice, chanPointAlice) + closeChannelAndAssert(t, net, ctxt, net.Alice, chanPointAlice, false) ctxt, _ = context.WithTimeout(ctxb, timeout) - closeChannelAndAssert(t, net, ctxt, carol, chanPointCarol) + closeChannelAndAssert(t, net, ctxt, carol, chanPointCarol, false) } func testInvoiceSubscriptions(net *networkHarness, t *harnessTest) { @@ -778,7 +780,7 @@ func testInvoiceSubscriptions(net *networkHarness, t *harnessTest) { } ctxt, _ = context.WithTimeout(ctxb, timeout) - closeChannelAndAssert(t, net, ctxt, net.Alice, chanPoint) + closeChannelAndAssert(t, net, ctxt, net.Alice, chanPoint, false) } // testBasicChannelCreation test multiple channel opening and closing. @@ -802,7 +804,7 @@ func testBasicChannelCreation(net *networkHarness, t *harnessTest) { // channel has been properly closed on-chain. for _, chanPoint := range chanPoints { ctx, _ := context.WithTimeout(context.Background(), timeout) - closeChannelAndAssert(t, net, ctx, net.Alice, chanPoint) + closeChannelAndAssert(t, net, ctx, net.Alice, chanPoint, false) } } @@ -902,7 +904,7 @@ func testMaxPendingChannels(net *networkHarness, t *harnessTest) { // channel has been properly closed on-chain. for _, chanPoint := range chanPoints { ctx, _ = context.WithTimeout(context.Background(), timeout) - closeChannelAndAssert(t, net, ctx, net.Alice, chanPoint) + closeChannelAndAssert(t, net, ctx, net.Alice, chanPoint, false) } }