github.com/pion/dtls/v2@v2.2.12/pkg/protocol/handshake/message_hello_verify_request_test.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 package handshake 5 6 import ( 7 "reflect" 8 "testing" 9 10 "github.com/pion/dtls/v2/pkg/protocol" 11 ) 12 13 func TestHandshakeMessageHelloVerifyRequest(t *testing.T) { 14 rawHelloVerifyRequest := []byte{ 15 0xfe, 0xff, 0x14, 0x25, 0xfb, 0xee, 0xb3, 0x7c, 0x95, 0xcf, 0x00, 16 0xeb, 0xad, 0xe2, 0xef, 0xc7, 0xfd, 0xbb, 0xed, 0xf7, 0x1f, 0x6c, 0xcd, 17 } 18 parsedHelloVerifyRequest := &MessageHelloVerifyRequest{ 19 Version: protocol.Version{Major: 0xFE, Minor: 0xFF}, 20 Cookie: []byte{0x25, 0xfb, 0xee, 0xb3, 0x7c, 0x95, 0xcf, 0x00, 0xeb, 0xad, 0xe2, 0xef, 0xc7, 0xfd, 0xbb, 0xed, 0xf7, 0x1f, 0x6c, 0xcd}, 21 } 22 23 h := &MessageHelloVerifyRequest{} 24 if err := h.Unmarshal(rawHelloVerifyRequest); err != nil { 25 t.Error(err) 26 } else if !reflect.DeepEqual(h, parsedHelloVerifyRequest) { 27 t.Errorf("handshakeMessageClientHello unmarshal: got %#v, want %#v", h, parsedHelloVerifyRequest) 28 } 29 30 raw, err := h.Marshal() 31 if err != nil { 32 t.Error(err) 33 } else if !reflect.DeepEqual(raw, rawHelloVerifyRequest) { 34 t.Errorf("handshakeMessageClientHello marshal: got %#v, want %#v", raw, rawHelloVerifyRequest) 35 } 36 }