Browse Source

fix test break

Darien Raymond 7 years ago
parent
commit
16051587b5
2 changed files with 18 additions and 6 deletions
  1. 10 3
      common/protocol/server_spec_test.go
  2. 8 3
      proxy/vmess/vmess_test.go

+ 10 - 3
common/protocol/server_spec_test.go

@@ -4,6 +4,7 @@ import (
 	"testing"
 	"time"
 
+	"v2ray.com/core/common"
 	"v2ray.com/core/common/net"
 	. "v2ray.com/core/common/protocol"
 	"v2ray.com/core/common/uuid"
@@ -39,19 +40,25 @@ func TestUserInServerSpec(t *testing.T) {
 	uuid1 := uuid.New()
 	uuid2 := uuid.New()
 
+	toAccount := func(a *vmess.Account) Account {
+		account, err := a.AsAccount()
+		common.Must(err)
+		return account
+	}
+
 	spec := NewServerSpec(net.Destination{}, AlwaysValid(), &MemoryUser{
 		Email:   "test1@v2ray.com",
-		Account: &vmess.Account{Id: uuid1.String()},
+		Account: toAccount(&vmess.Account{Id: uuid1.String()}),
 	})
 	assert(spec.HasUser(&MemoryUser{
 		Email:   "test1@v2ray.com",
-		Account: &vmess.Account{Id: uuid2.String()},
+		Account: toAccount(&vmess.Account{Id: uuid2.String()}),
 	}), IsFalse)
 
 	spec.AddUser(&MemoryUser{Email: "test2@v2ray.com"})
 	assert(spec.HasUser(&MemoryUser{
 		Email:   "test1@v2ray.com",
-		Account: &vmess.Account{Id: uuid1.String()},
+		Account: toAccount(&vmess.Account{Id: uuid1.String()}),
 	}), IsTrue)
 }
 

+ 8 - 3
proxy/vmess/vmess_test.go

@@ -5,7 +5,6 @@ import (
 	"time"
 
 	"v2ray.com/core/common"
-	"v2ray.com/core/common/serial"
 	"v2ray.com/core/common/uuid"
 
 	"v2ray.com/core/common/protocol"
@@ -20,10 +19,16 @@ func TestUserValidator(t *testing.T) {
 	v := NewTimedUserValidator(hasher)
 	defer common.Close(v)
 
+	toAccount := func(a *Account) protocol.Account {
+		account, err := a.AsAccount()
+		common.Must(err)
+		return account
+	}
+
 	id := uuid.New()
-	user := &protocol.User{
+	user := &protocol.MemoryUser{
 		Email: "test",
-		Account: serial.ToTypedMessage(&Account{
+		Account: toAccount(&Account{
 			Id:      id.String(),
 			AlterId: 8,
 		}),