Repository navigation
Conversation
|
Mutation testing: 2933 of 2953 changes caught by a test. Each one is a change to the code no test noticed. Not a blocker: real gaps get their own PR. Full report |
The percentage swap looked up the wallet balance by mint or by ticker. Two tokens can share a ticker, so a "50%" swap could take the balance and decimals of another mint with the same ticker. Now the lookup uses the resolved input mint only. The new test has two BONK tokens with different mints and decimals. It fails with the old lookup. It also kills the ObjectLiteral mutant on the tokenBalance snapshot.
wallet.getTokenMetadata is typed to resolve to an object, and every return path returns an object (resolver result, resolveTokenMetadata result or cache entry) or throws. So metadata?.decimals and metadata.decimals always read the same value. This removes an equivalent OptionalChaining mutant.
The text and media input handlers run clearInputSession(sessionKey, lockerId) on every try and catch path. That call deletes the session while this locker owns it, and setInputSession strips the lock fields from a new session. So when finally runs, no session is locked by lockerId and clearInputSessionProcessing does nothing. The CallExpression mutant that removes it cannot be told apart.
The target lookup reads the legacy game record with optional chaining. The new test returns no record for that lookup and expects no warning, the flush log line and one notification to the live message. It kills the OptionalChaining mutant on gameRecord?.chat_id and the mutant that removes the flush log.
A debounce of exactly MAX_TIMER_DELAY_MS fits in one timer. The test runs only the pending timer and expects one render. The mutant that also splits this delay (>= instead of >) chains a second timer, so the render does not happen. This kills that EqualityOperator mutant.
The args list used two conditional spreads. When no player count was typed, the ArrayDeclaration mutant put "Stryker was here" in the players slot, and inferMaxPlayers ignores a non-numeric value there, so the mutant was equivalent. The list now drops undefined parts with a filter. The command args never hold an empty string (they are filtered with Boolean), so this keeps the same list for every input. A new test types a coinflip with players and no token. With the other tests it kills every mutant of the new filter.
The typed player count check started with value === null. Since null < 1 is true, the ConditionalExpression mutant that drops this test was equivalent. A reply that is not an integer now becomes 0, which is below the minimum for every game type, so the range check alone rejects it. The accepted and rejected inputs stay the same. New tests type each limit for coinflip and giveaway: 1 and 0 are rejected, 2, 1 and 100 are accepted. They kill the coinflip, <= and >= mutants on this line, and the && mutant of the new fallback.
New probe tests check an empty error message ("error"), the 80
character cut, redaction of a plain http:// URL, the latency of an HTTP
failure with an injected clock, and a JSON body of null. They kill the
StringLiteral, MethodExpression and Regex mutants in
describeProbeError, the ArithmeticOperator mutant in the HTTP failure
branch, and the two OptionalChaining mutants on the payload.
clampChatPlayers already returns null for a null candidate (Number.isFinite(null ?? NaN) is false). So the parsed === null guard before it gave the same result on every path, and its ConditionalExpression mutant was equivalent. The guard is removed.
…esults A join-rate prompt whose update and reply carry no chat id must not open an input session. This kills the ConditionalExpression mutant on chatId != null. The join-rate tests now also check that handleSettingsInput reports the invalid-rate and expired-session replies as handled, which kills the BooleanLiteral mutant on the invalid-rate return.
A claim that fails because the wallet returned an invalid raw balance stores that message in last_error. The test now checks it, which kills the StringLiteral mutant on the error text.
…k to amounts
New prompt-target tests:
- a custom amount callback without a message stores the prompt under
the sent reply (kills the OptionalChaining mutant on message_id);
- a callback without a chat stores an edited prompt under the message
chat, not chat 0 (kills chatId === originalChatId -> true);
- a sender id that only the setup module sees makes requireTelegramId
throw, and the logged error names "type amount prompt" (kills the
StringLiteral mutant on that label);
- back to amounts uses the stored balance and minimum for the keyboard
without a wallet read (kills the ObjectLiteral mutant on
{ session, tokenContext }).
The compact players test now also checks the cancel button text and
callback data (kills two StringLiteral mutants).
…ct players prompt Commit 244d8b7 dropped ...(creatorContext.session ?? {}) from this storeSetupPromptSession call. On the same-message path the old code wrote the fields read at the start of the handler. The new code wrote only the prompt fields and merged them with the stored state at write time. The two differ when the stored setup changes or expires while the prompt edit is in flight. This restores the old form and removes the comment that claimed both paths were the same. The new test clears the stored setup during the edit and expects the fields read before the edit. It fails without the spread and with the && mutant of ??. Both forms bring back a setup that was cancelled during the edit. That race is older than this change and is not fixed here.
…disabling them The Stryker disable on the typed player range check hid killable ConditionalExpression mutants: a check that is always true rejects a valid count, one that is always false accepts 0 or 999, and dropping players < minPlayers accepts 1. The disable is removed. New tests type "1" (rejected) and "2" (accepted) for a coinflip. With the existing 20 and 21 tests they kill every variant except players === null -> false, which is equivalent because null < minPlayers is true.
The custom amount prompt test now checks the edited text, the HTML parse mode and the cancel keyboard. This kills the ObjectLiteral mutant on the respondWithMenu payload and the StringLiteral mutant on "HTML" in presentCustomAmountPrompt.
New send tests choose 50% of a token balance, once with the quick button and once typed into the custom amount prompt. Both expect half of the raw balance. They kill the ObjectLiteral mutants on the tokenBalance snapshot in both send paths. A wrap confirmation whose data repeats the prefix is now rejected, which kills the Regex mutant without ^. The wrap handler is registered with bot.callbackQuery(/^confirm_wrap_/), so ctx.callbackQuery and its data are always set there. The OptionalChaining and StringLiteral mutants on that read are excluded.
selectSolanaPairs looped over pairs ?? []. Its ArrayDeclaration mutant looped over a string instead, and every character was skipped because it has no chainId, so the mutant was equivalent. The function now returns [] when pairs is null or undefined and then loops over pairs. The result is the same for every input, and the existing selectSolanaPairs(null) test kills every mutant of the new guard.
…them The Stryker disable on the GeckoTerminal trade filter hid killable ConditionalExpression mutants: a filter that is always true drops every trade, and one that is always false keeps a zero amount. The disable is removed. New cases expect null for a zero token amount, a blank transaction hash and a missing trader. They kill every variant except tokenAmount == null -> false, which is equivalent because null <= 0 is true.
New pool trade poller tests: - each malformed trades response doubles the wait before the next request, and the reported error names the malformed response (kills the StringLiteral mutant and the removed deferAfterTradeFailure call); - a snapshot with a trade that does not parse still emits the newer buy (kills if (!event) -> false); - a response that arrives after stop() emits nothing (kills the removed watches.clear() call). The two Stryker disables in pollNow hid killable "-> true" mutants that drop every pool. The ConditionalExpression part is removed from both; the existing emit tests kill those variants. The "-> false" variants stay as documented survivors: setMints stores a watch for every mint, and refreshPoolQueue queues only pools with a target. The ArrayDeclaration disable stays, because that empty list is never returned. The trade time now parses String(block_timestamp) instead of block_timestamp ?? "". A missing value gives "undefined", which parses to NaN like "", so the result is the same and the equivalent StringLiteral mutant is gone.
belowMinimum runs only inside the publish filter chain, after matchesMint read an enabled row for the same chat. The chain is synchronous, so the row is still there and the OptionalChaining mutant cannot be told apart.
…imum A chat that is still in the enabled list but has no alert row any more is skipped without an error. This kills the OptionalChaining mutant on config?.enabled. A 0.1 SOL buy against a 100_000_000 lamport minimum is posted, because adding 1e-9 to 1e8 does not change the double. This kills the <= mutant of the dust check.
…te check The price check used null for a missing timestamp and then tested timestamp === null || !Number.isFinite(timestamp). Number.isFinite(null) is false, so the null test was redundant and its ConditionalExpression mutant was equivalent. A missing timestamp is now NaN, and the finite check alone rejects it with the same reason.
The Stryker disable on the claimed-delta check hid a killable mutant: with < instead of >=, an outgoing delta (for example -7) is skipped and an incoming one is recorded. The existing "records only an outgoing delta" tests kill it, so the disable is removed. The > variant stays as a documented survivor, because referralDeltaFromTransaction returns null for a zero delta. The claim order test now checks the "Referral claim 2/4" and "4/4" log lines, which kills the StringLiteral and ArithmeticOperator mutants in that log.
…check priceRawAmount rejected price === null, a non-finite price and a negative price before it multiplied. The null test and the finite test were both redundant, so their ConditionalExpression and LogicalOperator mutants were equivalent. A missing price now becomes NaN, and !(unitPrice >= 0) rejects NaN and every negative price, including -Infinity. A +Infinity price gives a value that is not finite (Infinity or NaN), which the existing last check turns into null. -0 still returns 0. Every mutant of the new lines is killed by the finance report tests.
- invoiceMatchesSats: the group ([munp]?) always takes part in a match, so match[2] is never undefined and the "" fallback is never used. - FixedFloatClient.requests: call() filters the list by r.at > now - 60_000 before it reads it. A placeholder [] has Array.prototype.at there, which compares false, so the new Array([]) mutant is dropped before any read.
satsToBtc("12x") and satsToBtc("1.2") must throw DepositInputError.
This kills the Regex mutant that drops the $ anchor of the sats
pattern in fixedfloat.ts.
- buildTokenPositions: a missing SOL price now gives NaN, not null, so the marked USD cost is NaN and Number.isFinite rejects it. The old markedUsd !== null check had no effect, because Number.isFinite(null) is false. - resolvePositionWork: cacheFresh is now cached !== undefined && cached.expiresAt > now. TypeScript narrows cached through cacheFresh, so the later cached?. and "cacheFresh && cached" checks go away. Map values are objects, so the old Boolean() test gave the same result.
Open
…rice set from null The changed-code job on dc8eb4d left two survivors that are not equivalent or need no mutant: removing the parsePositiveInteger clamp warning passed every test, and the empty list for an unfresh position cache could hold a placeholder. A test now expects the clamp warning, and the price set is built from null, which gives the same empty set as an empty list.
The check stopped reading the chat in f2250ee, so the options parameter had no reader. The two chat defaults tests that reach the expired-session reply now delete chatId from a typed copy of the session, with no cast.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #451
Scope
This PR covers three things.
It does not close Issue #451. The findings that remain open are under Left for follow-up PRs.
Left for follow-up PRs
The per-file ledger on checkpoint
5d5fd87has 9,810 open rows. "Not yet measured" rows were never scored after their part ran. "Source changed" rows are in code that changed after the row was scored, so the row must be scored again. The same list is in a comment on Issue #451.src/utils/game.tssrc/bot.tssrc/utils/wallet.tssrc/handlers/game-callbacks.tssrc/utils/game-database.tssrc/evm/bot.tssrc/handlers/chat-defaults.tssrc/utils/swap-manager.tssrc/handlers/wallet-transactions.tssrc/utils/token-manager.tssrc/services/positions.tssrc/handlers/lightning.tssrc/utils/jupiter.tssrc/handlers/faucet.tssrc/services/buy-alerts/pool-trades.tsEach follow-up PR takes one file or a group of small files, runs Stryker on it, and kills or documents each row. The ledger and the scripts are in
/mnt/data/agent-cache/bot-mutants/rotation/on mr.Also left: a known race on main. A
cancel_game_setup_callback that runs while the compact players prompt is being edited clears the setup, andstoreSetupPromptSessionthen writes it again. A fix needs a check that the setup still exists after the edit.Changes
debugLogcalls, whose arguments are pure trace text. A second skips only text literals inconsolelog arguments. Other mutants in those calls stay tested.e2b7cf8: 17 test kills, four dead-guard rewrites, and eight disable comments for equivalent mutants. Tests cover private join signers, probe type, token account errors, retry warning, history quotes and decimals, and zero stat limits.0edeb39).isFinalizedSlotcheck per slot.Number.isSafeIntegeris true only for a number, soNumber(value)is the value itself and every input gives the same result. Check text slots and the exact slots that the binary search reads (fb42acf,9b7aa37).Number.isSafeInteger, which is false for every value that is not a number. Same result for every input. Check a fee rate that JSON sends as text, and remove a disable whose reason was wrong (22e9dfe).price > 0inreadQuote, with a test for a zero quote and an amount that has no finite unit value. Name the player in the key warning (babdd99).recordRateLimit. TestInfinity,-Infinity,NaN,1e308and JSON values that are not numbers (4392c15).38c67cc).decodeUnsigned(82a4152).anyin the two new card test files (5ea4ba7).0a005f0).return, so Stryker never read them. A test kills each emptiedtry(afecce9,de36f7a).consumeprunes expired rate-limit buckets once per window (42351da).99c69cd,ca9dcfb,5f4fca9).inspectsees onlyJSON.parseoutput, soObject(value) !== valueequals the old primitive check. The stack frame and source location patterns are used only with.test(), and each old match contains a match of the shorter pattern (2f29d22).Numberdirectly.Number(null)is 0, which the positive check refuses like a missing fee. Check that an unusable RPC fee scales the fallback base fee (1f89936,8cdb6c2).NamedIdentityso a name without a picked user always has a username, which removes a!and two?? ""defaults (0968def,6765cea).@mentions (f852ba5).typeofchecks thatNumber.isFiniteorNumber.isIntegeralready make, incompleteGame,getRetryAfterSecondsandisMintDecimals(ed19213,f155dce,effbcfb).toLowerCase() === "sol". Only a ticker that upper-cases toSOLis native, and of those only the long s does not lower-case to ASCII, as the old pattern required. Exclude the two equivalent defaults in the price split (188bf1d).""for a request without a mint.normalizenever returns"", so nothing is stored there and the read misses as the early return did (40fab9f).acbc1e1).9ef71d3).unrefis optional, which retry delays become safe deadlines, a non-text RPC failure that prints as a miss, a nonzero block height given at insert, one result slot per item, the reason for a failed text edit, and prompt order by write time (4401d6b,fba0b08,704fd03,e5fd862,a0d1ef9,1b80244,dbbc222).categorizeErrorwith an empty message and a code of another type, and that an error's name does not pick the friendly reply (39ff932,58f4920). Fix the types of the new timer and RPC failure fakes (84bae4a).?.:getTokenMetadataalways returns an object or throws (771b13b).finallyblocks. Everytryandcatchpath already ranclearInputSession(sessionKey, lockerId), so no session that this locker holds is left (b89813c).732647d,dea6f28).filter.argsnever holds an empty string, so droppingundefineddrops exactly the missing parts. Read a non-integer EVM player reply as 0, which every game type refuses (87df8af,24eed28).581b19c).clampChatPlayershandle a null player count, which it already returns as null. Check prompt sessions without a chat and input results (1e00725,0ed0f49).13ffbd6).14cbdc7,d883c18,1e371a0).f263904).confirm_wrap_fallback: grammY runs this handler only for a matching callback query, so its data is always set (d84670f).d2a06d6).String(block_timestamp), which gives NaN for a missing time as before. Remove three disables; the-> falsevariants that no input reaches stay as listed survivors (de7646c,5d14b2e,0ab700d).9fb6edb).<(b1d3d16,644aa71).40576f2).ba557c5,aea0124).cacheFreshnarrows the cache entry (dc8eb4d).null, which gives the same empty set as[](296d372).f2250ee,aeae002).Bugs fixed
Infinity%. Keep scientific notation in a SOL shortfall message.2.5or12players.3players,1e2, or0x10.tests/buy-alerts.publisher.test.tschecks both cases.satsToBtcaccepts 16-digit amounts up to the 2,100,000,000,000,000 sats limit, which main refused. One above the limit and a 17-digit amount are refused (83cd859).344d5f0).17f754d).58c60a6).2a38b4f,babdd99).1f7b4d1,22e9dfe).92ac26c).collectErrorLogsreadsdata,errorandcauseonce each. Before, a getter that gives its value only once passed the check and then pushedundefined, so its logs were lost (289d2b0).0430a56).Changed-code mutants
The Mutants / Changed code job on the final commit
296d372(run 46396618729) scored the lines that this PR changes: 3,839 killed, 16 survived, 0 without coverage, 4 timeouts and 54 ignored (hidden by a disable comment or an ignorer). A timeout counts as detected.Each survivor left is equivalent: no input can tell it apart from the original. Each one shares its line and mutator with a mutant that a test kills, so a disable comment would hide that killable mutant too. These survivors are:
handlers/admin-status.ts:84typeof slot !== "number"→ false:Number.isSafeIntegerrejects every value that is not a number.handlers/game-callbacks.ts:128ctx.callbackQuery?.message→.message: it runs only inside callback query handlers.handlers/game-callbacks.ts:725players === null→ false:null < minPlayersis true, because every minimum is at least 1.handlers/lightning.ts:161if (messageId)→ true: a detach without a message changes no row.buy-alerts/pool-trades.ts:131tokenAmount == null→ false:null <= 0is true.buy-alerts/pool-trades.ts:401!watch→ false:setMintsstores a watch for every mint.buy-alerts/pool-trades.ts:413!target→ false: every queued pool has a target.buy-alerts/publisher.ts:221deliveredChats.size→ true: an empty set acts like no entry.fee-sweeper.ts:550>=→>: a zero delta is already null.lightning/fixedfloat.ts:104multiplier !== undefined→ true: the unit pattern allows only keys of the table.utils/callback-data.ts:59parsed === null→ false:null < 0is false, so null is returned either way.utils/game-creation-recovery.ts:123probes < maxProbes→ true,<=andprobes -= 1(3 mutants): a correct binary search ends before the bound.utils/game-creation-recovery.ts:132low <= high→ false andlow < high(2 mutants): the loop ends only whenlow > high.Review
The numbers match the review of 2026-11-29. Each item is done or rejected with a reason.
Scope decision:
Part of #451, an exact Scope, Left for follow-up PRs (also on Issue #451), the five Done when boxes, and Evidence as counts.for (let attempt = 0; ; attempt++); only a timeout before the last attempt continues, and every other path breaks or throws (2a38b4f).isTerminalRedraw: removed. A terminal redraw has the literal status"Completed", and both redirects need another status (2a38b4f).2a38b4f,babdd99).readQuote:Number.isFinite(price) && price > 0is back. The interimMath.max(price, 0)was not equivalent, because0 * Infinityis NaN. A test checks a zero quote (babdd99).getChatMember: the call is back, with an interleaving test that a hand mutant fails (2a38b4f).retry_after: 1e308and a 35-digit hint (17f754d).return. They are rewritten too.--memory 2g --cpus 2and a time limit. Full runs ran in CI.acceptedbranch): the job killed every mutant it made there (6, 39, 3, 19 and 9).92ac26c).debugTraceIgnorerchecks each argument withisPlainText, tested both ways (92ac26c).83cd859).344d5f0), listed under Bugs fixed.704b4bd). The swap balance now matches by mint only (0430a56).afterEach(3d79f30).useInstantRecoveryBackofffails on an unlisted delay of 1 second or more (3d79f30).withinTestDeadlineis 3,500 ms, below Bun's 5,000 ms timeout (3d79f30).errors.parsercase for a value that is not an array is back (3d79f30).as anyand 0 non-null assertions. The new test files usefake<Context>and a typed payload guard (5ea4ba7). Older test files lose moreanythan they gain. 17 test files reach private members with typed bracket access (gm["isPlayerInGame"]), which keeps names and signatures checked, unlike(gm as any).x(782 uses on main). Reasons: the game expiry, join, unjoin, key and active-list tests replace one step of a flow that needs a live chain;completion-state,stats-boundariesandupdate-message-recoveryneed a state that no public call sets up; the swap and wallet tests reach fee, token account, program cache and pending signature steps that have no public entry without RPC.Re-check review of
96ed686..296d372: 2 findings, both real, fixed inaeae002. One test added anas any(now a typed copy withchatIddeleted). The token check change was listed as a bug fix but keeps behavior, so it moved to Changes.Disable audit
Each
Stryker disablethat this PR adds, with the mutants that the final changed-code report shows as ignored on that line, and the two ignorers. Each verdict was checked against every input, including untyped JSON.bot.ts:6116;bot.ts:6206;evm/config.ts:23return evmBotConfigSchema.parse(JSON.parevm/setup.ts:153if (!action) throw new Error("Invalid seevm/setup.ts:230if (raw < BigInt(s.token.minimumAmount))evm/setup.ts:238""evm/setup.ts:278actions: [],evm/wallet.ts:10return mnemonicToAccount(mnemonic, { paspath ¦¦ m/44'/60'/0'/0/0handlers/wallet-transactions.ts:910ctx.callbackQuery.data,"Stryker was here!"services/buy-alerts/pool-trades.ts:401["Stryker was here"]setMintsstores a watch for every mint, so[]is never returnedservices/buy-alerts/publisher.ts:109deps.chatDb.getChatBuyAlerts(cservices/lightning/fixedfloat.ts:94"Stryker was here!"services/lightning/fixedfloat.ts:109new Array([])services/lightning/store.ts:32{},false?utils/callback-data.ts:89"Stryker was here!"utils/callback-data.ts:112encoded.charAtutils/callback-data.ts:114encoded.slice,"Stryker was here!"utils/game-database.ts:1947this.get<{ count: number }>(utils/game-database.ts:1950[],utils/game.ts:5683"Stryker was here!"utils/game.ts:5698() => undefinedundefinedandfalsetake the same pathutils/game.ts:6192"Stryker was here!"utils/game.ts:6217() => undefinedundefinedandfalsetake the same pathutils/game.ts:6467meta.decimalsutils/game.ts:6480lookup.priceutils/game.ts:8924// Stryker disable StringLiteral: operatdebugLogandconsole.errorutils/program-event-parser.ts:49return decodeFallback?.(logBase64) ?? nunullutils/program-event-parser.ts:72return parseProgramEventLogs(program.proutils/rpc-endpoints.ts:291""utils/telegram-rate-limiter.ts:443"Stryker was here!"utils/token-manager.ts:573"Stryker was here!",""Numberreads "" and "0" as 0utils/wallet.ts:2534{}undefinedlikenullandfalsescripts/stryker-ignorers.mjslog text ruleconsoleargumentsscripts/stryker-ignorers.mjsdebug trace ruledebugLog(...)callEvidence
This is a summary with counts. The full record (156 entries) is in the earlier body revisions of this PR and in
/mnt/data/agent-cache/bot-mutants/on mr.5d5fd87: 1,533 exact named kills, 11 narrow exclusions, 4,536 survivors, 321 coverage gaps, 1,369 rows to score again and 3,584 unmeasured rows.296d372: Validate (46396618738) ran 6,371 tests in 421 files for each contract version with 0 failures and passed the 100% line coverage gate. Static checks, Mutants / Changed code, CodeQL, CI / Required and Verify tested source tree pass. The mutation setup trial scored 386 killed, 76 survived, 2 without coverage and 15 ignored; it checks that the setup runs and is not a gate.Done when