From d6045a0fd575daca24539a4ce676dfb3d8dbe17f Mon Sep 17 00:00:00 2001 From: Torkel Rogstad Date: Thu, 26 Aug 2021 15:17:35 +0200 Subject: [PATCH] lntest: avoid global ServeMux Using the default, global ServeMux prevents the same process from calling `lntest.NewNetworkHarness` multiple times, because we get a panic when registering HTTP routes. Instead, we use the ServeMux beloning to the fee service struct. --- docs/release-notes/release-notes-0.13.1.md | 4 ++++ lntest/fee_service.go | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/release-notes-0.13.1.md b/docs/release-notes/release-notes-0.13.1.md index 76da2aea..a9c3334b 100644 --- a/docs/release-notes/release-notes-0.13.1.md +++ b/docs/release-notes/release-notes-0.13.1.md @@ -42,6 +42,10 @@ tag](https://github.com/lightningnetwork/lnd/pull/5335). A new flag test](https://github.com/lightningnetwork/lnd/pull/5348) that would cause the test to assert the wrong balance (the miner fee wasn't accounted for). +A bug has been [fixed](https://github.com/lightningnetwork/lnd/pull/5674) in +the `lntest` package that prevented multiple test harnesses to be created from +the same process. + ## Forwarding Optimizations [Decoding onion blobs is now done in diff --git a/lntest/fee_service.go b/lntest/fee_service.go index f8dbac21..bf80fa0d 100644 --- a/lntest/fee_service.go +++ b/lntest/fee_service.go @@ -46,11 +46,13 @@ func startFeeService() *feeService { f.Fees = map[uint32]uint32{feeServiceTarget: 50000} listenAddr := fmt.Sprintf(":%v", port) - f.srv = &http.Server{ - Addr: listenAddr, - } + mux := http.NewServeMux() + mux.HandleFunc("/fee-estimates.json", f.handleRequest) - http.HandleFunc("/fee-estimates.json", f.handleRequest) + f.srv = &http.Server{ + Addr: listenAddr, + Handler: mux, + } f.wg.Add(1) go func() {