Merge pull request #6783 from ErikEk/itest-neutrino-sub-server
itest: neutrino sub-server
This commit is contained in:
6 files changed
+103
No files matched your search
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/neutrinorpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/peersrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||
@@ -368,6 +369,7 @@ type HarnessNode struct {
|
||||
StateClient lnrpc.StateClient
|
||||
ChainClient chainrpc.ChainNotifierClient
|
||||
ChainKit chainrpc.ChainKitClient
|
||||
NeutrinoClient neutrinorpc.NeutrinoKitClient
|
||||
}
|
||||
|
||||
// RPCClients wraps a list of RPC clients into a single struct for easier
|
||||
@@ -387,6 +389,7 @@ type RPCClients struct {
|
||||
State lnrpc.StateClient
|
||||
ChainClient chainrpc.ChainNotifierClient
|
||||
ChainKit chainrpc.ChainKitClient
|
||||
NeutrinoClient neutrinorpc.NeutrinoKitClient
|
||||
}
|
||||
|
||||
// Assert *HarnessNode implements the lnrpc.LightningClient interface.
|
||||
@@ -941,6 +944,7 @@ func (hn *HarnessNode) InitRPCClients(c *grpc.ClientConn) {
|
||||
State: lnrpc.NewStateClient(c),
|
||||
ChainClient: chainrpc.NewChainNotifierClient(c),
|
||||
ChainKit: chainrpc.NewChainKitClient(c),
|
||||
NeutrinoClient: neutrinorpc.NewNeutrinoKitClient(c),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -964,6 +968,7 @@ func (hn *HarnessNode) initLightningClient() error {
|
||||
hn.StateClient = lnrpc.NewStateClient(conn)
|
||||
hn.ChainClient = chainrpc.NewChainNotifierClient(conn)
|
||||
hn.ChainKit = chainrpc.NewChainKitClient(conn)
|
||||
hn.NeutrinoClient = neutrinorpc.NewNeutrinoKitClient(conn)
|
||||
|
||||
// Wait until the server is fully started.
|
||||
if err := hn.WaitUntilServerActive(); err != nil {
|
||||
@@ -1183,6 +1188,7 @@ func (hn *HarnessNode) stop() error {
|
||||
hn.WalletUnlockerClient = nil
|
||||
hn.Watchtower = nil
|
||||
hn.WatchtowerClient = nil
|
||||
hn.NeutrinoClient = nil
|
||||
|
||||
// Close any attempts at further grpc connections.
|
||||
if hn.rpc.conn != nil {
|
||||
|
||||
@@ -227,4 +227,8 @@ var allTestCasesTemp = []*lntemp.TestCase{
|
||||
Name: "chain kit",
|
||||
TestFunc: testChainKit,
|
||||
},
|
||||
{
|
||||
Name: "neutrino kit",
|
||||
TestFunc: testNeutrino,
|
||||
},
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in new issue
Block a user