mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
remove PacketPaddingContainer abstraction
This commit is contained in:
parent
955cbc847a
commit
1bc310c2e9
6 changed files with 42 additions and 62 deletions
|
@ -10,12 +10,11 @@ import (
|
|||
|
||||
func TestPacketPaddingContainer(t *testing.T) {
|
||||
Convey("Given a PacketPaddingContainer", t, func() {
|
||||
container := packetpadding.New()
|
||||
|
||||
Convey("When packing data with padding", func() {
|
||||
data := []byte("testdata")
|
||||
paddingLength := 4
|
||||
packedData := container.Pack(data, paddingLength)
|
||||
packedData := packetpadding.Pack(data, paddingLength)
|
||||
|
||||
Convey("The packed data should have the correct length", func() {
|
||||
expectedLength := len(data) + paddingLength + 2
|
||||
|
@ -23,7 +22,7 @@ func TestPacketPaddingContainer(t *testing.T) {
|
|||
})
|
||||
|
||||
Convey("When unpacking the packed data", func() {
|
||||
unpackedData, unpackedPaddingLength := container.Unpack(packedData)
|
||||
unpackedData, unpackedPaddingLength := packetpadding.Unpack(packedData)
|
||||
|
||||
Convey("The unpacked data should match the original data", func() {
|
||||
So(string(unpackedData), ShouldEqual, string(data))
|
||||
|
@ -38,7 +37,7 @@ func TestPacketPaddingContainer(t *testing.T) {
|
|||
Convey("When packing empty data with padding", func() {
|
||||
data := []byte("")
|
||||
paddingLength := 4
|
||||
packedData := container.Pack(data, paddingLength)
|
||||
packedData := packetpadding.Pack(data, paddingLength)
|
||||
|
||||
Convey("The packed data should have the correct length", func() {
|
||||
expectedLength := len(data) + paddingLength + 2
|
||||
|
@ -46,7 +45,7 @@ func TestPacketPaddingContainer(t *testing.T) {
|
|||
})
|
||||
|
||||
Convey("When unpacking the packed data", func() {
|
||||
unpackedData, unpackedPaddingLength := container.Unpack(packedData)
|
||||
unpackedData, unpackedPaddingLength := packetpadding.Unpack(packedData)
|
||||
|
||||
Convey("The unpacked data should match the original data", func() {
|
||||
So(string(unpackedData), ShouldEqual, string(data))
|
||||
|
@ -61,7 +60,7 @@ func TestPacketPaddingContainer(t *testing.T) {
|
|||
Convey("When packing data with zero padding", func() {
|
||||
data := []byte("testdata")
|
||||
paddingLength := 0
|
||||
packedData := container.Pack(data, paddingLength)
|
||||
packedData := packetpadding.Pack(data, paddingLength)
|
||||
|
||||
Convey("The packed data should have the correct length", func() {
|
||||
expectedLength := len(data) + paddingLength + 2
|
||||
|
@ -69,7 +68,7 @@ func TestPacketPaddingContainer(t *testing.T) {
|
|||
})
|
||||
|
||||
Convey("When unpacking the packed data", func() {
|
||||
unpackedData, unpackedPaddingLength := container.Unpack(packedData)
|
||||
unpackedData, unpackedPaddingLength := packetpadding.Unpack(packedData)
|
||||
|
||||
Convey("The unpacked data should match the original data", func() {
|
||||
So(string(unpackedData), ShouldEqual, string(data))
|
||||
|
@ -84,7 +83,7 @@ func TestPacketPaddingContainer(t *testing.T) {
|
|||
Convey("When padding data", func() {
|
||||
Convey("With a positive padding length", func() {
|
||||
padLength := 3
|
||||
padData := container.Pad(padLength)
|
||||
padData := packetpadding.Pad(padLength)
|
||||
|
||||
Convey("The padded data should have the correct length", func() {
|
||||
So(len(padData), ShouldEqual, padLength)
|
||||
|
@ -93,7 +92,7 @@ func TestPacketPaddingContainer(t *testing.T) {
|
|||
|
||||
Convey("With a zero padding length", func() {
|
||||
padLength := 0
|
||||
padData := container.Pad(padLength)
|
||||
padData := packetpadding.Pad(padLength)
|
||||
|
||||
Convey("The padded data should be empty", func() {
|
||||
So(len(padData), ShouldEqual, 0)
|
||||
|
@ -102,7 +101,7 @@ func TestPacketPaddingContainer(t *testing.T) {
|
|||
|
||||
Convey("With a negative padding length", func() {
|
||||
padLength := -1
|
||||
padData := container.Pad(padLength)
|
||||
padData := packetpadding.Pad(padLength)
|
||||
|
||||
Convey("The padded data should be nil", func() {
|
||||
So(padData, ShouldBeNil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue