From 20fd630465e39da2c9a20382b0c32e74c59b4539 Mon Sep 17 00:00:00 2001 From: ErikEk Date: Thu, 18 Aug 2022 18:16:27 +0200 Subject: [PATCH] itest: test neutrino sub server --- lntest/itest/list_on_test.go | 4 ++++ lntest/itest/lnd_neutrino_test.go | 33 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 lntest/itest/lnd_neutrino_test.go diff --git a/lntest/itest/list_on_test.go b/lntest/itest/list_on_test.go index bb94c7394..91e808e5e 100644 --- a/lntest/itest/list_on_test.go +++ b/lntest/itest/list_on_test.go @@ -227,4 +227,8 @@ var allTestCasesTemp = []*lntemp.TestCase{ Name: "chain kit", TestFunc: testChainKit, }, + { + Name: "neutrino kit", + TestFunc: testNeutrino, + }, } diff --git a/lntest/itest/lnd_neutrino_test.go b/lntest/itest/lnd_neutrino_test.go new file mode 100644 index 000000000..902eac430 --- /dev/null +++ b/lntest/itest/lnd_neutrino_test.go @@ -0,0 +1,33 @@ +package itest + +import ( + "github.com/lightningnetwork/lnd/lnrpc/neutrinorpc" + "github.com/lightningnetwork/lnd/lntemp" + "github.com/lightningnetwork/lnd/lntest" + "github.com/stretchr/testify/require" +) + +// testNeutrino checks that the neutrino sub-server can fetch compact +// block filters, server status and connect to a connected peer. +func testNeutrino(ht *lntemp.HarnessTest) { + if ht.ChainBackendName() != lntest.NeutrinoBackendName { + ht.Skipf("skipping test for non neutrino backends") + } + + // Check if the neutrino sub server is running. + statusRes := ht.Alice.RPC.Status(nil) + require.True(ht, statusRes.Active) + require.Len(ht, statusRes.Peers, 1, "unable to find a peer") + + // Request the compact block filter of the best block. + cFilterReq := &neutrinorpc.GetCFilterRequest{ + Hash: statusRes.GetBlockHash(), + } + ht.Alice.RPC.GetCFilter(cFilterReq) + + // Try to reconnect to a connected peer. + addPeerReq := &neutrinorpc.AddPeerRequest{ + PeerAddrs: statusRes.Peers[0], + } + ht.Alice.RPC.AddPeer(addPeerReq) +}