network/frame/handshake_ack_frame_test.go

26 lines
702 B
Go
Raw Normal View History

2023-04-05 16:15:59 +08:00
package frame
import (
"testing"
"github.com/stretchr/testify/assert"
)
var handShakeAckTestBuf = []byte{0x80 | byte(TagOfHandshakeAckFrame), 0x8, 0x28, 0x6, 0x74, 0x68, 0x65, 0x2d, 0x69, 0x64}
var testStreamID = "the-id"
func TestHandshakeAckFrameEncode(t *testing.T) {
f := NewHandshakeAckFrame(testStreamID)
assert.Equal(t, TagOfHandshakeAckFrame, f.Type())
assert.Equal(t, handShakeAckTestBuf, f.Encode())
}
func TestHandshakeAckFrameDecode(t *testing.T) {
f, err := DecodeToHandshakeAckFrame(handShakeAckTestBuf)
assert.NoError(t, err)
assert.Equal(t, TagOfHandshakeAckFrame, f.Type())
assert.Equal(t, testStreamID, f.StreamId())
assert.Equal(t, handShakeAckTestBuf, f.Encode())
}