Skip to content

test: cover protocolConstants service env parsing and cache#881

Merged
1nonlypiece merged 3 commits into
Commitlabs-Org:masterfrom
Anichris-koded:test/protocol-constants-service
Jun 27, 2026
Merged

test: cover protocolConstants service env parsing and cache#881
1nonlypiece merged 3 commits into
Commitlabs-Org:masterfrom
Anichris-koded:test/protocol-constants-service

Conversation

@Anichris-koded

Copy link
Copy Markdown
Contributor

Closes #761

Summary

Adds tests/lib/backend/protocolConstants.service.test.ts with 35 unit tests targeting the service directly (not through the route).

What's tested

  • Defaults – all fields (protocolVersion, network, fees, penalty tiers, commitment limits, cachedAt) when no env vars are set
  • Env overrides – every env var the service reads, including float parsing, ACTIVE_CONTRACT_VERSION fallback precedence, and COMMITLABS_PENALTY_TIERS_JSON (with auto-generated description)
  • Invalid env fallbacks – non-numeric values fall back to defaults; malformed/non-array/missing-field JSON tiers throw descriptive errors
  • Caching – same object reference on repeated calls; env changes after first call are ignored; invalidateProtocolConstantsCache() forces re-read and new cachedAt

Coverage

100% statements, branches, functions, and lines on src/lib/backend/services/protocolConstants.ts (requirement ≥ 95%).

@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Anichris-koded is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Anichris-koded 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! 🚀

Learn more about application limits

@1nonlypiece 1nonlypiece left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good, covering the protocolConstants env parsing closes a real gap. merged.

@1nonlypiece 1nonlypiece merged commit 6743fc3 into Commitlabs-Org:master Jun 27, 2026
0 of 2 checks passed
@1nonlypiece

Copy link
Copy Markdown
Contributor

good, covering the protocolConstants env parsing closes a real gap — landed locally since it touches a workflow file. merged.

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.

Add unit tests for the protocolConstants service env parsing and cache

2 participants