mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
multi: add new config option BudgetConfig
and NoDeadlineConfTarget
This commit adds a new group config `BudgetConfig` to allow users specifying their own preference when sweeping outputs. And a new config option `NoDeadlineConfTarget` is added in case the user wants to use a different "lazy" conf target.
This commit is contained in:
83
contractcourt/config_test.go
Normal file
83
contractcourt/config_test.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package contractcourt
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestBudgetConfigValidate checks that the budget config validation works as
|
||||
// expected.
|
||||
func TestBudgetConfigValidate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
cfg *BudgetConfig
|
||||
expectedErrStr string
|
||||
}{
|
||||
{
|
||||
name: "valid config",
|
||||
cfg: DefaultBudgetConfig(),
|
||||
},
|
||||
{
|
||||
name: "nil config",
|
||||
cfg: nil,
|
||||
expectedErrStr: "no budget config set",
|
||||
},
|
||||
{
|
||||
name: "invalid tolocal",
|
||||
cfg: &BudgetConfig{ToLocal: -1},
|
||||
expectedErrStr: "tolocal",
|
||||
},
|
||||
{
|
||||
name: "invalid tolocalratio",
|
||||
cfg: &BudgetConfig{ToLocalRatio: -1},
|
||||
expectedErrStr: "tolocalratio",
|
||||
},
|
||||
{
|
||||
name: "invalid anchorcpfp",
|
||||
cfg: &BudgetConfig{AnchorCPFP: -1},
|
||||
expectedErrStr: "anchorcpfp",
|
||||
},
|
||||
{
|
||||
name: "invalid anchorcpfpratio",
|
||||
cfg: &BudgetConfig{AnchorCPFPRatio: -1},
|
||||
expectedErrStr: "anchorcpfpratio",
|
||||
},
|
||||
{
|
||||
name: "invalid deadlinehtlc",
|
||||
cfg: &BudgetConfig{DeadlineHTLC: -1},
|
||||
expectedErrStr: "deadlinehtlc",
|
||||
},
|
||||
{
|
||||
name: "invalid deadlinehtlcratio",
|
||||
cfg: &BudgetConfig{DeadlineHTLCRatio: -1},
|
||||
expectedErrStr: "deadlinehtlcratio",
|
||||
},
|
||||
|
||||
{
|
||||
name: "invalid nodeadlinehtlc",
|
||||
cfg: &BudgetConfig{NoDeadlineHTLC: -1},
|
||||
expectedErrStr: "nodeadlinehtlc",
|
||||
},
|
||||
{
|
||||
name: "invalid nodeadlinehtlcratio",
|
||||
cfg: &BudgetConfig{NoDeadlineHTLCRatio: -1},
|
||||
expectedErrStr: "nodeadlinehtlcratio",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
err := tc.cfg.Validate()
|
||||
|
||||
if tc.expectedErrStr == "" {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
|
||||
require.ErrorContains(t, err, tc.expectedErrStr)
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user