Skip to content

Raise per-file coverage to 90% - #5

Merged
senamakel merged 22 commits into
mainfrom
coverage-per-file-90
Aug 10, 2026
Merged

Raise per-file coverage to 90%#5
senamakel merged 22 commits into
mainfrom
coverage-per-file-90

Conversation

@senamakel

@senamakel senamakel commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

Raises all source and test files to at least 90% line coverage, reaching 96.59% overall line coverage.

Adds focused coverage for malformed client responses, Tron transactions, BIP-32/key-derivation failures, and EVM encoding safeguards. It also removes redundant address re-parsing and compiles feature-disabled dispatch fallbacks only when applicable.

Public API / behavior changes

None.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo build --all-targets --all-features
  • cargo test --all-features
  • cargo llvm-cov --all-features --all-targets

Related issue: none.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Bitcoin address validation to reject unsupported networks and malformed SegWit addresses.
    • Improved validation of Tron addresses, transaction data, account responses, and broadcast results.
    • Strengthened handling of malformed EVM and Solana responses.
    • Improved derivation error reporting for invalid paths and key-generation failures.
    • Prevented transaction signing failures and panics caused by invalid hexadecimal values, recovery IDs, or oversized chain IDs.
  • Reliability

    • Added broader validation coverage to improve consistent error handling across supported networks.

senamakel and others added 21 commits August 10, 2026 17:40
The coverage.json file was being tracked unintentionally, so it has been added to .gitignore to prevent future commits from including generated coverage data.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add three new test cases that verify the client correctly rejects malformed responses from EVM and Solana nodes. The EVM tests check that a non-string balance and a non-string transaction hash are both reported as malformed responses, and the Solana test verifies that missing blockhash fields and invalid signature strings are handled correctly.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add two new test cases for the Tron client: one verifying that malformed account and transaction responses are correctly rejected with a MalformedResponse error, and another confirming that a successful broadcast returns the expected transaction ID. Also fix the Solana test to use explicit mnemonic and derivation path constants instead of the VECTOR and SOLANA_PATH variables.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add two test cases that were missing from the test suite: one verifying that a Solana derivation path with a non-numeric segment is rejected, and another confirming that an EIP-155 chain ID causing a v-value overflow is properly rejected with an InvalidField error.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updated the coverage.json file to reflect the latest test run results, which include changes in coverage percentages across multiple source files.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…oadcast response

Add two test cases: one verifying that a base58check value with the correct prefix but wrong length is rejected, and another ensuring that the Tron client correctly handles both a missing txid in the create transaction response and a malformed broadcast response body.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updated the coverage.json file to reflect the latest test run results, ensuring the coverage report stays in sync with the current state of the codebase.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The `validate_sender` function now trims the input and checks for empty addresses before parsing, and replaces the implicit `assume_checked` call with an explicit `require_network(Network::Bitcoin)` to ensure the address is on mainnet, returning a clear `WrongNetwork` error instead of panicking or silently accepting testnet addresses.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Changed the error construction in `validate_sender` to call `to_string()` on the trimmed address instead of `clone()`, since the address is already a `&str` and converting it to an owned `String` is more idiomatic than cloning a reference.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reformatted several match arm patterns across the Tron address and client test files to use a multi-line layout with the `..` wildcard on its own line, improving readability and consistency with the project's existing style conventions.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The function now returns an owned `String` instead of a borrowed `&str` for both the success and error paths, ensuring the caller does not need to manage lifetimes of the trimmed address slice.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updated the coverage.json file to reflect the latest test run results, ensuring the coverage report stays in sync with the current state of the codebase.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reformatted several function calls and assertion expressions across the BIP-32, Bitcoin, and test modules to improve code readability by breaking long lines and adjusting indentation. No functional changes were made.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The test for derivation backend failures now exercises the compressed public key path by constructing a valid compressed key from an uncompressed private key, rather than injecting an artificial error. This ensures the error handling logic is tested against a realistic input that exercises the actual compression code path.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reformatted the test code to reduce unnecessary line breaks and improve readability without changing any behavior. The change consolidates the function call chain into a more compact layout while preserving the exact same logic and error handling.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Replace the `#[allow(unreachable_patterns)]` attribute on the catch-all arm in both `validate` and `chain_enabled` with a `#[cfg(not(all(...)))]` condition that suppresses the arm only when all four chain features are enabled. This makes the unreachable pattern warning disappear at compile time rather than silencing it, ensuring the code correctly reflects which chains are actually compiled in.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Removed the `test` module declarations from `src/address/mod.rs` and the corresponding test files, as these tests are no longer needed. The coverage data was updated to reflect the removal of these files from the coverage report.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The coverage.json file was being tracked in the repository, but coverage data is a generated artifact that should not be version controlled. Removing it keeps the repository clean of build outputs and prevents unnecessary diffs on every test run.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel senamakel self-assigned this Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@senamakel, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 94b281f1-780c-42b7-98d4-bba8e8c811af

📥 Commits

Reviewing files that changed from the base of the PR and between a7e0cb5 and ed04f0e.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml
📝 Walkthrough

Walkthrough

This PR hardens address validation, key derivation error mapping, EVM transaction encoding, and client response validation. It adds targeted tests for malformed inputs, backend failures, overflow cases, and chain-specific response errors.

Changes

Validation and error handling hardening

Layer / File(s) Summary
Address validation and feature guards
src/address/btc.rs, src/address/mod.rs, src/address/test.rs, src/address/tron/test.rs
Bitcoin sender validation now checks trimmed mainnet P2WPKH input directly. Chain fallback arms use conditional compilation. Tron invalid-length addresses are rejected.
Key derivation error mapping
src/key/bip32.rs, src/key/btc.rs, src/key/test.rs
BIP-32 and Bitcoin compressed-key failures map to labeled Error::Derivation values. Solana path parsing and backend error mappings are tested.
EVM transaction validation
src/tx/evm.rs, src/tx/test.rs
Shared helpers handle hex decoding, recovery-ID conversion, and checked EIP-155 v calculation. Invalid and overflowing inputs have structured error coverage.
Client response validation coverage
src/client/test.rs
Tests cover malformed EVM, Solana, and Tron responses, EVM calldata submission, and successful Tron broadcast handling.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • tinyhumansai/tinywallet#1: Introduces functions refined here for Bitcoin address validation and chain-feature fallback handling.
  • tinyhumansai/tinywallet#3: Introduces functions refined here for BIP-32 derivation, Bitcoin derivation, and EVM transaction signing.

Poem

A rabbit checks each path and key,
While errors hop where they should be.
Hex and hashes now stand in line,
Bad chains stop at the proper sign.
“Validated!” thumps the bunny’s toe.
Safer wallet flows now glow.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary objective: raising per-file test coverage to at least 90%.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel
senamakel merged commit 537340e into main Aug 10, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant