Merge pull request #6354 from guggero/fix-unit-tests

chainview: fix unit test timeout
This commit is contained in:
Oliver Gugger 2022-04-19 13:08:43 +02:00 committed by GitHub
commit 51a7566248
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 9 deletions

View File

@ -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

View File

@ -547,14 +547,23 @@ 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)
}
// 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 +784,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 +866,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 +921,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 +958,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 +972,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 {