mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-07 11:22:37 +01:00
tests: add test case "disconnecting target peer"
Issue: 139 This commit contains test case "disconnecting target peer" (second test case) which takes two connected peers, then checks via assert method one connection exists, then disconnects this remote peer by passing pubKey parameter (just some string) into RPC-call method. Then checks 0 connection exists, and then connects disconnected peer for passing further tests, and then checks one connection exists.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
cf605c81ab
commit
1eaa522265
@@ -664,7 +664,6 @@ func (n *networkHarness) SetUp() error {
|
||||
// Swap out grpc's default logger with out fake logger which drops the
|
||||
// statements on the floor.
|
||||
grpclog.SetLogger(&fakeLogger{})
|
||||
|
||||
// Start the initial seeder nodes within the test network, then connect
|
||||
// their respective RPC clients.
|
||||
var wg sync.WaitGroup
|
||||
@@ -847,6 +846,25 @@ func (n *networkHarness) ConnectNodes(ctx context.Context, a, b *lightningNode)
|
||||
}
|
||||
}
|
||||
|
||||
// DisconnectNodes disconnects node a from node b by sending RPC message
|
||||
// from a node to b node
|
||||
func (n *networkHarness) DisconnectNodes(ctx context.Context, a, b *lightningNode) error {
|
||||
bobInfo, err := b.GetInfo(ctx, &lnrpc.GetInfoRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req := &lnrpc.DisconnectPeerRequest{
|
||||
PubKey: bobInfo.IdentityPubkey,
|
||||
}
|
||||
|
||||
if _, err := a.DisconnectPeer(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RestartNode attempts to restart a lightning node by shutting it down
|
||||
// cleanly, then restarting the process. This function is fully blocking. Upon
|
||||
// restart, the RPC connection to the node will be re-attempted, continuing iff
|
||||
|
||||
Reference in New Issue
Block a user