| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- 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()
- }
|