2016-12-08 10:27:41 -05:00
|
|
|
package internet_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-02-16 15:31:50 -05:00
|
|
|
"github.com/v2fly/v2ray-core/v4/common"
|
|
|
|
. "github.com/v2fly/v2ray-core/v4/transport/internet"
|
|
|
|
"github.com/v2fly/v2ray-core/v4/transport/internet/headers/noop"
|
|
|
|
"github.com/v2fly/v2ray-core/v4/transport/internet/headers/srtp"
|
|
|
|
"github.com/v2fly/v2ray-core/v4/transport/internet/headers/utp"
|
|
|
|
"github.com/v2fly/v2ray-core/v4/transport/internet/headers/wechat"
|
|
|
|
"github.com/v2fly/v2ray-core/v4/transport/internet/headers/wireguard"
|
2016-12-08 10:27:41 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestAllHeadersLoadable(t *testing.T) {
|
2019-02-01 08:38:14 -05:00
|
|
|
testCases := []struct {
|
|
|
|
Input interface{}
|
|
|
|
Size int32
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
Input: new(noop.Config),
|
|
|
|
Size: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Input: new(srtp.Config),
|
|
|
|
Size: 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Input: new(utp.Config),
|
|
|
|
Size: 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Input: new(wechat.VideoConfig),
|
|
|
|
Size: 13,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Input: new(wireguard.WireguardConfig),
|
|
|
|
Size: 4,
|
|
|
|
},
|
|
|
|
}
|
2016-12-08 10:27:41 -05:00
|
|
|
|
2019-02-01 08:38:14 -05:00
|
|
|
for _, testCase := range testCases {
|
|
|
|
header, err := CreatePacketHeader(testCase.Input)
|
|
|
|
common.Must(err)
|
|
|
|
if header.Size() != testCase.Size {
|
|
|
|
t.Error("expected size ", testCase.Size, " but got ", header.Size())
|
|
|
|
}
|
|
|
|
}
|
2016-12-08 10:27:41 -05:00
|
|
|
}
|