Skip to content

test: add for v2 apr endpoint#477

Open
necipsagiro wants to merge 3 commits intomainfrom
test-v2-apr-endpoint
Open

test: add for v2 apr endpoint#477
necipsagiro wants to merge 3 commits intomainfrom
test-v2-apr-endpoint

Conversation

@necipsagiro
Copy link
Copy Markdown
Contributor

@necipsagiro necipsagiro commented Dec 16, 2025

Adds unit and e2e tests for the /v2/apr endpoint and APR calculation functions

resolves: #420

@necipsagiro necipsagiro linked an issue Dec 16, 2025 that may be closed by this pull request
@necipsagiro necipsagiro marked this pull request as ready for review December 16, 2025 13:38
Copilot AI review requested due to automatic review settings December 16, 2025 13:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive test coverage for the new /v2/apr endpoint, which calculates personalized staking APR based on a user's BTC and BABY stake amounts. The changes include both e2e tests for the HTTP endpoint and unit tests for the APR calculation logic.

  • E2E tests validate endpoint parameter validation and error handling
  • Unit tests verify APR calculation functions handle edge cases correctly
  • Tests follow established patterns in the codebase for consistency

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/api/v2_test.go Adds e2e tests for /v2/apr endpoint covering parameter validation (invalid types, negative values) and expected service errors when BBN client is unavailable
internal/v2/service/stats_test.go Adds unit tests for calculateUserCoStakingAPR and calculateBoostCoStakingAPR functions, testing zero value edge cases and correct calculation with valid inputs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@necipsagiro necipsagiro requested a review from kirugan December 16, 2025 22:36
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.

Cover /v2/apr endpoint with tests

4 participants