mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 03:01:52 +01:00
This commit adds a new interface, `Bumper`, to handle RBF for a given input set. It's responsible for creating the sweeping tx using the input set, and monitors its confirmation status to decide whether a RBF should be attempted or not. We leave implementation details to future commits, and focus on mounting this `Bumper` interface to our sweeper in this commit.
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package sweep
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/btcsuite/btcd/wire"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestBumpResultValidate tests the validate method of the BumpResult struct.
|
|
func TestBumpResultValidate(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
// An empty result will give an error.
|
|
b := BumpResult{}
|
|
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
|
|
|
|
// Unknown event type will give an error.
|
|
b = BumpResult{
|
|
Tx: &wire.MsgTx{},
|
|
Event: sentinalEvent,
|
|
}
|
|
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
|
|
|
|
// A replacing event without a new tx will give an error.
|
|
b = BumpResult{
|
|
Tx: &wire.MsgTx{},
|
|
Event: TxReplaced,
|
|
}
|
|
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
|
|
|
|
// A failed event without a failure reason will give an error.
|
|
b = BumpResult{
|
|
Tx: &wire.MsgTx{},
|
|
Event: TxFailed,
|
|
}
|
|
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
|
|
|
|
// A confirmed event without fee info will give an error.
|
|
b = BumpResult{
|
|
Tx: &wire.MsgTx{},
|
|
Event: TxConfirmed,
|
|
}
|
|
require.ErrorIs(t, b.Validate(), ErrInvalidBumpResult)
|
|
|
|
// Test a valid result.
|
|
b = BumpResult{
|
|
Tx: &wire.MsgTx{},
|
|
Event: TxPublished,
|
|
}
|
|
require.NoError(t, b.Validate())
|
|
}
|