Skip to content

Test the utils and factory packages - #213

Merged
edridudi merged 1 commit into
mainfrom
claude/utils-factory-tests
Sep 12, 2026
Merged

edridudi merged 1 commit into
mainfrom
claude/utils-factory-tests

Conversation

@edridudi

Copy link
Copy Markdown
Collaborator

utils and factory were the two thinnest packages in the codebase, and HexUtil had no tests at all.

Coverage

Measured on the same basis before and after (the preview suite plus the offline tests, which is what the Codecov job runs):

Before After
rest.koios.client.utils 57.8% 92.2%
rest.koios.client.backend.factory 56.2% 90.6%
Overall lines 76.9% 81.5%
Overall branches 63.4% 70.6%

Branch coverage gaining 7 points is the part that matters — those are untested decisions, not untested getters.

What the 29 tests actually assert

HexUtil (11) — had zero coverage. Round trips, 0x prefix handling, odd-length and non-hex rejection with the expected messages, and negative bytes not sign-extending (Byte.MIN_VALUE → 80, -1 → ff). Plus a round trip across all 256 byte values, which would catch any sign or masking regression in one assertion.

Bech32Util (7) — the existing test only proves malformed input is rejected; nothing proved valid input is accepted. These validate real mainnet stake addresses, pool ids and drep ids, and reject a deliberately corrupted checksum that still passes the charset check — the case that separates checksum verification from character validation.

Tuple (3) — values, nulls, mixed types.

BackendFactory (8) — every overload resolves to the expected base URL (https://api.koios.rest/api/v1/ and the guild/preview/preprod equivalents) rather than merely returning non-null, custom RPC honours the given URL, all ten services are wired, and the utility class cannot be instantiated.

Cost

All 29 run offline in under a second. No CI time, and nothing that can flake on a live Koios instance.

Note on the target

This does not chase 100%, deliberately. Lombok-generated code is already excluded by JaCoCo, and the remaining gap is mostly the seven System.getenv branches in the BaseService constructor — getenv is immutable in-process, so covering those needs either subprocesses per permutation or a seam added to production code purely for tests. Not worth it for the number.

🤖 Generated with Claude Code

Both were the thinnest packages in the codebase - utils at 57.8% line
coverage and factory at 56.2% - and HexUtil had no tests at all.

  HexUtil        11 tests: round trips, 0x prefix handling, odd-length and
                 non-hex rejection, negative bytes not sign-extending, and
                 a round trip across all 256 byte values
  Bech32Util      7 tests: the accepting side, which nothing covered. Real
                 mainnet stake addresses, pool ids and drep ids validate,
                 and a corrupted checksum that still passes the charset
                 check is rejected
  Tuple           3 tests
  BackendFactory  8 tests: every overload resolves to the expected base
                 URL, all ten services are wired, and the utility class
                 cannot be instantiated

Coverage on the same measurement basis:

  utils     57.8% -> 92.2%
  factory   56.2% -> 90.6%
  overall   76.9% -> 81.5% lines, 63.4% -> 70.6% branches

All 29 run offline in under a second, so they add nothing to CI time and
cannot flake on a live Koios instance.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@edridudi
edridudi merged commit 6d3ab01 into main Sep 12, 2026
3 checks passed
@edridudi
edridudi deleted the claude/utils-factory-tests branch September 12, 2026 23:40
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.67%. Comparing base (5a617dc) to head (e6922b5).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #213      +/-   ##
============================================
- Coverage     69.39%   68.67%   -0.72%     
- Complexity      246      248       +2     
============================================
  Files            37       37              
  Lines           941      961      +20     
  Branches         73       79       +6     
============================================
+ Hits            653      660       +7     
- Misses          249      256       +7     
- Partials         39       45       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

edridudi added a commit that referenced this pull request Sep 13, 2026
* Authenticate the Codecov upload

Uploads have been failing since 2026-09-12:

  429 - {"message":"Rate limit reached. Please upload with the Codecov
  repository upload token to resolve issue."}

Tokenless uploads from public repos are rate limited. codecov-action exits
0 on upload errors, so the job kept reporting success while Codecov's data
went stale - the badge has been showing coverage from two days and several
merges ago, including none of the work in #213 or #214.

Passes CODECOV_TOKEN, and sets fail_ci_if_error so a failed upload is
visible rather than silent. The silence is what let this go unnoticed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Upgrade codecov-action to v5 for the current token format

The v3 action bundles uploader 0.8.0, which only accepts the legacy 36
character UUID token and rejects today's 50 character tokens:

  Token found by environment variables with length 50 did not pass validation

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: dudiedri <dudi.edri@ox.security>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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