Skip to content

Commit ccef263

Browse files
committed
fix: rounding on failing unit test
1 parent 1f77062 commit ccef263

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/test/unit/DelegationUnit.t.sol

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7268,7 +7268,7 @@ contract DelegationManagerUnitTests_burningShares is DelegationManagerUnitTests
72687268
uint256 depositSharesToWithdraw1 = r.Uint256(1, depositAmount);
72697269
uint256 depositSharesToWithdraw2 = r.Uint256(1, depositAmount - depositSharesToWithdraw1);
72707270

7271-
uint64 newMagnitude = 5e17;
7271+
uint64 newMagnitude = 50e16;
72727272

72737273
// 2. Register the operator, set the staker deposits, and delegate the 2 stakers to them
72747274
_registerOperatorWithBaseDetails(operator);
@@ -7331,8 +7331,8 @@ contract DelegationManagerUnitTests_burningShares is DelegationManagerUnitTests
73317331
);
73327332
}
73337333

7334-
// 4. Queue withdrawal for staker and slash operator for 50% again
7335-
newMagnitude = newMagnitude/2;
7334+
// 4. Queue withdrawal for staker and slash operator for 60% again
7335+
newMagnitude = 25e16;
73367336
{
73377337
(
73387338
QueuedWithdrawalParams[] memory queuedWithdrawalParams,,
@@ -7343,8 +7343,6 @@ contract DelegationManagerUnitTests_burningShares is DelegationManagerUnitTests
73437343
depositSharesToWithdraw: depositSharesToWithdraw2
73447344
});
73457345

7346-
// actual withdrawn shares are half of the deposit shares because of first slashing
7347-
uint256 withdrawAmount2 = depositSharesToWithdraw2 / 2;
73487346

73497347
// 4.1 queue a withdrawal for the staker
73507348
cheats.prank(staker);
@@ -7353,7 +7351,7 @@ contract DelegationManagerUnitTests_burningShares is DelegationManagerUnitTests
73537351
uint256 queuedSlashableSharesBefore = delegationManager.getSlashableSharesInQueue(operator, strategyMock);
73547352

73557353
uint256 sharesToDecrease = operatorSharesBefore / 2;
7356-
uint256 sharesToBurn = sharesToDecrease + (withdrawAmount2 + depositSharesToWithdraw1/2)/2;
7354+
uint256 sharesToBurn = sharesToDecrease + (depositSharesToWithdraw1 + depositSharesToWithdraw2) / 4;
73577355

73587356
// 4.2 Burn shares
73597357
_setOperatorMagnitude(operator, strategyMock, newMagnitude);
@@ -7376,13 +7374,13 @@ contract DelegationManagerUnitTests_burningShares is DelegationManagerUnitTests
73767374
// 4.3 Assert slashable shares and operator shares
73777375
assertEq(
73787376
queuedSlashableSharesBefore,
7379-
withdrawAmount2 + depositSharesToWithdraw1/2,
7380-
"Slashable shares in queue before should be withdrawAmount1 / 2 + withdrawAmount2"
7377+
(depositSharesToWithdraw1 + depositSharesToWithdraw2)/2,
7378+
"Slashable shares in queue before should be both queued withdrawal amounts halved"
73817379
);
73827380
assertEq(
73837381
delegationManager.getSlashableSharesInQueue(operator, strategyMock),
7384-
(withdrawAmount2 + depositSharesToWithdraw1/2)/2,
7385-
"Slashable shares in queue should be (withdrawAmount2 + depositSharesToWithdraw1/2)/2 after slashing"
7382+
queuedSlashableSharesBefore / 2,
7383+
"Slashable shares in queue should be halved again after slashing"
73867384
);
73877385
assertEq(
73887386
delegationManager.operatorShares(operator, strategyMock),

0 commit comments

Comments
 (0)