From 2195c714073cc70a16695610f69cb9e5d392d510 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 22 Mar 2022 13:54:27 +0100 Subject: [PATCH 1/3] chainview: fix formatting --- routing/chainview/interface_test.go | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/routing/chainview/interface_test.go b/routing/chainview/interface_test.go index 3b0cf8ed6..c0cb2a5ee 100644 --- a/routing/chainview/interface_test.go +++ b/routing/chainview/interface_test.go @@ -553,8 +553,9 @@ func testFilterBlockDisconnected(node *rpctest.Harness, } // Init a chain view that has this node as its block source. - cleanUpFunc, reorgView, err := chainViewInit(reorgNode.RPCConfig(), - reorgNode.P2PAddress()) + cleanUpFunc, reorgView, err := chainViewInit( + reorgNode.RPCConfig(), reorgNode.P2PAddress(), + ) if err != nil { t.Fatalf("unable to create chain view: %v", err) } @@ -775,7 +776,9 @@ var interfaceImpls = []struct { }{ { name: "bitcoind_zmq", - chainViewInit: func(_ rpcclient.ConnConfig, p2pAddr string) (func(), FilteredChainView, error) { + chainViewInit: func(_ rpcclient.ConnConfig, + p2pAddr string) (func(), FilteredChainView, error) { + // Start a bitcoind instance. tempBitcoindDir, err := ioutil.TempDir("", "bitcoind") if err != nil { @@ -855,7 +858,9 @@ var interfaceImpls = []struct { }, { name: "p2p_neutrino", - chainViewInit: func(_ rpcclient.ConnConfig, p2pAddr string) (func(), FilteredChainView, error) { + chainViewInit: func(_ rpcclient.ConnConfig, + p2pAddr string) (func(), FilteredChainView, error) { + spvDir, err := ioutil.TempDir("", "neutrino") if err != nil { return nil, nil, err @@ -908,7 +913,9 @@ var interfaceImpls = []struct { }, { name: "btcd_websockets", - chainViewInit: func(config rpcclient.ConnConfig, _ string) (func(), FilteredChainView, error) { + chainViewInit: func(config rpcclient.ConnConfig, + _ string) (func(), FilteredChainView, error) { + blockCache := blockcache.NewBlockCache(10000) chainView, err := NewBtcdFilteredChainView( config, blockCache, @@ -943,7 +950,9 @@ func TestFilteredChainView(t *testing.T) { t.Logf("Testing '%v' implementation of FilteredChainView", chainViewImpl.name) - cleanUpFunc, chainView, err := chainViewImpl.chainViewInit(rpcConfig, p2pAddr) + cleanUpFunc, chainView, err := chainViewImpl.chainViewInit( + rpcConfig, p2pAddr, + ) if err != nil { t.Fatalf("unable to make chain view: %v", err) } @@ -955,8 +964,10 @@ func TestFilteredChainView(t *testing.T) { testName := fmt.Sprintf("%v: %v", chainViewImpl.name, chainViewTest.name) success := t.Run(testName, func(t *testing.T) { - chainViewTest.test(miner, chainView, - chainViewImpl.chainViewInit, t) + chainViewTest.test( + miner, chainView, + chainViewImpl.chainViewInit, t, + ) }) if !success { From 1c0b4fd1de9cb140b06094f309c7ef846a6c3c13 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 22 Mar 2022 13:54:49 +0100 Subject: [PATCH 2/3] chainview: increase connection timeout in test The unit test sometimes fails with a connection timeout when trying to connect to the reorg mining node. We attempt to make things more robust by doubling both the number of retries as well as the retry timeout itself. --- routing/chainview/interface_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routing/chainview/interface_test.go b/routing/chainview/interface_test.go index c0cb2a5ee..fca3191f4 100644 --- a/routing/chainview/interface_test.go +++ b/routing/chainview/interface_test.go @@ -547,6 +547,14 @@ func testFilterBlockDisconnected(node *rpctest.Harness, } defer reorgNode.TearDown() + // We want to overwrite some of the connection settings to make the + // tests more robust. We might need to restart the backend while there + // are already blocks present, which will take a bit longer than the + // 1 second the default settings amount to. Doubling both values will + // give us retries up to 4 seconds. + reorgNode.MaxConnRetries = rpctest.DefaultMaxConnectionRetries * 2 + reorgNode.ConnectionRetryTimeout = rpctest.DefaultConnectionRetryTimeout * 2 + // This node's chain will be 105 blocks. if err := reorgNode.SetUp(true, 5); err != nil { t.Fatalf("unable to set up mining node: %v", err) From 3f757e56a7aabbaa912d6fcd884047af2e8fa313 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 22 Mar 2022 13:57:41 +0100 Subject: [PATCH 3/3] docs: add release notes --- docs/release-notes/release-notes-0.15.0.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/release-notes-0.15.0.md b/docs/release-notes/release-notes-0.15.0.md index 4daf9f18a..b482b4c83 100644 --- a/docs/release-notes/release-notes-0.15.0.md +++ b/docs/release-notes/release-notes-0.15.0.md @@ -176,7 +176,11 @@ then watch it on chain. Taproot script spends are also supported through the * [The CI and build infrastructure for the project has transitioned to using Go 1.18](https://github.com/lightningnetwork/lnd/pull/6340). * [Announce the keysend feature bit in NodeAnnouncement if `--accept-keysend` - is set](https://github.com/lightningnetwork/lnd/pull/6414) + is set](https://github.com/lightningnetwork/lnd/pull/6414). + +* [Fix a flaky unit test in the `chainview` + package](https://github.com/lightningnetwork/lnd/pull/6354). + ## RPC Server