From 2d59976e169d9306eec39adb454279b5af4fc263 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 15 Sep 2025 17:47:06 +0800 Subject: [PATCH] rpcserver+itest: skip err from `FlapCount` We need to make sure the `ListPeers` to be robust against errors from the `FlapCount` so this RPC won't fail due to no flap count info. Also updated the itest to check this field. --- itest/lnd_misc_test.go | 11 +++++++++++ rpcserver.go | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/itest/lnd_misc_test.go b/itest/lnd_misc_test.go index 138232706..f6252132f 100644 --- a/itest/lnd_misc_test.go +++ b/itest/lnd_misc_test.go @@ -257,6 +257,17 @@ func testListChannels(ht *lntest.HarnessTest) { assertChannelConstraintsEqual( ht, aliceChannel.RemoteConstraints, bobChannel.LocalConstraints, ) + + // Finally we assert that the flap count is updated as expected. + resp := alice.RPC.ListPeers() + + // Assert Alice only have one peer. + require.Len(ht, resp.Peers, 1) + for _, p := range resp.Peers { + // The channel open event resulted in an online event, so we + // expect the flap count to be 1. + require.EqualValues(ht, 1, p.FlapCount) + } } // testMaxPendingChannels checks that error is returned from remote peer if diff --git a/rpcserver.go b/rpcserver.go index 6fb050711..d3d3c5180 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -3561,8 +3561,12 @@ func (r *rpcServer) ListPeers(ctx context.Context, flap, ts, err := r.server.chanEventStore.FlapCount( vertex, ) + + // Log the error if we cannot get the flap count instead + // of failing this RPC call. if err != nil { - return nil, err + rpcsLog.Debugf("Failed to get flap count for "+ + "peer %v", vertex) } // If our timestamp is non-nil, we have values for our