@@ -140,4 +140,46 @@ contract HorizonStakingSlashTest is HorizonStakingTest {
140140 vm.startPrank (subgraphDataServiceAddress);
141141 _slash (users.indexer, subgraphDataServiceAddress, tokens + delegationTokens, 0 );
142142 }
143+
144+ function testSlash_RoundDown_TokensThawing_Provision () public useIndexer {
145+ uint256 tokens = 1 ether + 1 ;
146+ _useProvision (subgraphDataServiceAddress, tokens, MAX_PPM, MAX_THAWING_PERIOD);
147+
148+ _thaw (users.indexer, subgraphDataServiceAddress, tokens);
149+
150+ resetPrank (subgraphDataServiceAddress);
151+ _slash (users.indexer, subgraphDataServiceAddress, 1 , 0 );
152+
153+ resetPrank (users.indexer);
154+ Provision memory provision = staking.getProvision (users.indexer, subgraphDataServiceAddress);
155+ assertEq (provision.tokens, tokens - 1 );
156+ // Tokens thawing should be rounded down
157+ assertEq (provision.tokensThawing, tokens - 2 );
158+ }
159+
160+ function testSlash_RoundDown_TokensThawing_Delegation (
161+ uint256 tokens
162+ ) public useIndexer useProvision (tokens, MAX_PPM, 0 ) useDelegationSlashing {
163+ resetPrank (users.delegator);
164+ uint256 delegationTokens = 1 ether + 1 ;
165+ _delegate (users.indexer, subgraphDataServiceAddress, delegationTokens, 0 );
166+
167+ DelegationInternal memory delegation = _getStorage_Delegation (
168+ users.indexer,
169+ subgraphDataServiceAddress,
170+ users.delegator,
171+ false
172+ );
173+ _undelegate (users.indexer, subgraphDataServiceAddress, delegation.shares);
174+
175+ resetPrank (subgraphDataServiceAddress);
176+ // Slash 1 token from delegation
177+ _slash (users.indexer, subgraphDataServiceAddress, tokens + 1 , 0 );
178+
179+ resetPrank (users.delegator);
180+ DelegationPool memory pool = staking.getDelegationPool (users.indexer, subgraphDataServiceAddress);
181+ assertEq (pool.tokens, delegationTokens - 1 );
182+ // Tokens thawing should be rounded down
183+ assertEq (pool.tokensThawing, delegationTokens - 2 );
184+ }
143185}
0 commit comments