fix: reject ambiguous Riot winner evidence
This commit is contained in:
1 parent
575cd911cb
commit
6aa2cb9009
2 files changed
+22
-1
No files matched your search
@@ -211,6 +211,22 @@ describe('Competition result Riot mapping', () => {
|
|||||||
).toBeNull();
|
).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('rejects inconsistent Riot evidence with more than one winning team', () => {
|
||||||
|
const { competition, detail, lookup } = fixture();
|
||||||
|
detail.info.teams.forEach((team) => {
|
||||||
|
team.win = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
mapRiotGameToCompetitionSlot({
|
||||||
|
competition,
|
||||||
|
target: competition.projection.gameSlots[0],
|
||||||
|
detail,
|
||||||
|
lookup,
|
||||||
|
}),
|
||||||
|
).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it('orders collected Riot games by occurrence before first-to projection', () => {
|
it('orders collected Riot games by occurrence before first-to projection', () => {
|
||||||
const { detail } = fixture();
|
const { detail } = fixture();
|
||||||
const later = {
|
const later = {
|
||||||
|
|||||||
@@ -155,7 +155,12 @@ export function mapRiotGameToCompetitionSlot(params: {
|
|||||||
const blueTeamId =
|
const blueTeamId =
|
||||||
normalOverlap > reversedOverlap ? slotATeamId : slotBTeamId;
|
normalOverlap > reversedOverlap ? slotATeamId : slotBTeamId;
|
||||||
const redTeamId = normalOverlap > reversedOverlap ? slotBTeamId : slotATeamId;
|
const redTeamId = normalOverlap > reversedOverlap ? slotBTeamId : slotATeamId;
|
||||||
const winningRiotTeam = detail.info.teams.find(({ win }) => win);
|
const winningRiotTeams = detail.info.teams.filter(
|
||||||
|
({ teamId, win }) =>
|
||||||
|
win && (teamId === RIOT_BLUE_TEAM_ID || teamId === RIOT_RED_TEAM_ID),
|
||||||
|
);
|
||||||
|
if (winningRiotTeams.length !== 1) return null;
|
||||||
|
const winningRiotTeam = winningRiotTeams[0];
|
||||||
const winnerTeamId =
|
const winnerTeamId =
|
||||||
winningRiotTeam?.teamId === RIOT_BLUE_TEAM_ID
|
winningRiotTeam?.teamId === RIOT_BLUE_TEAM_ID
|
||||||
? blueTeamId
|
? blueTeamId
|
||||||
|
|||||||
Reference in new issue
Block a user