test: add update_rewards several blocks delegation rewards test#92
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
5b321b5 to
fec770a
Compare
366dcb1 to
f179d36
Compare
fec770a to
eb46cf8
Compare
noa-starkware
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @arad-starkware)
src/flow_test/test.cairo line 3872 at r1 (raw file):
/// Flow: /// Staker stake. /// Delegator delegate.
Add btc
f179d36 to
5103722
Compare
eb46cf8 to
feac4a7
Compare
feac4a7 to
7670413
Compare
5103722 to
016908f
Compare
| system.update_rewards(:staker, disable_rewards: false); | ||
| advance_blocks( | ||
| blocks: quarter_epoch_length, block_duration: AVG_BLOCK_DURATION * quarter_epoch_length, | ||
| ); |
There was a problem hiding this comment.
Bug: Wrong block_duration calculation causes squared time advancement
The advance_blocks function expects block_duration to be the duration per single block, then multiplies it internally by the blocks count. The test passes AVG_BLOCK_DURATION * quarter_epoch_length as block_duration, but since the function multiplies by quarter_epoch_length again, the time advancement is squared. Other usages in the codebase show the correct pattern: advance_blocks(blocks: 1, block_duration: AVG_BLOCK_DURATION). The block_duration argument should just be AVG_BLOCK_DURATION.

This change is
Note
Adds a flow test verifying staker/delegator rewards accumulate correctly when update_rewards is called multiple times within the same epoch.
update_rewards_delegator_rewards_same_epoch_flow_testinsrc/flow_test/test.cairo:update_rewards4 times within one epoch (separated by quarter-epoch block advances), and asserts staker/delegator rewards equal 4× single-block expectations.EpochInfoTrait(alongsideNormalizedAmountTrait).src/flow_test/flow_ideas.mdunderupdate_rewards.Written by Cursor Bugbot for commit 016908f. This will update automatically on new commits. Configure here.