github.com/EagleQL/Xray-core@v1.4.3/proxy/vmess/encoding/commands_test.go (about) 1 package encoding_test 2 3 import ( 4 "testing" 5 6 "github.com/google/go-cmp/cmp" 7 8 "github.com/xtls/xray-core/common" 9 "github.com/xtls/xray-core/common/buf" 10 "github.com/xtls/xray-core/common/protocol" 11 "github.com/xtls/xray-core/common/uuid" 12 . "github.com/xtls/xray-core/proxy/vmess/encoding" 13 ) 14 15 func TestSwitchAccount(t *testing.T) { 16 sa := &protocol.CommandSwitchAccount{ 17 Port: 1234, 18 ID: uuid.New(), 19 AlterIds: 1024, 20 Level: 128, 21 ValidMin: 16, 22 } 23 24 buffer := buf.New() 25 common.Must(MarshalCommand(sa, buffer)) 26 27 cmd, err := UnmarshalCommand(1, buffer.BytesFrom(2)) 28 common.Must(err) 29 30 sa2, ok := cmd.(*protocol.CommandSwitchAccount) 31 if !ok { 32 t.Fatal("failed to convert command to CommandSwitchAccount") 33 } 34 if r := cmp.Diff(sa2, sa); r != "" { 35 t.Error(r) 36 } 37 }