Skip to content

Add comprehensive test coverage for boost/stake system #22

Description

@prodbycorne

Overview

The boost/stake system (stake, unstake, set_boost, set_global_multiplier, get_credits) is undertested. The core invariant — that credits earned under the old boost config are preserved when the boost changes — is not verified.

Missing Test Cases

compute_total_stake (unit test the private fn via public interface)

  • No boost (allocation_pct = 0): total_stake == amount
  • 50% allocation, multiplier 2: total_stake == amount * 1.5
  • 100% allocation, multiplier 3: total_stake == amount * 3
  • 100% allocation, multiplier 1: total_stake == amount (no gain)

set_boost

  • allocation_pct = 0 rejected
  • allocation_pct = 101 rejected
  • Changing boost checkpoints credits earned at old rate (no credit loss)
  • boost_applied event emitted with (user, allocation_pct, multiplier)

set_global_multiplier

  • Non-admin rejected
  • multiplier = 0 rejected
  • Changing multiplier does not retroactively alter already-banked credits
  • mult_set event emitted

get_credits

  • Returns 0 for unstaked user
  • Increases monotonically with ledger advancement
  • Boost increases credits relative to unboosted at same amount

Credit preservation across boost changes

  • Stake 1000 → advance 500 ledgers → set_boost 50% → advance 500 ledgers
    → credits = (unboosted * 500) + (boosted * 500)
    (NOT retroactively recalculated for first 500 ledgers)

Acceptance Criteria

  • All cases above have passing tests
  • compute_credits arithmetic verified with exact expected values
  • get_credits vs calculate_credits distinction documented in test comments
  • Full stake/unstake round-trip tested with token balance assertions

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaignfarming-poolFarmingPool contracttestingTests and test coverage

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions