Skip to content

test: add get stakers delegation undelegation flow#30

Merged
arad-starkware merged 1 commit intomainfrom
arad/test_add_get_stakers_delegation_undelegation_flow
Nov 20, 2025
Merged

test: add get stakers delegation undelegation flow#30
arad-starkware merged 1 commit intomainfrom
arad/test_add_get_stakers_delegation_undelegation_flow

Conversation

@arad-starkware
Copy link
Collaborator

@arad-starkware arad-starkware commented Nov 19, 2025

This change is Reviewable


Note

Add a new end-to-end test validating get_stakers across delegation and undelegation intents/actions over epochs, and prune one obsolete idea from flow_ideas.

  • Tests:
    • Add get_stakers_delegation_undelegation_flow_test in workspace/apps/staking/contracts/src/flow_test/test.cairo:
      • Stakes two stakers, delegates STRK, then performs partial and full undelegation (intent/action).
      • Asserts get_stakers weights at current and subsequent K-epochs, verifying staking-power redistribution via mul_wide_and_div and STRK_WEIGHT_FACTOR.
  • Docs:
    • Remove - Undelegate, get stakers. from flow_test/flow_ideas.md.

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

@arad-starkware arad-starkware self-assigned this Nov 19, 2025
@arad-starkware arad-starkware marked this pull request as ready for review November 19, 2025 11:47
@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from 49148e3 to 6a1d9d3 Compare November 19, 2025 11:48
@arad-starkware arad-starkware force-pushed the arad/add_get_stakers_btc_and_strk_delegations_flow branch from 53c0237 to 357c939 Compare November 19, 2025 11:48
@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from 6a1d9d3 to ee75727 Compare November 19, 2025 11:49
@arad-starkware arad-starkware force-pushed the arad/add_get_stakers_btc_and_strk_delegations_flow branch from 357c939 to 00bbd36 Compare November 19, 2025 12:35
@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from ee75727 to ef727cc Compare November 19, 2025 12:36
@arad-starkware arad-starkware force-pushed the arad/add_get_stakers_btc_and_strk_delegations_flow branch 2 times, most recently from f3f562a to 83822a4 Compare November 19, 2025 12:41
@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from ef727cc to daaced7 Compare November 19, 2025 12:41
@arad-starkware arad-starkware force-pushed the arad/add_get_stakers_btc_and_strk_delegations_flow branch 2 times, most recently from 767967b to 7f4eda4 Compare November 19, 2025 12:44
@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch 2 times, most recently from 5df2adb to 544506f Compare November 19, 2025 12:49
@arad-starkware arad-starkware force-pushed the arad/add_get_stakers_btc_and_strk_delegations_flow branch from 7f4eda4 to 59470a4 Compare November 19, 2025 12:49
Copy link
Collaborator

@noa-starkware noa-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @arad-starkware)


workspace/apps/staking/contracts/src/flow_test/test.cairo line 2138 at r2 (raw file):

        (staker_1.staker.address, STRK_WEIGHT_FACTOR / 2, Option::None),
        (staker_2.staker.address, STRK_WEIGHT_FACTOR / 2, Option::None),
    ]

same as above

Code quote:

    let expected_stakers = array![
        (staker_1.staker.address, STRK_WEIGHT_FACTOR / 2, Option::None),
        (staker_2.staker.address, STRK_WEIGHT_FACTOR / 2, Option::None),
    ]

@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from 544506f to 5569d00 Compare November 19, 2025 13:41
Copy link
Collaborator Author

@arad-starkware arad-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, all discussions resolved (waiting on @arad-starkware)


workspace/apps/staking/contracts/src/flow_test/test.cairo line 2138 at r2 (raw file):

Previously, noa-starkware wrote…

same as above

Done

@arad-starkware arad-starkware changed the base branch from arad/add_get_stakers_btc_and_strk_delegations_flow to graphite-base/30 November 19, 2025 14:25
@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from 5569d00 to d3893e2 Compare November 19, 2025 14:25
@graphite-app graphite-app bot changed the base branch from graphite-base/30 to main November 19, 2025 14:26
@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from d3893e2 to 6165b21 Compare November 19, 2025 14:26
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #30      +/-   ##
==========================================
+ Coverage   95.43%   95.46%   +0.03%     
==========================================
  Files          45       45              
  Lines        9446     9510      +64     
==========================================
+ Hits         9015     9079      +64     
  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.

Copy link
Collaborator

@noa-starkware noa-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @arad-starkware)


workspace/apps/staking/contracts/src/flow_test/test.cairo line 2157 at r3 (raw file):

    assert!(stakers == expected_stakers);

    // Undelegate

Maybe test partial intent?

@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from 6165b21 to a9d619f Compare November 20, 2025 08:15
@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch 2 times, most recently from 53d30f3 to 1542855 Compare November 20, 2025 08:20
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Missing exit wait window before delegator exit action

The test calls delegator_exit_action without advancing time by the exit wait window after delegator_exit_intent. The exit_delegation_pool_action function requires that sufficient time has passed (the exit wait window) since the intent, but the test only calls advance_k_epochs which advances K epochs. The exit wait window is typically longer than K epochs, so this call will fail with INTENT_WINDOW_NOT_FINISHED error. Other tests in the codebase consistently call advance_time(time: system.staking.get_exit_wait_window()) between intent and action calls.

workspace/apps/staking/contracts/src/flow_test/test.cairo#L2201-L2202

// Undelegate action
system.advance_exit_wait_window();

Fix in Cursor Fix in Web


@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from 1542855 to 14bd004 Compare November 20, 2025 08:28
Copy link
Collaborator Author

@arad-starkware arad-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, all discussions resolved


workspace/apps/staking/contracts/src/flow_test/test.cairo line 2157 at r3 (raw file):

Previously, noa-starkware wrote…

Maybe test partial intent?

Done

@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from 14bd004 to 317aefb Compare November 20, 2025 09:40
@arad-starkware arad-starkware force-pushed the arad/test_add_get_stakers_delegation_undelegation_flow branch from 317aefb to c460717 Compare November 20, 2025 09:50
Copy link
Collaborator

@noa-starkware noa-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @arad-starkware)


workspace/apps/staking/contracts/src/flow_test/test.cairo line 2116 at r5 (raw file):

    let mut system = SystemConfigTrait::basic_stake_flow_cfg(:cfg).deploy();
    let stake_amount = system.staking.get_min_stake();
    let strk_delegation_amount = STRK_CONFIG.min_for_rewards * 3;

why?

Code quote:

* 3

Copy link
Collaborator

@noa-starkware noa-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @arad-starkware)

@arad-starkware arad-starkware merged commit d17c1e1 into main Nov 20, 2025
6 of 7 checks passed
Copy link
Collaborator Author

Merge activity

@arad-starkware arad-starkware deleted the arad/test_add_get_stakers_delegation_undelegation_flow branch November 20, 2025 11:01
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