From 70bd6d1a119aaab8e7ec6c0470f7b0c6ebbdad15 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 17 Aug 2023 23:49:38 +0800 Subject: [PATCH] lnwire: fix unit test flake for `Ping` message --- lnwire/lnwire_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lnwire/lnwire_test.go b/lnwire/lnwire_test.go index 1ad93c96b..703c94211 100644 --- a/lnwire/lnwire_test.go +++ b/lnwire/lnwire_test.go @@ -937,8 +937,9 @@ func TestLightningWireProtocol(t *testing.T) { // // We'll allow the test to generate padding bytes up to // the max message limit, factoring in the 2 bytes for - // the num pong bytes. - paddingBytes := make([]byte, r.Intn(MaxMsgBody-1)) + // the num pong bytes and 2 bytes for encoding the + // length of the padding bytes. + paddingBytes := make([]byte, rand.Intn(MaxMsgBody-3)) req := Ping{ NumPongBytes: uint16(r.Intn(MaxPongBytes + 1)), PaddingBytes: paddingBytes,