GeezerVison is showing github.com — test(combos): resolve cooled accounts by id, not by filtered position · lidge-jun/opencodex@e8ee8a8
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: tests/adapters/anthropic/anthropic-combo-account-cooldown.test.ts +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -146,8 +146,16 @@ test("a spent pool account does not cool the combo target for the accounts that |
146 | 146 | expect(served.status).toBe(200); |
147 | 147 | // The retry left through an account the first request had not spent. |
148 | 148 | expect(sentTokens.length).toBeGreaterThan(0); |
149 | | - const cooledTokens = cooled.map((_, index) => `Bearer ${credential(index).access}`); |
| 149 | + // Map each COOLED id back to its own token. `cooled` is a filtered subset of `ids`, so its |
| 150 | + // positions are not account indexes: with accounts 0 and 2 cooled, indexing by position would |
| 151 | + // check tokens 0 and 1 and let a retry through cooled account 2 unnoticed. |
| 152 | + const cooledTokens = cooled.map(id => `Bearer ${credential(ids.indexOf(id)).access}`); |
150 | 153 | expect(cooledTokens).not.toContain(sentTokens[0]!); |
| 154 | + // Stated the other way round, from the token actually sent: resolve it back to its account and |
| 155 | + // assert that account is one the first request never cooled. |
| 156 | + const servedIndex = ids.findIndex((_, index) => sentTokens[0] === `Bearer ${credential(index).access}`); |
| 157 | + expect(servedIndex).toBeGreaterThanOrEqual(0); |
| 158 | + expect(cooled).not.toContain(ids[servedIndex]!); |
151 | 159 | }, 20_000); |
152 | 160 |
|
153 | 161 | test("every pool account spent still cools the combo target", async () => { |
|