@@ -697,17 +697,22 @@ func TestWebsocketVoteDynamicCompressionAbortMessage(t *testing.T) {
697697 require .True (t , peerBtoA .msgCodec .statefulVoteEncEnabled .Load (), "VP encoding not established on B->A" )
698698 require .True (t , peerBtoA .msgCodec .statefulVoteDecEnabled .Load (), "VP decoding not established on B->A" )
699699
700- // Send VP abort message from A to B
701- abortMsg := append ([]byte (protocol .VotePackedTag ), voteCompressionAbortMessage )
702- sent := peerAtoB .writeNonBlock (context .Background (), abortMsg , true , crypto.Digest {}, time .Now ())
703- require .True (t , sent , "failed to send abort message" )
700+ // Send a malformed VP message from B to A to trigger decoder failure and abort handshake.
701+ malformedVP := append ([]byte (protocol .VotePackedTag ), [] byte { 0x01 , 0xFF , 0x42 } ... )
702+ sent := peerBtoA .writeNonBlock (context .Background (), malformedVP , true , crypto.Digest {}, time .Now ())
703+ require .True (t , sent , "failed to enqueue malformed VP message" )
704704
705- // Wait for abort to be processed - verify B disabled its encoder (can't send VP to A anymore)
705+ // Decoder on A should disable itself after the malformed vote.
706+ require .Eventually (t , func () bool {
707+ return ! peerAtoB .msgCodec .statefulVoteDecEnabled .Load ()
708+ }, 2 * time .Second , 50 * time .Millisecond , "VP decoding not disabled on A->B after malformed VP" )
709+
710+ // Encoder on B should see the abort and disable as well.
706711 require .Eventually (t , func () bool {
707712 return ! peerBtoA .msgCodec .statefulVoteEncEnabled .Load ()
708- }, 2 * time .Second , 50 * time .Millisecond , "VP encoding not disabled on B->A after receiving abort message " )
713+ }, 2 * time .Second , 50 * time .Millisecond , "VP encoding not disabled on B->A after decoder abort" )
709714
710- // Verify connection is still up after abort
715+ // Verify connection is still up after abort handshake.
711716 require .Equal (t , 1 , len (netB .peers ), "connection should still be alive after abort" )
712717 require .Equal (t , 1 , len (netA .peers ), "connection should still be alive after abort" )
713718}
0 commit comments