sweep: add new state TxFatal for erroneous sweepings

Also updated the loggings. This new state will be used in the following
commit.
This commit is contained in:
yyforyongyu
2024-04-30 17:13:57 +08:00
committed by yyforyongyu
parent 1dfb5a0c20
commit 6c2e8b9a00
3 changed files with 68 additions and 16 deletions

View File

@@ -91,6 +91,19 @@ func TestBumpResultValidate(t *testing.T) {
}
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
// A failed event without a tx will give an error.
b = BumpResult{
Event: TxFailed,
Err: errDummy,
}
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
// A fatal event without a failure reason will give an error.
b = BumpResult{
Event: TxFailed,
}
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
// A confirmed event without fee info will give an error.
b = BumpResult{
Tx: &wire.MsgTx{},
@@ -104,6 +117,13 @@ func TestBumpResultValidate(t *testing.T) {
Event: TxPublished,
}
require.NoError(t, b.Validate())
// Tx is allowed to be nil in a TxFatal event.
b = BumpResult{
Event: TxFatal,
Err: errDummy,
}
require.NoError(t, b.Validate())
}
// TestCalcSweepTxWeight checks that the weight of the sweep tx is calculated