Skip to content

Commit 73770db

Browse files
committed
peer: include ping pong-size in debug summaries
Expose num_pong_bytes in the ping message summary so ignored no-reply pings are visible in debug logs. Add a focused test covering the summary output for the sentinel range.
1 parent dd61acd commit 73770db

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

peer/brontide.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2598,7 +2598,8 @@ func messageSummary(msg lnwire.Message) string {
25982598
msg.NodeID, time.Unix(int64(msg.Timestamp), 0))
25992599

26002600
case *lnwire.Ping:
2601-
return fmt.Sprintf("ping_bytes=%x", msg.PaddingBytes[:])
2601+
return fmt.Sprintf("num_pong_bytes=%d, len(ping_bytes)=%d",
2602+
msg.NumPongBytes, len(msg.PaddingBytes[:]))
26022603

26032604
case *lnwire.Pong:
26042605
return fmt.Sprintf("len(pong_bytes)=%d", len(msg.PongBytes[:]))

peer/brontide_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,26 @@ func TestPeerIgnoresPingWithoutPongReply(t *testing.T) {
11431143
require.Len(t, pong.PongBytes, 1)
11441144
}
11451145

1146+
// TestMessageSummaryPingIncludesNumPongBytes ensures the debug summary for a
1147+
// ping exposes the requested pong size, which makes ignored no-reply pings
1148+
// visible without requiring trace-level logging.
1149+
func TestMessageSummaryPingIncludesNumPongBytes(t *testing.T) {
1150+
t.Parallel()
1151+
1152+
// Arrange: Build a ping that uses the BOLT 1 no-reply sentinel range.
1153+
msg := &lnwire.Ping{
1154+
NumPongBytes: 65535,
1155+
PaddingBytes: []byte{1, 2, 3},
1156+
}
1157+
1158+
// Act: Generate the human-readable message summary.
1159+
summary := messageSummary(msg)
1160+
1161+
// Assert: The summary includes both the requested pong size and payload
1162+
// length so debug logs can explain why no pong was sent.
1163+
require.Equal(t, "num_pong_bytes=65535, len(ping_bytes)=3", summary)
1164+
}
1165+
11461166
// TestUpdateNextRevocation checks that the method `updateNextRevocation` is
11471167
// behave as expected.
11481168
func TestUpdateNextRevocation(t *testing.T) {

0 commit comments

Comments
 (0)