fix: improve endgame clock and gameplay stability
This commit is contained in:
1 parent
ce6aabfc55
commit
658298ee86
46 files changed
+1915
-99
No files matched your search
@@ -0,0 +1,67 @@
|
||||
package sdkserver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gac-hkrpg-go/internal/common"
|
||||
pb "gac-hkrpg-go/protocol/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func TestCurrencyWarsEndCommandQueuesOnlyActiveRun(t *testing.T) {
|
||||
chdirRepoRootSDK(t)
|
||||
t.Setenv("GAC_CONFIG", "server.json")
|
||||
if err := os.WriteFile("persistent", []byte(`{}`), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err := common.LoadCurrencyWarsCatalog()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg, err := common.LoadRuntimeConfig()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data := &pb.GridFightGetDataScRsp{DHFOFLFCLAH: &pb.MPIMAEMCEFH{UniqueId: 5, DivisionId: c.CapturedStages[0].ID, LJNGPCKPJLF: c.ActiveSeasonID, NAGDJGMMCBE: []*pb.GridFightGameInfo{{LEOIAOFBBFA: &pb.GridFightGameInfo_FAOCFBOFCJP{FAOCFBOFCJP: &pb.NIHNGPKHEPC{}}}}}}
|
||||
wire, err := proto.Marshal(data)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
snapshot := common.NewCurrencyWarsSnapshot(cfg.PlayerUID, c.ClientVersion, c.Provenance.GameAssemblySHA256, wire)
|
||||
if _, err := common.CommitCurrencyWarsSnapshot(0, snapshot); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
invoke := func(command string) map[string]any {
|
||||
t.Helper()
|
||||
w := httptest.NewRecorder()
|
||||
apiCurrencyWarsCommand(w, command)
|
||||
var result map[string]any
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &result); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return result
|
||||
}
|
||||
if result := invoke("/cw end now"); result["success"] != false {
|
||||
t.Fatal("end accepted extra arguments")
|
||||
}
|
||||
queued, err := common.ReadCurrencyWarsCommands()
|
||||
if err != nil || len(queued) != 0 {
|
||||
t.Fatal("invalid request queued a command")
|
||||
}
|
||||
result := invoke("/cw end")
|
||||
if result["success"] != true || result["state"] != "queued" || !strings.Contains(result["output"].(string), "quit") {
|
||||
t.Fatalf("unexpected response: %v", result)
|
||||
}
|
||||
queued, err = common.ReadCurrencyWarsCommands()
|
||||
if err != nil || len(queued) != 1 || queued[0].UID != cfg.PlayerUID || queued[0].RunID != data.DHFOFLFCLAH.UniqueId || queued[0].Field != common.CurrencyWarsCommandEnd {
|
||||
t.Fatalf("unexpected queue: %v %v", queued, err)
|
||||
}
|
||||
current, err := common.ReadCurrencyWarsSnapshot(cfg.PlayerUID, c.ClientVersion, c.Provenance.GameAssemblySHA256)
|
||||
if err != nil || current.Revision != 1 || string(current.WireData) != string(wire) {
|
||||
t.Fatal("API changed active run instead of queuing")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user