channeldb/channel: allow storing empty closes

This is preparation for the subsequent commit, allowing us to fix a race
condition in the integration test assertions.
This commit is contained in:
Conner Fromknecht committed 2019-12-04 14:25:29 -08:00
1 parent d9cf0396b3
commit 46990c412c
2 files changed
+30 -9

No files matched your search

+14 -3
View File
@@ -897,13 +897,24 @@ func TestFetchWaitingCloseChannels(t *testing.T) {
PreviousOutPoint: channel.FundingOutpoint,
},
)
if err := channel.MarkCommitmentBroadcasted(closeTx); err != nil {
t.Fatalf("unable to mark commitment broadcast: %v", err)
}
// Modify the close tx deterministically and also mark it as
// coop closed. Later we will test that distinct transactions
// are returned for both coop and force closes.
// Now try to marking a coop close with a nil tx. This should
// succeed, but it shouldn't exit when queried.
if err = channel.MarkCoopBroadcasted(nil); err != nil {
t.Fatalf("unable to mark nil coop broadcast: %v", err)
}
_, err := channel.BroadcastedCooperative()
if err != ErrNoCloseTx {
t.Fatalf("expected no closing tx error, got: %v", err)
}
// Finally, modify the close tx deterministically and also mark
// it as coop closed. Later we will test that distinct
// transactions are returned for both coop and force closes.
closeTx.TxIn[0].PreviousOutPoint.Index ^= 1
if err := channel.MarkCoopBroadcasted(closeTx); err != nil {
t.Fatalf("unable to mark coop broadcast: %v", err)