diff --git a/CHANGELOG.md b/CHANGELOG.md index c2a0ef1..939dd2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Multiple bugs preventing production server from working properly - CI builds should be working now - Team registration now correctly writes names to files +- Anonymized team names now only computed once per team ## [v4.0-rc1] - 2020-10-13 ### Changed diff --git a/cmd/mothd/server.go b/cmd/mothd/server.go index 9f83c7a..97c90b3 100644 --- a/cmd/mothd/server.go +++ b/cmd/mothd/server.go @@ -196,8 +196,8 @@ func (mh *MothRequestHandler) exportStateIfRegistered(override bool) *StateExpor } else { exportID := strconv.Itoa(logno) name, _ := mh.State.TeamName(awd.TeamID) - awd.TeamID = exportID exportIDs[awd.TeamID] = awd.TeamID + awd.TeamID = exportID export.TeamNames[exportID] = name } export.PointsLog[logno] = awd diff --git a/cmd/mothd/server_test.go b/cmd/mothd/server_test.go index bc2526f..9144b2e 100644 --- a/cmd/mothd/server_test.go +++ b/cmd/mothd/server_test.go @@ -133,5 +133,20 @@ func TestServer(t *testing.T) { r.Close() } + if err := handler.CheckAnswer("pategory", 2, "wat"); err != nil { + t.Error("Right answer marked wrong:", err) + } + + time.Sleep(TestMaintenanceInterval) + es = anonHandler.ExportState() + if len(es.TeamNames) != 2 { + t.Error("Anonymous TeamNames is wrong:", es.TeamNames) + } + + es = handler.ExportState() + if len(es.TeamNames) != 1 { + t.Error("TeamNames is wrong:", es.TeamNames) + } + // BUG(neale): We aren't currently testing the various ways to disable the server } diff --git a/cmd/mothd/state_test.go b/cmd/mothd/state_test.go index 2cbae4b..c05bd3b 100644 --- a/cmd/mothd/state_test.go +++ b/cmd/mothd/state_test.go @@ -89,6 +89,10 @@ func TestState(t *testing.T) { t.Error("Duplicate points award didn't fail") } + if err := s.AwardPoints(teamID, category, points+1); err != nil { + t.Error("Awarding more points:", err) + } + pl = s.PointsLog() if len(pl) != 1 { t.Errorf("After awarding points, points log has length %d", len(pl)) @@ -104,7 +108,7 @@ func TestState(t *testing.T) { t.Error(err) } s.refresh() - if len(s.PointsLog()) != 1 { + if len(s.PointsLog()) != 2 { t.Error("Intentional parse error screws up all parsing") }