github.com/decred/dcrlnd@v0.7.6/lnwire/ping_test.go (about) 1 package lnwire 2 3 import ( 4 "bytes" 5 "math" 6 "testing" 7 ) 8 9 // TestMaxPongBytes tests that we'll fail to decode a Ping message that wants 10 // more pong bytes that we can actually encode while adhering to the max 11 // message limit. 12 func TestMaxPongBytes(t *testing.T) { 13 t.Parallel() 14 15 msg := Ping{ 16 NumPongBytes: math.MaxUint16, 17 } 18 19 var b bytes.Buffer 20 if _, err := WriteMessage(&b, &msg, 0); err != nil { 21 t.Fatalf("unable to write msg: %v", err) 22 } 23 24 _, err := ReadMessage(&b, 0) 25 if err != ErrMaxPongBytesExceeded { 26 t.Fatalf("incorrect error: %v, expected "+ 27 "ErrMaxPongBytesExceeded", err) 28 } 29 }