Skip to content

Conversation

@noa-starkware
Copy link
Collaborator

@noa-starkware noa-starkware commented Nov 20, 2025

Note

Add new delegator V0/cross-version flow tests and hook them into mainnet fork tests; minor test utils import tweak and flow ideas note update.

  • Flow tests (src/flow_test/flows.cairo):
    • Add DelegatorChangeBalanceOverVersionsFlow (V0→V1→V3 with balance changes, reward checks).
    • Add DelegatorFromV0Flow (V0 entry, rewards across V1/V3, mid-V3 balance change).
    • Add DelegatorV0ChangeBalanceBeforeRewardsFlow (V0 entry, V3 balance change prior to rewards).
    • Import adjustment: include calculate_strk_pool_rewards_v1 alongside existing V2 helpers.
  • Fork tests (src/flow_test/fork_test.cairo):
    • Register new tests: delegator_change_balance_over_versions_flow_test, delegator_from_v0_flow_test, delegator_v0_change_balance_before_rewards_flow_test.
  • Docs (src/flow_test/flow_ideas.md):
    • Update “find sigma” section to note coverage for member from V0.

Written by Cursor Bugbot for commit 0cbc327. This will update automatically on new commits. Configure here.


This change is Reviewable

staker_address: staker.staker.address,
staking_contract: system.staking.address,
minting_curve_contract: system.minting_curve.address,
);
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect V2 reward calculation in V3 flow

The test calculates expected V3 rewards using calculate_strk_pool_rewards_v2 (epoch-based) instead of calculate_strk_pool_rewards_v3 (block-based). This mismatch in rounding logic causes assert_eq! failures against actual V3 contract behavior.

Fix in Cursor Fix in Web

staker_address: staker.staker.address,
staking_contract: system.staking.address,
minting_curve_contract: system.minting_curve.address,
);
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect V2 reward calculation in V3 flow

The test uses calculate_strk_pool_rewards_v2 (epoch-based) to calculate expected rewards for a V3 period (block-based), instead of calculate_strk_pool_rewards_v3. This occurs in the second reward update of the DelegatorFromV0Flow test and will lead to incorrect expected values.

Fix in Cursor Fix in Web

Base automatically changed from noa/staking/v3/test/test-utils-rewards to main November 23, 2025 11:20
@noa-starkware noa-starkware force-pushed the noa/staking/v3/test/delegator-v0 branch from 4e31646 to 9b801e3 Compare November 23, 2025 14:48

let expected_rewards = self.expected_rewards.unwrap() + expected_rewards_v1;
self.expected_rewards = Option::Some(expected_rewards);
}
Copy link

Choose a reason for hiding this comment

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

Bug: Missing setup method for version 2

The DelegatorFromV0Flow comment indicates attestations should occur in V2 ("Attest in V2 (pool gets rewards)"), but the implementation lacks a setup_v2 method. When test_flow_mainnet executes this flow, it upgrades through V0→V1→V2→V3, calling setup, setup_v1, setup_v2, then test. Without setup_v2, no operations occur in V2, causing the flow to skip V2 attestations and pool rewards entirely, making the test incomplete and rewards calculations incorrect.

Fix in Cursor Fix in Web

@noa-starkware noa-starkware force-pushed the noa/staking/v3/test/delegator-v0 branch from 9b801e3 to 0cbc327 Compare November 23, 2025 14:56
@codecov
Copy link

codecov bot commented Nov 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.54%. Comparing base (a28d60e) to head (0cbc327).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #45      +/-   ##
==========================================
+ Coverage   95.43%   95.54%   +0.10%     
==========================================
  Files          45       45              
  Lines        9446     9674     +228     
==========================================
+ Hits         9015     9243     +228     
  Misses        431      431              

☔ View full report in Codecov by Sentry.
📢 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.

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.

2 participants