Skip to content

Add tests for top-movers computation edge cases: new assets, zero-supply #38

Description

@christabel888

Context: Edge cases the ranking computation needs to not crash or misrank on.

Where:

  • tests/ -- new test file or extend an existing analytics test file

What to do:

  • Test a newly-created asset (no 24h-ago baseline to diff against -- shouldn't divide by zero or show a nonsensical infinite percent gain).
  • Test a zero-supply/zero-holder asset.

Suggested approach:

  1. Write a test seeding a brand-new asset (created today, no 24h-ago snapshot) through Add /api/v1/rankings/top-movers endpoint: 24h percent change by holders/volume #33's ranking computation and assert it doesn't crash, divide by zero, or show an infinite/NaN percent change.
  2. Write a second test for a zero-supply or zero-holder asset and assert the same.
  3. Decide explicitly what these edge cases should display (e.g. "new" badge instead of a percentage) and assert on that specific output, not just "doesn't crash."

Watch out for:

  • These are exactly the inputs a public, gameable endpoint attracts (someone could create a zero-supply asset specifically to see what breaks) -- treat this as a correctness issue, not just a nice-to-have test.

Definition of done:

  • Both edge cases have explicit test coverage and don't panic or return garbage values

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions