receiver_test.go 896 B

123456789101112131415161718192021222324252627282930
  1. package outbound_test
  2. import (
  3. "testing"
  4. v2net "github.com/v2ray/v2ray-core/common/net"
  5. proto "github.com/v2ray/v2ray-core/common/protocol"
  6. "github.com/v2ray/v2ray-core/common/uuid"
  7. . "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
  8. v2testing "github.com/v2ray/v2ray-core/testing"
  9. "github.com/v2ray/v2ray-core/testing/assert"
  10. )
  11. func TestReceiverUser(t *testing.T) {
  12. v2testing.Current(t)
  13. id := proto.NewID(uuid.New())
  14. user := proto.NewUser(id, proto.UserLevel(0), 100, "")
  15. rec := NewReceiver(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80), user)
  16. assert.Bool(rec.HasUser(user)).IsTrue()
  17. assert.Int(len(rec.Accounts)).Equals(1)
  18. id2 := proto.NewID(uuid.New())
  19. user2 := proto.NewUser(id2, proto.UserLevel(0), 100, "")
  20. assert.Bool(rec.HasUser(user2)).IsFalse()
  21. rec.AddUser(user2)
  22. assert.Bool(rec.HasUser(user2)).IsTrue()
  23. assert.Int(len(rec.Accounts)).Equals(2)
  24. }