mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
lnd_test: check close status also for force closes
This commit makes sure the channels that are force closed also are put into the state "waiting close" before the commitment transaction is confirmed, and exits this state when it confirms. This was previously not checked, as this check was added before the "waiting close" state was introduced.
This commit is contained in:
parent
f73a2f362e
commit
45a1fa54d8
1 changed files with 32 additions and 36 deletions
68
lnd_test.go
68
lnd_test.go
|
@ -220,25 +220,23 @@ func closeChannelAndAssert(ctx context.Context, t *harnessTest,
|
||||||
}
|
}
|
||||||
chanPointStr := fmt.Sprintf("%v:%v", txid, fundingChanPoint.OutputIndex)
|
chanPointStr := fmt.Sprintf("%v:%v", txid, fundingChanPoint.OutputIndex)
|
||||||
|
|
||||||
// If we didn't force close the transaction, at this point, the channel
|
// At this point, the channel should now be marked as being in the
|
||||||
// should now be marked as being in the state of "waiting close".
|
// state of "waiting close".
|
||||||
if !force {
|
pendingChansRequest := &lnrpc.PendingChannelsRequest{}
|
||||||
pendingChansRequest := &lnrpc.PendingChannelsRequest{}
|
pendingChanResp, err := node.PendingChannels(ctx, pendingChansRequest)
|
||||||
pendingChanResp, err := node.PendingChannels(ctx, pendingChansRequest)
|
if err != nil {
|
||||||
if err != nil {
|
t.Fatalf("unable to query for pending channels: %v", err)
|
||||||
t.Fatalf("unable to query for pending channels: %v", err)
|
}
|
||||||
}
|
var found bool
|
||||||
var found bool
|
for _, pendingClose := range pendingChanResp.WaitingCloseChannels {
|
||||||
for _, pendingClose := range pendingChanResp.WaitingCloseChannels {
|
if pendingClose.Channel.ChannelPoint == chanPointStr {
|
||||||
if pendingClose.Channel.ChannelPoint == chanPointStr {
|
found = true
|
||||||
found = true
|
break
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
t.Fatalf("channel not marked as waiting close")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !found {
|
||||||
|
t.Fatalf("channel not marked as waiting close")
|
||||||
|
}
|
||||||
|
|
||||||
// We'll now, generate a single block, wait for the final close status
|
// We'll now, generate a single block, wait for the final close status
|
||||||
// update, then ensure that the closing transaction was included in the
|
// update, then ensure that the closing transaction was included in the
|
||||||
|
@ -254,28 +252,26 @@ func closeChannelAndAssert(ctx context.Context, t *harnessTest,
|
||||||
|
|
||||||
// Finally, the transaction should no longer be in the waiting close
|
// Finally, the transaction should no longer be in the waiting close
|
||||||
// state as we've just mined a block that should include the closing
|
// state as we've just mined a block that should include the closing
|
||||||
// transaction. This only applies for co-op close channels though.
|
// transaction.
|
||||||
if !force {
|
err = lntest.WaitPredicate(func() bool {
|
||||||
err = lntest.WaitPredicate(func() bool {
|
pendingChansRequest := &lnrpc.PendingChannelsRequest{}
|
||||||
pendingChansRequest := &lnrpc.PendingChannelsRequest{}
|
pendingChanResp, err := node.PendingChannels(
|
||||||
pendingChanResp, err := node.PendingChannels(
|
ctx, pendingChansRequest,
|
||||||
ctx, pendingChansRequest,
|
)
|
||||||
)
|
if err != nil {
|
||||||
if err != nil {
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pendingClose := range pendingChanResp.WaitingCloseChannels {
|
||||||
|
if pendingClose.Channel.ChannelPoint == chanPointStr {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pendingClose := range pendingChanResp.WaitingCloseChannels {
|
|
||||||
if pendingClose.Channel.ChannelPoint == chanPointStr {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}, time.Second*15)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("closing transaction not marked as fully closed")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}, time.Second*15)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("closing transaction not marked as fully closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
return closingTxid
|
return closingTxid
|
||||||
|
|
Loading…
Add table
Reference in a new issue