2022-08-18 18:16:27 +02:00
|
|
|
package itest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/lightningnetwork/lnd/lnrpc/neutrinorpc"
|
2022-08-12 11:03:44 +02:00
|
|
|
"github.com/lightningnetwork/lnd/lntest"
|
2022-08-18 18:16:27 +02:00
|
|
|
"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.
|
2022-08-12 11:03:44 +02:00
|
|
|
func testNeutrino(ht *lntest.HarnessTest) {
|
2022-08-12 07:07:16 +02:00
|
|
|
if !ht.IsNeutrinoBackend() {
|
2022-08-18 18:16:27 +02:00
|
|
|
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)
|
|
|
|
}
|