FILE / ScuroNeko/mtg

mtglib/internal/tls/init_test.go

Исходный файл и его история в репозитории.
FILE 00403e3a948d1fc43aeb91b4d3bc9453f5df9c37
Files
mtg/mtglib/internal/tls/init_test.go
T
2026-03-12 19:07:10 +01:00

31 lines
605 B
Go

package tls
import (
"encoding/binary"
"github.com/stretchr/testify/mock"
)
type WriterMock struct {
mock.Mock
}
func (m *WriterMock) Write(p []byte) (int, error) {
args := m.Called(p)
return args.Int(0), args.Error(1)
}
// makeTLSRecord builds a raw TLS record from hardcoded offsets:
// type(1) + version(2, {3,3}) + length(2, big-endian) + payload.
func MakeTLSRecord(recordType byte, payload []byte) []byte {
buf := make([]byte, 5+len(payload))
buf[0] = recordType
buf[1] = 3
buf[2] = 3
binary.BigEndian.PutUint16(buf[3:5], uint16(len(payload)))
copy(buf[5:], payload)
return buf
}