Merge pull request #3789 from cfromknecht/coop-close-rpc-status
republish force and coop closes on startup
This commit is contained in:
8 files changed
+269
-65
No files matched your search
@@ -992,9 +992,28 @@ func TestFetchWaitingCloseChannels(t *testing.T) {
|
||||
PreviousOutPoint: channel.FundingOutpoint,
|
||||
},
|
||||
)
|
||||
|
||||
if err := channel.MarkCommitmentBroadcasted(closeTx); err != nil {
|
||||
t.Fatalf("unable to mark commitment broadcast: %v", err)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
// Now, we'll fetch all the channels waiting to be closed from the
|
||||
@@ -1004,7 +1023,7 @@ func TestFetchWaitingCloseChannels(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to fetch all waiting close channels: %v", err)
|
||||
}
|
||||
if len(waitingCloseChannels) != 2 {
|
||||
if len(waitingCloseChannels) != numChannels {
|
||||
t.Fatalf("expected %d channels waiting to be closed, got %d", 2,
|
||||
len(waitingCloseChannels))
|
||||
}
|
||||
@@ -1018,17 +1037,31 @@ func TestFetchWaitingCloseChannels(t *testing.T) {
|
||||
channel.FundingOutpoint)
|
||||
}
|
||||
|
||||
// Finally, make sure we can retrieve the closing tx for the
|
||||
// channel.
|
||||
closeTx, err := channel.BroadcastedCommitment()
|
||||
chanPoint := channel.FundingOutpoint
|
||||
|
||||
// Assert that the force close transaction is retrievable.
|
||||
forceCloseTx, err := channel.BroadcastedCommitment()
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to retrieve commitment: %v", err)
|
||||
}
|
||||
|
||||
if closeTx.TxIn[0].PreviousOutPoint != channel.FundingOutpoint {
|
||||
if forceCloseTx.TxIn[0].PreviousOutPoint != chanPoint {
|
||||
t.Fatalf("expected outpoint %v, got %v",
|
||||
channel.FundingOutpoint,
|
||||
closeTx.TxIn[0].PreviousOutPoint)
|
||||
chanPoint,
|
||||
forceCloseTx.TxIn[0].PreviousOutPoint)
|
||||
}
|
||||
|
||||
// Assert that the coop close transaction is retrievable.
|
||||
coopCloseTx, err := channel.BroadcastedCooperative()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to retrieve coop close: %v", err)
|
||||
}
|
||||
|
||||
chanPoint.Index ^= 1
|
||||
if coopCloseTx.TxIn[0].PreviousOutPoint != chanPoint {
|
||||
t.Fatalf("expected outpoint %v, got %v",
|
||||
chanPoint,
|
||||
coopCloseTx.TxIn[0].PreviousOutPoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user