package main import ( "f1-game/tool/client-cli/cli" "fmt" "math/rand" "sync" "testing" "time" cherryTime "github.com/cherry-game/cherry/extend/time" cherryLogger "github.com/cherry-game/cherry/logger" ) // TestDev_10001 dev环境连10001服 func TestDev_10001(t *testing.T) { var ( url = "http://192.168.1.232:18080" addr = "192.168.1.232:30001" gameNodeID = "1" pid = "2188001" userAndPwd = "su1002" ) cli.RegisterDevAccounts(url, map[string]string{ userAndPwd: userAndPwd, }) wg := &sync.WaitGroup{} wg.Add(1) robot := cli.EnterServer(url, pid, userAndPwd, userAndPwd, addr, gameNodeID, true) if robot != nil { robot.ChargeCreate(80006) } wg.Wait() } func TestDev_10001_10000_EnterServer(t *testing.T) { var ( url = "http://192.168.1.232:18080" addr = "192.168.1.232:30001" gameNodeID = "1" testAccounts = make(map[string]string) pid = "2188001" maxAccountNum = 10000 ) for i := 1; i <= maxAccountNum; i++ { key := fmt.Sprintf("susu%d", i) testAccounts[key] = key } now := cherryTime.Now() wg := &sync.WaitGroup{} wg.Add(1) for userName, password := range testAccounts { time.Sleep(time.Duration(rand.Int31n(2)) * time.Millisecond) go func(userName, password string) { cli.EnterServer(url, pid, userName, password, addr, gameNodeID, false) //wg.Done() }(userName, password) } wg.Wait() cherryLogger.Infof("elapsedTime = %dms", now.NowDiffMillisecond()) } // TestDev_10002 dev环境连10002服 func TestDev_10002(t *testing.T) { var ( url = "http://192.168.1.232:18080" addr = "192.168.1.232:30001" gameNodeID = "10002" pid = "2188001" userAndPwd = "su1001" ) cli.RegisterDevAccount(url, userAndPwd, userAndPwd) wg := &sync.WaitGroup{} wg.Add(1) robot := cli.EnterServer(url, pid, userAndPwd, userAndPwd, addr, gameNodeID, true) if robot != nil { //robot.ItemUse(3003, 208) robot.ChargeCreate(80006) //robot.Time() //robot.ItemUse(21001) //robot.GuideUpdate() //robot.BuyEP(1) //robot.ItemUse() //robot.ChapterEnter() //robot.ChapterExit() } wg.Wait() }