mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-24 06:06:05 +03:00
be23d5d3b7
The first UoT protocol that supports UoT Migration Thank @yuhan6665 for testing
52 lines
756 B
Go
52 lines
756 B
Go
package mux_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/xtls/xray-core/common/mux"
|
|
)
|
|
|
|
func TestSessionManagerAdd(t *testing.T) {
|
|
m := NewSessionManager()
|
|
|
|
s := m.Allocate()
|
|
if s.ID != 1 {
|
|
t.Error("id: ", s.ID)
|
|
}
|
|
if m.Size() != 1 {
|
|
t.Error("size: ", m.Size())
|
|
}
|
|
|
|
s = m.Allocate()
|
|
if s.ID != 2 {
|
|
t.Error("id: ", s.ID)
|
|
}
|
|
if m.Size() != 2 {
|
|
t.Error("size: ", m.Size())
|
|
}
|
|
|
|
s = &Session{
|
|
ID: 4,
|
|
}
|
|
m.Add(s)
|
|
if s.ID != 4 {
|
|
t.Error("id: ", s.ID)
|
|
}
|
|
if m.Size() != 3 {
|
|
t.Error("size: ", m.Size())
|
|
}
|
|
}
|
|
|
|
func TestSessionManagerClose(t *testing.T) {
|
|
m := NewSessionManager()
|
|
s := m.Allocate()
|
|
|
|
if m.CloseIfNoSession() {
|
|
t.Error("able to close")
|
|
}
|
|
m.Remove(false, s.ID)
|
|
if !m.CloseIfNoSession() {
|
|
t.Error("not able to close")
|
|
}
|
|
}
|