Skip to content

Commit

Permalink
feat: tests (check total bond shares)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgorkavenko committed Dec 1, 2023
1 parent 24b8d52 commit 7803f8f
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions test/CSAccounting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2074,8 +2074,6 @@ abstract contract CSAccountingClaimRewardsBaseTest is
function test_WithDesirableValue() public virtual;

function test_RevertWhen_NotOwner() public virtual;

// todo: check total bond shares
}

contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
Expand Down Expand Up @@ -2107,6 +2105,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to before"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithCurve() public override {
Expand Down Expand Up @@ -2139,6 +2138,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithMultiplier() public override {
Expand Down Expand Up @@ -2171,6 +2171,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithBlocked() public override {
Expand Down Expand Up @@ -2208,6 +2209,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithCurveAndBlocked() public override {
Expand Down Expand Up @@ -2253,6 +2255,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to before"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithBond() public override {
Expand Down Expand Up @@ -2284,6 +2287,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithBondAndOneWithdrawnValidator() public override {
Expand Down Expand Up @@ -2316,6 +2320,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to before"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithExcessBond() public override {
Expand Down Expand Up @@ -2348,6 +2353,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithExcessBondAndOneWithdrawnValidator() public override {
Expand Down Expand Up @@ -2381,6 +2387,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithMissingBond() public override {
Expand Down Expand Up @@ -2412,6 +2419,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithMissingBondAndOneWithdrawnValidator() public override {
Expand Down Expand Up @@ -2443,6 +2451,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after claim should be equal to after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_EventEmitted() public override {
Expand Down Expand Up @@ -2495,6 +2504,7 @@ contract CSAccountingClaimStETHRewardsTest is CSAccountingClaimRewardsBaseTest {
bondSharesAfter,
"bond manager after should be equal to before and fee minus claimed shares"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_RevertWhen_NotOwner() public override {
Expand Down Expand Up @@ -2549,6 +2559,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithCurve() public override {
Expand Down Expand Up @@ -2587,6 +2598,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithMultiplier() public override {
Expand Down Expand Up @@ -2625,6 +2637,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithBlocked() public override {
Expand Down Expand Up @@ -2668,6 +2681,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithCurveAndBlocked() public override {
Expand Down Expand Up @@ -2719,6 +2733,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithBond() public override {
Expand Down Expand Up @@ -2757,6 +2772,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithBondAndOneWithdrawnValidator() public override {
Expand Down Expand Up @@ -2796,6 +2812,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithExcessBond() public override {
Expand Down Expand Up @@ -2835,6 +2852,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithExcessBondAndOneWithdrawnValidator() public override {
Expand Down Expand Up @@ -2874,6 +2892,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithMissingBond() public override {
Expand Down Expand Up @@ -2910,6 +2929,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithMissingBondAndOneWithdrawnValidator() public override {
Expand Down Expand Up @@ -2946,6 +2966,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after claim should be equal to bond shares after"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_EventEmitted() public override {
Expand Down Expand Up @@ -3003,6 +3024,7 @@ contract CSAccountingClaimWstETHRewardsTest is
bondSharesAfter,
"bond manager after should be equal to before and fee minus claimed shares"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_RevertWhen_NotOwner() public override {
Expand Down Expand Up @@ -3047,6 +3069,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithCurve() public override {
Expand Down Expand Up @@ -3077,6 +3100,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithMultiplier() public override {
Expand Down Expand Up @@ -3105,6 +3129,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares and excess"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithBlocked() public override {
Expand Down Expand Up @@ -3140,6 +3165,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares and excess"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithCurveAndBlocked() public override {
Expand Down Expand Up @@ -3184,6 +3210,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares and excess"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithBond() public override {
Expand Down Expand Up @@ -3214,6 +3241,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithBondAndOneWithdrawnValidator() public override {
Expand Down Expand Up @@ -3246,6 +3274,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares and excess"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithExcessBond() public override {
Expand Down Expand Up @@ -3278,6 +3307,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares and excess"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithExcessBondAndOneWithdrawnValidator() public override {
Expand Down Expand Up @@ -3310,6 +3340,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares and excess"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithMissingBond() public override {
Expand Down Expand Up @@ -3340,6 +3371,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_WithMissingBondAndOneWithdrawnValidator() public override {
Expand Down Expand Up @@ -3370,6 +3402,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_EventEmitted() public override {
Expand Down Expand Up @@ -3432,6 +3465,7 @@ contract CSAccountingRequestRewardsETHRewardsTest is
"shares of withdrawal queue should be equal to requested shares"
);
assertEq(stETH.sharesOf(address(user)), 0, "user shares should be 0");
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_RevertWhen_NotOwner() public override {
Expand Down Expand Up @@ -3480,6 +3514,7 @@ contract CSAccountingDepositsTest is CSAccountingBaseTest {
sharesToDeposit,
"bond manager shares should be equal to deposited shares"
);
assertEq(accounting.totalBondShares(), sharesToDeposit);
}

function test_depositStETH() public {
Expand Down Expand Up @@ -3510,6 +3545,7 @@ contract CSAccountingDepositsTest is CSAccountingBaseTest {
sharesToDeposit,
"bond manager shares should be equal to deposited shares"
);
assertEq(accounting.totalBondShares(), sharesToDeposit);
}

function test_depositWstETH() public {
Expand Down Expand Up @@ -3543,6 +3579,7 @@ contract CSAccountingDepositsTest is CSAccountingBaseTest {
sharesToDeposit,
"bond manager shares should be equal to deposited shares"
);
assertEq(accounting.totalBondShares(), sharesToDeposit);
}

function test_depositStETHWithPermit() public {
Expand Down Expand Up @@ -3587,6 +3624,7 @@ contract CSAccountingDepositsTest is CSAccountingBaseTest {
sharesToDeposit,
"bond manager shares should be equal to deposited shares"
);
assertEq(accounting.totalBondShares(), sharesToDeposit);
}

function test_depositStETHWithPermit_AlreadyPermitted() public {
Expand Down Expand Up @@ -3676,6 +3714,7 @@ contract CSAccountingDepositsTest is CSAccountingBaseTest {
sharesToDeposit,
"bond manager shares should be equal to deposited shares"
);
assertEq(accounting.totalBondShares(), sharesToDeposit);
}

function test_depositWstETHWithPermit_AlreadyPermitted() public {
Expand Down Expand Up @@ -3814,22 +3853,24 @@ contract CSAccountingPenalizeTest is CSAccountingBaseTest {
uint256 bondSharesBefore = accounting.getBondShares(0);
vm.prank(admin);
accounting.penalize(0, 1 ether);
uint256 bondSharesAfter = accounting.getBondShares(0);

assertEq(
accounting.getBondShares(0),
bondSharesAfter,
bondSharesBefore - shares,
"bond shares should be decreased by penalty"
);
assertEq(
stETH.sharesOf(address(accounting)),
bondSharesBefore - shares,
bondSharesAfter,
"bond manager shares should be decreased by penalty"
);
assertEq(
stETH.sharesOf(address(burner)),
shares,
"burner shares should be equal to penalty"
);
assertEq(accounting.totalBondShares(), bondSharesAfter);
}

function test_penalize_MoreThanDeposit() public {
Expand Down Expand Up @@ -3860,6 +3901,7 @@ contract CSAccountingPenalizeTest is CSAccountingBaseTest {
bondSharesBefore,
"burner shares should be equal to bond shares"
);
assertEq(accounting.totalBondShares(), 0);
}

function test_penalize_EqualToDeposit() public {
Expand All @@ -3886,6 +3928,7 @@ contract CSAccountingPenalizeTest is CSAccountingBaseTest {
shares,
"burner shares should be equal to penalty"
);
assertEq(accounting.totalBondShares(), 0);
}

function test_penalize_RevertWhenCallerHasNoRole() public {
Expand Down

0 comments on commit 7803f8f

Please sign in to comment.