network/frame/handshake_frame_test.go

31 lines
675 B
Go
Raw Normal View History

2022-10-11 17:36:09 +08:00
package frame
import (
"testing"
"github.com/stretchr/testify/assert"
)
2023-04-05 16:15:59 +08:00
func TestHandshakeFrame(t *testing.T) {
var (
name = "hpds"
id = "sdfsdfsd"
streamType = byte(0x5F)
observeDataTags = []Tag{'a', 'b', 'c'}
metadata = []byte{'d', 'e', 'f'}
2022-10-11 17:36:09 +08:00
)
2023-04-05 16:15:59 +08:00
f := NewHandshakeFrame(name, id, streamType, observeDataTags, metadata)
buf := f.Encode()
got, err := DecodeToHandshakeFrame(buf)
2022-10-11 17:36:09 +08:00
assert.NoError(t, err)
2023-04-05 16:15:59 +08:00
assert.Equal(t, name, got.Name())
assert.Equal(t, id, got.ID())
assert.Equal(t, streamType, got.StreamType())
assert.Equal(t, observeDataTags, got.ObserveDataTags())
assert.Equal(t, metadata, got.Metadata())
2022-10-11 17:36:09 +08:00
}