Repository navigation
Conversation
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.
The weekly mutation run listed 316 missed mutants in Issue #95: 303 in the TypeScript package and 13 in the Rust crate. This PR adds tests for the real gaps and rewrites code where a mutant could not change behavior. Mutants that no test can catch are marked with a reason. The tests also found two bugs, and this PR fixes them.
Closes #95
Bugs found
uintSchema(EVM HTTP) threw aSyntaxErrorfor text such as"1a"instead of returning a parse failure. Zod 4 runs.refineeven after.regexfails, andBigInt("1a")throws. The regex now has{ abort: true }..max(44, { abort: true })and.max(88, { abort: true })stop first. A test checks that very long input is rejected in under 250 ms.How each finding is handled
src/commonbase58 and hex checkshasBase58DecodedLengthcounts bytes with no loops: leading1s plus the hex length of the decoded number.BASE58_PATTERNis gone (the decode rejects other characters). New tests: byte counts, leading zeros, an address whose top byte is0x01, bad characters, the issue messages, and Hex32 anchors.src/commonHTTP client/:[A-Za-z]/. The body isJSON.stringify(body), which isundefinedfor an endpoint without one. New tests: accept and content-type headers, a missing base URL, numbers, paths without a leading slash, loose record queries, null params and queries, error fields, and plain-text errors.src/contracts/eventsfailed:lines, padded base64, and payloads under 8 bytes.Number.isSafeIntegeris gone:\d+always gives a whole number, andInfinityfailsdepth > 64. Two mutants are marked: an extra first stack entry anddepth + 1keep the same top frame.src/evm/http.tstests/evm-http.test.tscovers every schema: address and uint anchors, the 2^256 limit, token symbols and decimals, metadata limits, duplicate tokens (also by case), proofs, private joins, authorizations, game responses and game pages. Upper case finds the same duplicate symbols as lower case, so that mutant is marked.src/amountsBigInt("")is0n, so the `src/oracle,src/web/verification.ts,src/solana/plans/contract-adapter.tstokenAmount === undefined || tokenAmount <= 0n.scripts/check-coverage.tsexcludeuses?.some. LCOV line data is read with one anchored regex (DA:<line>,<hits>[,<checksum>]).git ls-filesoutput needs no backslash replacement and is already sorted. A path outside the root matches no tracked file, so its special case is gone. New tests: scope roots, globs,trackedFiles, extra LCOV records, data outside a record, a missingend_of_record, several extensions and several missing files.scripts/check-evm-upstream.ts,scripts/check-package-version.tsBun.file().json(). The npm error check reads.error.codedirectly, so output without an error object throws like plain text. The main-script checks are marked: tests import these files.address.rs!(32..=44).contains(&len)(the clippy form). New cases: exactly 16 seeds and a 32-byte seed are allowed.amounts.rsformat!("{digits:0>width$}"). New cases:0.5,0.123,1.234.contracts.rsdata.starts_with(&GAME_ACCOUNT)replaces the length and slice check. New cases: short data, free space after the participants, and a participant count past the data.events.rsdepth - 1→depth + 1ordepth / 1inget_trusted_program_datais excluded in.cargo/mutants.toml, for the same reason as in TypeScript.plans.rs,validators.rsis_base64_transactionaccepts 16 384 characters but not more.All changes
src/common/index.ts: the two bug fixes above, the loop-free byte count, the simpler parameter check and the request body.src/evm/http.ts:{ abort: true }on the uint regex.src/contracts/events/index.ts: noNumber.isSafeInteger; two marked mutants.src/amounts/index.ts,src/oracle/index.ts,src/web/verification.ts,src/solana/plans/contract-adapter.ts: the small rewrites and marks in the table.scripts/check-coverage.ts,scripts/check-evm-upstream.ts,scripts/check-package-version.ts: the rewrites in the table.crates/timba-protocol/src/{address,amounts,contracts,events,plans,validators}.rs: rewrites and tests..cargo/mutants.toml: one exclusion with its reason.tests/evm-http.test.ts; more cases inscripts/check-coverage.test.tsand in the amounts, client, events, package-version, protocol, randomness, Solana adapter, plans and token-program, token-policy, verification and workflow tests.dist/: rebuilt.package.json,Cargo.toml,Cargo.lockand the README tag, because the latest release is v0.18.3.Done when
bun run format:check,bun run typecheck,bun test(207 pass),check:rust-fixturesand the 100% line coverage gate pass on 560ec14.cargo fmt --check,cargo clippy --all-features --all-targets -D warningsandcargo test --all-featurespass on 560ec14.Review
Pending.