mirror of
https://github.com/aljazceru/lspd.git
synced 2025-12-19 06:44:23 +01:00
Spend unconfirmed utxos if minconfs=0
This commit is contained in:
@@ -7,31 +7,55 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/breez/lntest"
|
||||
"github.com/breez/lspd/config"
|
||||
)
|
||||
|
||||
var defaultTimeout time.Duration = time.Second * 120
|
||||
|
||||
func TestLspd(t *testing.T) {
|
||||
testCases := allTestCases
|
||||
runTests(t, testCases, "LND-lspd", func(h *lntest.TestHarness, m *lntest.Miner) (LspNode, BreezClient) {
|
||||
return NewLndLspdNode(h, m, "lsp"), newLndBreezClient(h, m, "breez-client")
|
||||
})
|
||||
|
||||
runTests(t, testCases, "CLN-lspd", func(h *lntest.TestHarness, m *lntest.Miner) (LspNode, BreezClient) {
|
||||
return NewClnLspdNode(h, m, "lsp"), newClnBreezClient(h, m, "breez-client")
|
||||
})
|
||||
runTests(t, testCases, "LND-lspd", lndLspFunc, lndClientFunc)
|
||||
runTests(t, testCases, "CLN-lspd", clnLspFunc, clnClientFunc)
|
||||
}
|
||||
|
||||
func runTests(t *testing.T, testCases []*testCase, prefix string, nodesFunc func(h *lntest.TestHarness, m *lntest.Miner) (LspNode, BreezClient)) {
|
||||
func lndLspFunc(h *lntest.TestHarness, m *lntest.Miner, c *config.NodeConfig) LspNode {
|
||||
return NewLndLspdNode(h, m, "lsp", c)
|
||||
}
|
||||
|
||||
func clnLspFunc(h *lntest.TestHarness, m *lntest.Miner, c *config.NodeConfig) LspNode {
|
||||
return NewClnLspdNode(h, m, "lsp", c)
|
||||
}
|
||||
|
||||
func lndClientFunc(h *lntest.TestHarness, m *lntest.Miner) BreezClient {
|
||||
return newLndBreezClient(h, m, "breez-client")
|
||||
}
|
||||
|
||||
func clnClientFunc(h *lntest.TestHarness, m *lntest.Miner) BreezClient {
|
||||
return newClnBreezClient(h, m, "breez-client")
|
||||
}
|
||||
|
||||
func runTests(
|
||||
t *testing.T,
|
||||
testCases []*testCase,
|
||||
prefix string,
|
||||
lspFunc LspFunc,
|
||||
clientFunc ClientFunc,
|
||||
) {
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(fmt.Sprintf("%s: %s", prefix, testCase.name), func(t *testing.T) {
|
||||
runTest(t, testCase, prefix, nodesFunc)
|
||||
runTest(t, testCase, prefix, lspFunc, clientFunc)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func runTest(t *testing.T, testCase *testCase, prefix string, nodesFunc func(h *lntest.TestHarness, m *lntest.Miner) (LspNode, BreezClient)) {
|
||||
func runTest(
|
||||
t *testing.T,
|
||||
testCase *testCase,
|
||||
prefix string,
|
||||
lspFunc LspFunc,
|
||||
clientFunc ClientFunc,
|
||||
) {
|
||||
log.Printf("%s: Running test case '%s'", prefix, testCase.name)
|
||||
var dd time.Duration
|
||||
to := testCase.timeout
|
||||
@@ -49,23 +73,30 @@ func runTest(t *testing.T, testCase *testCase, prefix string, nodesFunc func(h *
|
||||
miner := lntest.NewMiner(h)
|
||||
miner.Start()
|
||||
log.Printf("Creating lsp")
|
||||
lsp, c := nodesFunc(h, miner)
|
||||
lsp.Start()
|
||||
var lsp LspNode
|
||||
if !testCase.skipCreateLsp {
|
||||
lsp = lspFunc(h, miner, nil)
|
||||
lsp.Start()
|
||||
}
|
||||
c := clientFunc(h, miner)
|
||||
c.Start()
|
||||
log.Printf("Run testcase")
|
||||
testCase.test(&testParams{
|
||||
t: t,
|
||||
h: h,
|
||||
m: miner,
|
||||
c: c,
|
||||
lsp: lsp,
|
||||
t: t,
|
||||
h: h,
|
||||
m: miner,
|
||||
c: c,
|
||||
lsp: lsp,
|
||||
lspFunc: lspFunc,
|
||||
clientFunc: clientFunc,
|
||||
})
|
||||
}
|
||||
|
||||
type testCase struct {
|
||||
name string
|
||||
test func(t *testParams)
|
||||
timeout time.Duration
|
||||
name string
|
||||
test func(t *testParams)
|
||||
skipCreateLsp bool
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
var allTestCases = []*testCase{
|
||||
@@ -105,4 +136,9 @@ var allTestCases = []*testCase{
|
||||
name: "registerPaymentWithTag",
|
||||
test: registerPaymentWithTag,
|
||||
},
|
||||
{
|
||||
name: "testOpenZeroConfUtxo",
|
||||
test: testOpenZeroConfUtxo,
|
||||
skipCreateLsp: true,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user