mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 01:33:02 +01:00
sweep: allow published input to be marked as PublishFailed
If anything happens during the fee bumping process, and causes the input to be failed, we should be able to mark it as `PublishFailed`.
This commit is contained in:
parent
acde08c65a
commit
a2b8f4e19c
@ -961,7 +961,7 @@ func (s *UtxoSweeper) markInputsPublishFailed(outpoints []wire.OutPoint) {
|
||||
}
|
||||
|
||||
// Valdiate that the input is in an expected state.
|
||||
if pi.state != PendingPublish {
|
||||
if pi.state != PendingPublish && pi.state != Published {
|
||||
log.Errorf("Expect input %v to have %v, instead it "+
|
||||
"has %v", op, PendingPublish, pi.state)
|
||||
|
||||
|
@ -2274,8 +2274,8 @@ func TestMarkInputsPublished(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestMarkInputsPublishFailed checks that given a list of inputs with
|
||||
// different states, only the state `PendingPublish` will be marked as
|
||||
// `PublishFailed`.
|
||||
// different states, only the state `PendingPublish` and `Published` will be
|
||||
// marked as `PublishFailed`.
|
||||
func TestMarkInputsPublishFailed(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@ -2315,6 +2315,14 @@ func TestMarkInputsPublishFailed(t *testing.T) {
|
||||
state: PendingPublish,
|
||||
}
|
||||
|
||||
// inputPublished specifies an input that's published.
|
||||
inputPublished := &wire.TxIn{
|
||||
PreviousOutPoint: wire.OutPoint{Index: 4},
|
||||
}
|
||||
s.inputs[inputPublished.PreviousOutPoint] = &SweeperInput{
|
||||
state: Published,
|
||||
}
|
||||
|
||||
// Mark the test inputs. We expect the non-exist input and the
|
||||
// inputInit to be skipped, and the final input to be marked as
|
||||
// published.
|
||||
@ -2322,10 +2330,11 @@ func TestMarkInputsPublishFailed(t *testing.T) {
|
||||
inputNotExist.PreviousOutPoint,
|
||||
inputInit.PreviousOutPoint,
|
||||
inputPendingPublish.PreviousOutPoint,
|
||||
inputPublished.PreviousOutPoint,
|
||||
})
|
||||
|
||||
// We expect unchanged number of pending inputs.
|
||||
require.Len(s.inputs, 2)
|
||||
require.Len(s.inputs, 3)
|
||||
|
||||
// We expect the init input's state to stay unchanged.
|
||||
require.Equal(Init,
|
||||
@ -2336,6 +2345,10 @@ func TestMarkInputsPublishFailed(t *testing.T) {
|
||||
require.Equal(PublishFailed,
|
||||
s.inputs[inputPendingPublish.PreviousOutPoint].state)
|
||||
|
||||
// We expect the published input's is now marked as publish failed.
|
||||
require.Equal(PublishFailed,
|
||||
s.inputs[inputPublished.PreviousOutPoint].state)
|
||||
|
||||
// Assert mocked statements are executed as expected.
|
||||
mockStore.AssertExpectations(t)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user