Skip to content

test: add toggle tokens before and after upgrade test#51

Merged
arad-starkware merged 1 commit intomainfrom
arad/test_add_toggle_tokens_before_and_after_upgrade_test
Nov 24, 2025
Merged

test: add toggle tokens before and after upgrade test#51
arad-starkware merged 1 commit intomainfrom
arad/test_add_toggle_tokens_before_and_after_upgrade_test

Conversation

@arad-starkware
Copy link
Collaborator

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

This change is Reviewable


Note

Adds a flow test that toggles BTC tokens around an upgrade and asserts token activation state across epochs, with a mainnet-fork test and docs update.

  • Flow tests:
    • Toggle tokens before/after upgrade: New flow ToggleTokensBeforeAfterUpgradeFlow in src/flow_test/flows.cairo to add two BTC tokens, toggle enable/disable around an upgrade, and verify dispatcher().get_tokens() across epochs.
    • Fork test: Adds toggle_tokens_before_after_upgrade_flow_test in src/flow_test/fork_test.cairo.
  • Docs:
    • Update src/flow_test/flow_ideas.md with the token A/B enable/disable + upgrade scenario.
  • Misc:
    • Import adjustments in flows.cairo (add Token and STRK_TOKEN_ADDRESS).

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

Copy link
Collaborator Author

arad-starkware commented Nov 23, 2025

@arad-starkware arad-starkware self-assigned this Nov 23, 2025
@arad-starkware arad-starkware marked this pull request as ready for review November 23, 2025 11:00
@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch from 692a1de to 95239a7 Compare November 23, 2025 11:03
@codecov
Copy link

codecov bot commented Nov 23, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
+ Coverage   95.43%   95.60%   +0.16%     
==========================================
  Files          45       45              
  Lines        9446     9783     +337     
==========================================
+ Hits         9015     9353     +338     
+ Misses        431      430       -1     

☔ 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 3 files reviewed, 6 unresolved discussions (waiting on @NirLevi-starkware)


src/flow_test/flows.cairo line 7067 at r1 (raw file):

}

/// Flow:

I think we should also test disable/enable in the same epoch of upgrade. then test same and next epoch after upgrade


src/flow_test/flows.cairo line 7070 at r1 (raw file):

/// Token A enabled, Token B disabled
/// Test tokens
/// Upgrade to V3

test here


src/flow_test/flows.cairo line 7092 at r1 (raw file):

        system.staking.enable_token(token_address: token_a.contract_address());
        let result = system.staking.safe_disable_token(token_address: token_b.contract_address());
        assert_panic_with_error(result, StakingError::TOKEN_ALREADY_DISABLED.describe());

I think these lines are unnecessary

Code quote:

        let result = system.staking.safe_disable_token(token_address: token_b.contract_address());
        assert_panic_with_error(result, StakingError::TOKEN_ALREADY_DISABLED.describe());

src/flow_test/flows.cairo line 7100 at r1 (raw file):

        ]
            .span();
        assert!(tokens == expected_tokens);

same, what are you trying to test here?

Code quote:

        let tokens = system.staking.dispatcher().get_tokens();
        let expected_tokens = array![
            (STRK_TOKEN_ADDRESS, true), (system.btc_token.contract_address(), true),
            (token_a.contract_address(), true), (token_b.contract_address(), false),
        ]
            .span();
        assert!(tokens == expected_tokens);

src/flow_test/flows.cairo line 7115 at r1 (raw file):

        ]
            .span();
        assert!(tokens == expected_tokens);

add test with rewards? WDYT?


src/flow_test/flows.cairo line 7135 at r1 (raw file):

        ]
            .span();
        assert!(tokens == expected_tokens);

Also here?

@arad-starkware arad-starkware changed the base branch from main to graphite-base/51 November 23, 2025 13:45
@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch from 95239a7 to c36a370 Compare November 23, 2025 13:45
@arad-starkware arad-starkware changed the base branch from graphite-base/51 to arad/chore_add_check_for_rpc_url November 23, 2025 13:45
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 3 files reviewed, 5 unresolved discussions (waiting on @NirLevi-starkware and @noa-starkware)


src/flow_test/flows.cairo line 7067 at r1 (raw file):

Previously, noa-starkware wrote…

I think we should also test disable/enable in the same epoch of upgrade. then test same and next epoch after upgrade

Done.


src/flow_test/flows.cairo line 7070 at r1 (raw file):

Previously, noa-starkware wrote…

test here

Done.


src/flow_test/flows.cairo line 7100 at r1 (raw file):

Previously, noa-starkware wrote…

same, what are you trying to test here?

nvm


src/flow_test/flows.cairo line 7115 at r1 (raw file):

Previously, noa-starkware wrote…

add test with rewards? WDYT?

There's a different flow (idea) that tests rewards, or do you mean specifically after upgrade?


src/flow_test/flows.cairo line 7135 at r1 (raw file):

Previously, noa-starkware wrote…

Also here?

see above

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 3 files reviewed, 3 unresolved discussions (waiting on @arad-starkware and @NirLevi-starkware)


src/flow_test/flows.cairo line 7115 at r1 (raw file):

Previously, arad-starkware wrote…

There's a different flow (idea) that tests rewards, or do you mean specifically after upgrade?

yes, lets add a test with one token disabled + one token enabled before upgrade, then test after upgrade view+rewards. Please add to flow ideas now and open a new pr for that later.


src/flow_test/flows.cairo line 7128 at r2 (raw file):

        system.staking.enable_token(token_address: token_b.contract_address());
        let tokens = system.staking.dispatcher().get_tokens();
        assert!(tokens == expected_tokens);

Suggestion:

        // Test same epoch.
        let tokens = system.staking.dispatcher().get_tokens();
        assert!(tokens == expected_tokens);

@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch from c36a370 to affafed Compare November 23, 2025 15:01
@arad-starkware arad-starkware force-pushed the arad/chore_add_check_for_rpc_url branch 2 times, most recently from af890b8 to f1a3f80 Compare November 23, 2025 15:23
@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch 2 times, most recently from 4a7e18c to bca5ae2 Compare November 23, 2025 15:29
@arad-starkware arad-starkware force-pushed the arad/chore_add_check_for_rpc_url branch from f1a3f80 to 149e559 Compare November 23, 2025 15:29
@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch 2 times, most recently from 1c79687 to d08a2c7 Compare November 23, 2025 15:56
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 3 files reviewed, 1 unresolved discussion (waiting on @NirLevi-starkware and @noa-starkware)


src/flow_test/flows.cairo line 7115 at r1 (raw file):

Previously, noa-starkware wrote…

yes, lets add a test with one token disabled + one token enabled before upgrade, then test after upgrade view+rewards. Please add to flow ideas now and open a new pr for that later.

Done.


src/flow_test/flows.cairo line 7128 at r2 (raw file):

        system.staking.enable_token(token_address: token_b.contract_address());
        let tokens = system.staking.dispatcher().get_tokens();
        assert!(tokens == expected_tokens);

Done

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 3 files reviewed, 1 unresolved discussion (waiting on @NirLevi-starkware)


src/flow_test/flow_ideas.md line 103 at r3 (raw file):

- same as above with disable (can be implemented together as one test)
- token A enabled, next epoch token B enabled, next epoch token A disabled, next epoch token B disabled
- enable token A and disable token B, upgrade (in the same epoch), views and rewards the next few epochs

Why? Thats what we implemented now. isnt it?

Code quote:

(in the same epoch)

@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch from d08a2c7 to c7d5511 Compare November 23, 2025 16:15
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 3 files reviewed, 1 unresolved discussion (waiting on @NirLevi-starkware and @noa-starkware)


src/flow_test/flow_ideas.md line 103 at r3 (raw file):

Previously, noa-starkware wrote…

Why? Thats what we implemented now. isnt it?

I thought you said you wanted to test with rewards, then I don't understand what the test it... just that after the upgrade the tokens are still in the same state?
Took me writing this comment to understand the connection between this test and what we talked about...

@arad-starkware arad-starkware changed the base branch from arad/chore_add_check_for_rpc_url to graphite-base/51 November 23, 2025 16:29
@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch from c7d5511 to dcb0558 Compare November 23, 2025 16:37
@arad-starkware arad-starkware changed the base branch from graphite-base/51 to arad/chore_add_check_for_rpc_url November 23, 2025 16:37
@arad-starkware arad-starkware force-pushed the arad/chore_add_check_for_rpc_url branch from 894eed0 to c44bef8 Compare November 23, 2025 16:38
@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch from dcb0558 to 6c99136 Compare November 23, 2025 16:38
@arad-starkware arad-starkware changed the base branch from arad/chore_add_check_for_rpc_url to graphite-base/51 November 23, 2025 16:48
@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch from 6c99136 to 5dbaf64 Compare November 23, 2025 16:49
@graphite-app graphite-app bot changed the base branch from graphite-base/51 to main November 23, 2025 16:49
@arad-starkware arad-starkware force-pushed the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch from 5dbaf64 to d8f66ad Compare November 23, 2025 16: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.

:lgtm:

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

Copy link
Collaborator Author

arad-starkware commented Nov 24, 2025

Merge activity

  • Nov 24, 8:02 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 24, 8:02 AM UTC: @arad-starkware merged this pull request with Graphite.

@arad-starkware arad-starkware merged commit 197c090 into main Nov 24, 2025
6 of 7 checks passed
@arad-starkware arad-starkware deleted the arad/test_add_toggle_tokens_before_and_after_upgrade_test branch November 24, 2025 08:02
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