-
Notifications
You must be signed in to change notification settings - Fork 51
fix(SortitionModule): total stake update #2199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 2 commits
1006d82
a2b5d76
719ea3e
5799a3b
cb492fd
cae435e
8c256aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,6 +141,32 @@ contract KlerosCore_StakingTest is KlerosCore_TestBase { | |
| ); | ||
| } | ||
|
|
||
| function test_setStake_totalStaked() public { | ||
| // Increase | ||
| vm.prank(staker1); | ||
| core.setStake(GENERAL_COURT, 4000); | ||
| vm.prank(staker1); | ||
| core.setStake(GENERAL_COURT, 5001); | ||
| vm.prank(staker2); | ||
| core.setStake(GENERAL_COURT, 1000); | ||
| vm.prank(staker2); | ||
| core.setStake(GENERAL_COURT, 1500); | ||
|
|
||
| assertEq(sortitionModule.totalStaked(), 6501, "Wrong totalStaked"); | ||
|
|
||
| // Decrease | ||
| vm.prank(staker1); | ||
| core.setStake(GENERAL_COURT, 3000); | ||
| vm.prank(staker1); | ||
| core.setStake(GENERAL_COURT, 2500); | ||
| vm.prank(staker2); | ||
| core.setStake(GENERAL_COURT, 1400); | ||
| vm.prank(staker2); | ||
| core.setStake(GENERAL_COURT, 1200); | ||
|
|
||
| assertEq(sortitionModule.totalStaked(), 3700, "Wrong totalStaked"); | ||
| } | ||
|
Comment on lines
+144
to
+168
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# First, search for totalStaked references in the test file
rg -n "totalStaked" contracts/test/foundry/KlerosCore_Staking.t.sol -B2 -A2Repository: kleros/kleros-v2 Length of output: 7231 🏁 Script executed: #!/bin/bash
# Search for tests that combine delayed stakes with totalStaked checks
rg -n "delayedStake.*totalStaked|totalStaked.*delayedStake" contracts/test/foundry/ -iRepository: kleros/kleros-v2 Length of output: 42 🏁 Script executed: #!/bin/bash
# Search for all test functions that mention delayed stake
rg -n "function test.*[Dd]elayed" contracts/test/foundry/KlerosCore_Staking.t.solRepository: kleros/kleros-v2 Length of output: 182 🏁 Script executed: #!/bin/bash
# Check the entire context around delayed stake tests to see if totalStaked is tested
rg -n "test_delayedStake" contracts/test/foundry/KlerosCore_Staking.t.sol -A 50 | head -100Repository: kleros/kleros-v2 Length of output: 42 🏁 Script executed: #!/bin/bash
# Read the test_executeDelayedStakes function
sed -n '324,450p' contracts/test/foundry/KlerosCore_Staking.t.solRepository: kleros/kleros-v2 Length of output: 6960 🏁 Script executed: #!/bin/bash
# Find the SortitionModule contract file
fd -t f "SortitionModule\.sol" contracts/Repository: kleros/kleros-v2 Length of output: 163 🏁 Script executed: #!/bin/bash
# Search for the totalStaked function/variable definition
rg -n "totalStaked" contracts/src/ -B2 -A5 | head -100Repository: kleros/kleros-v2 Length of output: 7695 🏁 Script executed: #!/bin/bash
# Search for executeDelayedStakes implementation
rg -n "function executeDelayedStakes" contracts/src/ -A 30Repository: kleros/kleros-v2 Length of output: 9796 🏁 Script executed: #!/bin/bash
# Search for setStakeBySortitionModule in KlerosCore
rg -n "function setStakeBySortitionModule" contracts/src/ -A 15Repository: kleros/kleros-v2 Length of output: 3466 🏁 Script executed: #!/bin/bash
# Confirm _setStake calls the totalStaked update
rg -n "function _setStake" contracts/src/arbitration/KlerosCore.sol -A 40 | head -60Repository: kleros/kleros-v2 Length of output: 2059 Test coverage for delayed stakes affecting The verification confirms the review comment's concern is valid. While the current
A test case should verify that executing delayed stakes properly increments the global 🤖 Prompt for AI Agents |
||
|
|
||
| function test_setStake_maxStakePathCheck() public { | ||
| uint256[] memory supportedDK = new uint256[](1); | ||
| supportedDK[0] = DISPUTE_KIT_CLASSIC; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.