Repository navigation
test(cargo-budget-report): cover every arg_spec render and error path (#696) - #777
Merged
mallison031 merged 1 commit intoSep 29, 2026
Merged
Conversation
…Tollcraft#696) Take cargo-budget-report/src/arg_spec.rs from 85.5% to 100% production-line coverage (cargo llvm-cov), 8 tests to 68. Ten lines of the renderer were unreachable before: the forwarded boolean, the non-scalar rejection, both explicit and invalid `bool` values, malformed hex for `bytes`/`bytesn`, and the whole explicit-`address` branch. Covers all ten scalar keywords, both bytes keywords, all four structured keywords, generate-derived addresses at every seed length (including empty and multibyte names), the unknown/mistyped/`type` vocabulary, and the untagged-enum + deny_unknown_fields deserialisation surface. Two defects are pinned as current behaviour rather than fixed, since this issue is tests-only: a TOML datetime under `type = "json"` forwards {"$__toml_private_datetime": "..."}, and `generate = true` reads the name through a `seed[i % seed.len()]` window, so "ab" and "abab" derive the same dummy address. Both are documented in the tests that pin them.
|
@Dreal-pyper Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
MergeKeeper review Scope: in scope for linked issue This PR adds comprehensive unit-test coverage for Reviewed commit: |
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.
Description
Adds comprehensive unit-test coverage for
cargo-budget-report/src/arg_spec.rs— the module thatturns the typed
budget.tomlargument specs introduced in #152 into the flatstellarCLI argv.The file went from 8 tests to 68 tests (+898 lines, one file;
arg_spec.rsis now 1143 linesand no production line was modified). Tests live in the module's existing inline
#[cfg(test)] mod tests, becausegenerated_address()is module-private and a sibling test modulecould not reach it — that's also why the new tests sit next to the 8 originals rather than in
cargo-budget-report/tests/like #700'scli_arg_tests.Coverage is organised by the shape of the code, with section banners in the file:
u32 … stringkeywords,bool, value forwardingbytes/bytesnaddressexplicitaddressgenerate = truejson/struct/vec/map{:#}chain for each failuredeny_unknown_fields, untagged-enum errorsError assertions pin the complete anyhow chain (
format!("{:#}", err)→function `f`, argument `x`: <cause>) rather than substrings, so a rewordedcontext()call fails loudly. Related-issuetest count: none of the production code changed; this PR is test-only plus one CHANGELOG entry.
Related Issue
Closes #696
Motivation and Context
#696 asks for happy-path and error-path unit tests for
arg_spec.rs. Measuring first showed thegap was narrow but real: 10 uncovered production lines out of 69, and they clustered on exactly
the paths most likely to be broken silently — the whole explicit-address branch and every
value-rejection message.
Baseline → after (
cargo llvm-cov,arg_spec.rsproduction lines only):Lines 111–115 — the entire explicit
addressvalue path — had never executed. Neither had thefour rejection arms at 84, 85, 96, 97 (boolean forwarded for a scalar type, non-scalar value,
explicit
boolvalue, non-booleanboolvalue) nor the malformed-hex bail at 103. All arenow covered.
The remaining 21 uncovered lines in the file are all inside
mod tests: assertion message stringsthat only run when a test fails. Those are not reachable in a green suite, by definition.
Two behaviours pinned as findings, not fixed
The issue scopes this work to tests, so both are locked in by assertion with an explanatory comment
instead of being silently patched. Each is worth a follow-up issue:
addressis validated by prefix only. A value starting withGis accepted however short,empty-tail or otherwise malformed —
generated_address/explicit addresses never reach a realstrkey decode.
address_is_checked_by_prefix_onlyanda_muxed_account_strkey_is_rejected_by_the_prefix_rulepin today's behaviour. (
"G"alone passes; it is deliberately in the accept list.)generated_addressreads the seed through a repeating 32-byte window. Two argument namescollide whenever one is a whole repetition of the other, so
ab≡abab, and any two names thatshare a 32-byte prefix collide outright (
"z"×31≡"z"×32). Pinned bygenerated_address_reads_the_name_through_a_repeating_window. I verified the collision classindependently against a replica of the FNV-1a loop. Realistic contract argument names
(
sender_accountvsreceiver_account) do not collide, so this is latent rather than live.Also pinned incidentally: a TOML
datetimeundertype = "json"forwards as{"$__toml_private_datetime":"…"}— toml-crate internal encoding leaking into CLI arguments(
a_toml_datetime_forwards_as_tomls_private_json_shape).Scope notes
an_unrecognised_key_is_an_error_not_an_ignored_flagasserts serde'suntagged enum ArgSpecwording: serde swallows the inner
deny_unknown_fieldsreason, so the precise cause isunobservable through the untagged enum. The test records that fact instead of over-claiming.
account(seed)helper wrappingstellar_strkey::ed25519::PublicKeyrather than pasted real-looking accounts, so no testcontains anything resembling a live address or key.
ROADMAP.mdcheckbox not done: the issue asks to check off the corresponding box, but thisrepository has no
ROADMAP.md(nor thePRD.md/ARCHITECTURE.md/AGENTS.mdthe issuelists as mandatory context). Nothing to tick; flagging rather than inventing a file.
How Has This Been Tested?
cargo testcargo clippycargo fmtamm-pool-contract/tests/budget_test.rswhen contract, build profile, or toolchain changes may affect them — not applicable: no contract code, no build profile, no toolchain change.Commands run from the workspace root on the pinned
1.91.0toolchain:cargo fmt --all -- --check→ clean.cargo clippy --workspace --all-targets -- -D warnings→ clean, no warnings.scripts/check-module-reachability.sh→ "all .rs files under src/ are reachable".cargo test -p cargo-budget-report→ 768 unit tests pass, 60 more than before this branch(the 8 → 68 delta above), plus generate-manpage 21 and exit_code_tests 5.
cargo llvm-covfor the before/after table above. Note--branchcannot run on the pinnedstable toolchain (
the option 'Z' is only accepted on the nightly compiler), so the figures areline/function/region coverage only —
coverage.ymlreports coverage and does not gate on it.One test in the crate's integration suite fails on this machine and does not fail on CI:
soroban_sdk_stub_compiles_as_workspace_member, withld: dynamic executables or dylibs must link with libSystem.dylib. It is a macOS cdylib-linkinglimitation for the generated fixture crates (CI runs
ubuntu-latest). I reproduced it identicallyon an untouched worktree at
main's tip, so it is pre-existing and unrelated to this change.Reviewer notes
cargo-budget-report/src/arg_spec.rs#766 also editsarg_spec.rs, but onlyrender_args' allocation(
Vec::with_capacity+shrink_to_fit) — far frommod testsat the end of the file. Nosemantic conflict expected.
## Unreleased→### Addedheading, sowhoever merges second takes a one-line conflict.
Types of changes
Test-only change (plus a CHANGELOG entry). No production behaviour altered; the two defective
behaviours found are pinned by tests and reported here rather than fixed, per the issue's scope
guidance.