peer: include ping pong-size in debug summaries
What changed, and why it matters
This commit only changes a debug log message so that ping messages show how many pong bytes were requested and how long the ping payload is. It is purely an observability/logging improvement and does not alter any behavior, protocol handling, or security logic.
No security action needed; this is a normal logging/test improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change updates peer/brontide.go’s messageSummary() for lnwire.Ping to return ‘num_pong_bytes=%d, len(ping_bytes)=%d’ instead of printing the raw padding bytes. A unit test verifies the new format for a BOLT 1 no-reply sentinel ping (NumPongBytes=65535). No functional code paths are modified.
Changed components
peer/brontide.go messageSummary() debug formattingpeer/brontide_test.go unit testInspect captured patch +22 / −1
diff --git a/peer/brontide.go b/peer/brontide.go
index c659a02..f4865fe 100644
--- a/peer/brontide.go
+++ b/peer/brontide.go
@@ -2598,7 +2598,8 @@ func messageSummary(msg lnwire.Message) string {
msg.NodeID, time.Unix(int64(msg.Timestamp), 0))
case *lnwire.Ping:
- return fmt.Sprintf("ping_bytes=%x", msg.PaddingBytes[:])
+ return fmt.Sprintf("num_pong_bytes=%d, len(ping_bytes)=%d",
+ msg.NumPongBytes, len(msg.PaddingBytes[:]))
case *lnwire.Pong:
return fmt.Sprintf("len(pong_bytes)=%d", len(msg.PongBytes[:]))
diff --git a/peer/brontide_test.go b/peer/brontide_test.go
index 2a2cb73..8e0bd29 100644
--- a/peer/brontide_test.go
+++ b/peer/brontide_test.go
@@ -1143,6 +1143,26 @@ func TestPeerIgnoresPingWithoutPongReply(t *testing.T) {
require.Len(t, pong.PongBytes, 1)
}
+// TestMessageSummaryPingIncludesNumPongBytes ensures the debug summary for a
+// ping exposes the requested pong size, which makes ignored no-reply pings
+// visible without requiring trace-level logging.
+func TestMessageSummaryPingIncludesNumPongBytes(t *testing.T) {
+ t.Parallel()
+
+ // Arrange: Build a ping that uses the BOLT 1 no-reply sentinel range.
+ msg := &lnwire.Ping{
+ NumPongBytes: 65535,
+ PaddingBytes: []byte{1, 2, 3},
+ }
+
+ // Act: Generate the human-readable message summary.
+ summary := messageSummary(msg)
+
+ // Assert: The summary includes both the requested pong size and payload
+ // length so debug logs can explain why no pong was sent.
+ require.Equal(t, "num_pong_bytes=65535, len(ping_bytes)=3", summary)
+}
+
// TestUpdateNextRevocation checks that the method `updateNextRevocation` is
// behave as expected.
func TestUpdateNextRevocation(t *testing.T) {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.