| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640 |
- package main
- import (
- "f1-game/internal/enum"
- "f1-game/internal/pb"
- "f1-game/tool/client-cli/cli"
- "fmt"
- "math/rand"
- "sync"
- "testing"
- "time"
- cherryHttp "github.com/cherry-game/cherry/extend/http"
- ctime "github.com/cherry-game/cherry/extend/time"
- clog "github.com/cherry-game/cherry/logger"
- )
- func testDHCSetup() *cli.Robot {
- var (
- // url = "http://192.168.1.232:18080"
- // addr = "192.168.1.232:30001"
- url = "http://dev.f1.chun-pu.com"
- addr = "127.0.0.1:30001"
- serverId = "4"
- account = "dhc-031211"
- password = "123456"
- pid = "2188004"
- )
- cli.RegisterDevAccount(url, account, password)
- robot := cli.EnterServer(url, pid, account, password, addr, serverId, true)
- return robot
- }
- func TestDHCMain(t *testing.T) {
- testDHCSetup()
- select {}
- }
- func TestDHCMainMap(t *testing.T) {
- robot := testDHCSetup()
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- // robot.SelectState(1)
- // time.Sleep(1 * time.Second)
- robot.MapEnter()
- time.Sleep(1 * time.Second)
- robot.FacilityUp(10200)
- // robot.MapMarch(1, enum.MarchType_Siege, 63, 755, false, false)
- // time.Sleep(3 * time.Second)
- // robot.MapMarch(2, enum.MarchType_Siege, 63, 755, false, false)
- // time.Sleep(3 * time.Second)
- // robot.MapMarch(3, enum.MarchType_Siege, 63, 755, false, false)
- // time.Sleep(3 * time.Second)
- // robot.MapMarch(1, enum.MarchType_Occupy, 72, 712, false, true)
- // time.Sleep(3 * time.Second)
- // robot.MapMarch(2, enum.MarchType_Assemble, 63, 755, false, true)
- // time.Sleep(3 * time.Second)
- // robot.MapMarch(3, enum.MarchType_Assemble, 63, 755, false, false)
- // time.Sleep(3 * time.Second)
- // robot.MapStop(1)
- // time.Sleep(3 * time.Second)
- // robot.MapRetreat(1, 0)
- // time.Sleep(3 * time.Second)
- select {}
- }
- // 获取赛季霸业任务
- func TestSeasonQuestInfo(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- robot.SeasonQuestInfo()
- }
- // 领取赛季霸业奖励
- func TestSeasonQuestReward(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- questID := int32(101)
- robot.SeasonQuestReward(questID)
- select {}
- }
- // 地图交易所货柜解锁
- func TestExchangeSlotUnlock(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- robot.ExchangeSlotUnlock(enum.ExchangeActType_Sell)
- select {}
- }
- // 获取资源的历史求购价格
- func TestExchangeHistoryPrice(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- robot.ExchangeHistoryPrice(101)
- select {}
- }
- // 交易所交易物品
- func TestExchangeItem(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- robot.ExchangeItem(enum.ExchangeActType_Sell, enum.ItemIDWoodUnBound, 1, 1)
- // time.Sleep(50 * time.Millisecond)
- // transID := robot.ExchangeMyItems(enum.ExchangeActType_Wish)
- // if transID != "" {
- // time.Sleep(50 * time.Millisecond)
- // robot.ExchangeItemUpdate(enum.ExchangeUpdateType_Retrieve, transID)
- // }
- // for _, itemID := range enum.ItemMaxNumList {
- // robot.ExchangeItem(enum.ExchangeActType_Sell, itemID, 1+rand.Int63n(4), 10+rand.Int31n(10))
- // time.Sleep(1 * time.Second)
- // }
- select {}
- }
- // 购买商品
- func TestExchangeBuyItem(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- transID := "miNdctqlureFjhkbfR2JXK"
- count := int32(1)
- robot.ExchangeBuyItem(count, transID)
- select {}
- }
- // 查询交易所交易物品
- func TestExchangeQuery(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- var (
- pageNum int32 = 1
- itemIDList = []int32{}
- subTypeList = []int32{}
- qualityList = []int32{}
- priceSort = enum.ExchangeSortType_None
- countSort = enum.ExchangeSortType_None
- )
- robot.ExchangeQuery(pageNum, itemIDList, subTypeList, qualityList, priceSort, countSort)
- select {}
- }
- // 获取自己的交易商品列表
- func TestExchangeMyItems(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- robot.ExchangeMyItems(enum.ExchangeActType_Sell)
- select {}
- }
- // 更新地图交易所商品
- func TestExchangeItemUpdate(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- transID := "WvzFHxz2YM2YFhuQEYWpI2"
- updateType := enum.ExchangeUpdateType_Cancel
- robot.ExchangeItemUpdate(updateType, transID)
- time.Sleep(1 * time.Second)
- var (
- pageNum int32 = 1
- itemIDList = []int32{}
- subTypeList = []int32{}
- qualityList = []int32{}
- priceSort = enum.ExchangeSortType_Asc
- countSort = enum.ExchangeSortType_Desc
- )
- robot.ExchangeQuery(pageNum, itemIDList, subTypeList, qualityList, priceSort, countSort)
- select {}
- }
- // 获取交易所日志
- func TestExchangeLog(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- logType := enum.ExchangeLogType_Sell
- lastLogID := int64(0)
- robot.ExchangeLog(logType, lastLogID)
- select {}
- }
- // 获取联盟仓库信息
- func TestLeagueStorage(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(3 * time.Second)
- robot.LeagueStorageInfo()
- select {}
- }
- // 联盟调整税率
- func TestLeagueRatioUpdate(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(3 * time.Second)
- robot.LeagueRatioUpdate(20201, 10)
- select {}
- }
- // 联盟F币分红
- func TestLeagueFundBonus(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.LeagueFundBonus(100, 12121, 112313)
- select {}
- }
- // 获取联盟城池列表
- func TestLeagueCastleList(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.GetLeagueCastleList()
- }
- // 联盟城池城主任命
- func TestLeagueCastleAppoint(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.LeagueCastleAppoint(101001, 1049132)
- }
- // 获取联盟科技列表
- func TestLeagueTechList(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.GetLeagueTechList()
- }
- // 联盟科技升级
- func TestLeagueTechUpgrade(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.LeagueTechUpgrade(1001)
- }
- // 英雄上阵
- func TestHeroLineupUp(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.TeamUp(1049155, 1, 1, 1)
- time.Sleep(500 * time.Microsecond)
- // robot.TeamLeave(1, 1)
- // time.Sleep(500 * time.Microsecond)
- // robot.TeamUp(1048889, 1, 2, 3)
- // time.Sleep(500 * time.Microsecond)
- // robot.TeamUp(1048898, 1, 3, 5)
- // time.Sleep(500 * time.Microsecond)
- }
- // 获取个人战报列表
- func TestReportList(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- robot.ReportList("", enum.ReportCategory_All)
- select {}
- }
- // 获取个人收藏战报列表
- func TestReportInfo(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ReportInfo()
- }
- // 战报收藏和取消收藏
- func TestReportLike(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ReportLike(enum.ReportLikeType_Group, "1001", false)
- }
- // 战报一键阅读
- func TestReportRead(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ReportRead("")
- }
- // 获取同盟战报列表
- func TestLeagueReportList(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.LeagueReportList(0, enum.ReportCategory_PVP)
- select {}
- }
- // 发起探险战斗
- func TestChapterBattle(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChapterBattle(1011)
- }
- // 探险战斗验证
- func TestChapterVerify(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChapterVerify(enum.BattleCampType_Left)
- }
- // 发送聊天消息
- func TestChatSend(t *testing.T) {
- robot := testDHCSetup()
- for i := range 1 {
- time.Sleep(1 * time.Second)
- robot.ChatSend(enum.ChatType_Game, 4, fmt.Sprintf("hello TestDHC%d", i))
- }
- select {}
- }
- // 聊天消息获取
- func TestChatMsgList(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- // robot.MapLogin()
- // time.Sleep(1 * time.Second)
- robot.ChatMsgList(enum.ChatType_Game, 4, 656893032578399168)
- select {}
- }
- // 创建聊天群组
- func TestChatGroupCreate(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChatGroupCreate("h4", 1066402)
- select {}
- }
- // 群组成员修改
- func TestChatGroupPlayerChange(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChatGroupPlayerChange(1025, []int64{1066353})
- select {}
- }
- // 群组邀请确认
- func TestChatGroupInviteConfirm(t *testing.T) {
- robot := testDHCSetup()
- robot.ChatGroupInviteConfirm(1028, true)
- }
- // 获取群组成员列表
- func TestChatGroupPlayerList(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChatGroupPlayerList(1028)
- }
- // 解散群组
- func TestChatGroupDismiss(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChatGroupDismiss(1030)
- }
- // 主动退出群组
- func TestChatGroupQuit(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChatGroupQuit(1027)
- }
- // 设置群组聊天免打扰
- func TestGroupChatNofitySetting(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChatGroupMute(1031, false)
- }
- // 私聊发送消息
- func TestChatPrivateSend(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(3 * time.Second)
- for i := 0; i < 1; i++ {
- robot.ChatPrivateSend(1048857, fmt.Sprintf("测试私聊消息4 hello I am dhc-test %d", i))
- time.Sleep(3 * time.Second)
- }
- select {}
- }
- // 获取私聊消息列表
- func TestChatPrivateMsgList(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChatPrivateMsgList(1066419, 0)
- }
- // 聊天设置
- func TestChatSetting(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChatSetting(false, false, false)
- }
- // 查询玩家信息
- func TestFriendSearch(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.FriendSearch(1048584)
- }
- // 添加好友
- func TestFriendAdd(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.FriendAdd(1066406)
- select {}
- }
- // 好友邀请确认
- func TestFriendConfirm(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.FriendConfirm(1066408, true)
- select {}
- }
- // 删除好友
- func TestFriendDel(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.FriendDel(1066408)
- select {}
- }
- // 设置黑名单
- func TestBlackSetting(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.BlackSetting(1066355, false)
- select {}
- }
- // 举报
- func TestComplaint(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.Complaint(1048585, enum.ComplaintType_BadName, "")
- }
- // 建筑升级
- func TestFacilityUp(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.FacilityUp(1)
- }
- // 建筑取消升级
- func TestFacilityCancel(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.FacilityCancel(1)
- }
- // 建筑立即升级完成
- func TestFacilityFinish(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.FacilityFinish(1)
- }
- // 建筑队列解锁
- func TestFacilityQueueUnlock(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.FacilityQueueUnlock(2)
- }
- // 充值创建
- func TestChargeCreate(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.ChargeCreate(83001)
- select {}
- }
- // 每日周月卡奖励领取
- func TestCardReward(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.CardReward(81003)
- select {}
- }
- // 支付测试
- func TestPayment(t *testing.T) {
- reqURL := "http://127.0.0.1/pay/test_payment?orderID=602573286605938496"
- cherryHttp.GET(reqURL)
- }
- // 英雄穿戴装备
- func TestHeroWearEquip(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.HeroWearEquip(&pb.HeroEquip{
- HeroGUID: 1048603,
- EquipGUIDList: []int64{1048661, 1048642, 1048660},
- })
- select {}
- }
- // 英雄脱下装备
- func TestHeroTakeOffEquip(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.HeroTakeOffEquip(&pb.I64I64{
- Key: 1048603,
- Value: 0,
- })
- select {}
- }
- // 领取每日VIP点数
- func TestVipDailyExpReward(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.VipDailyExpReward()
- select {}
- }
- // 领取每日VIP宝箱奖励
- func TestVipDailyBoxReward(t *testing.T) {
- time.Sleep(1 * time.Second)
- robot := testDHCSetup()
- robot.VipDailyBoxReward(0)
- select {}
- }
- // 使用道具
- func TestDHCItemUse(t *testing.T) {
- robot := testDHCSetup()
- time.Sleep(1 * time.Second)
- robot.MapLogin()
- time.Sleep(1 * time.Second)
- robot.ItemUse(140003, 3)
- select {}
- }
- func Test_dhc_RegisterDevAccount(t *testing.T) {
- var (
- url = "http://192.168.1.225:18080"
- accountNum = 10000
- )
- accountList := make(map[string]string)
- for i := 1; i <= accountNum; i++ {
- key := fmt.Sprintf("dhc_%d", i)
- accountList[key] = key
- }
- cli.RegisterDevAccounts(url, accountList)
- }
- func Test_dhc_EnterServer(t *testing.T) {
- var (
- url = "http://192.168.1.225:18080"
- addr = "192.168.1.225:30001"
- gameNodeID = "4"
- testAccounts = make(map[string]string)
- pid = "2188004"
- maxAccountNum = 500
- )
- for i := 1; i <= maxAccountNum; i++ {
- key := fmt.Sprintf("dhc_122910_%d", i)
- testAccounts[key] = key
- cli.RegisterDevAccount(url, key, key)
- }
- now := ctime.Now()
- wg := &sync.WaitGroup{}
- wg.Add(maxAccountNum)
- for userName, password := range testAccounts {
- go func(userName, password string) {
- time.Sleep(50 + (time.Duration(rand.Int31n(100)) * time.Millisecond))
- robot := cli.EnterServer(url, pid, userName, password, addr, gameNodeID, false)
- robot.RandSleep()
- robot.MapLogin()
- wg.Done()
- }(userName, password)
- }
- wg.Wait()
- clog.Infof("elapsedTime = %dms", now.NowDiffMillisecond())
- }
|