From b586b07c246371918e8782fdd855c820b52cdd6b Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Mon, 11 May 2026 16:06:22 +0300 Subject: [PATCH] test added; is it possible to breakout for each participant from bond depository if warmup is changed Signed-off-by: Uncle Fatso --- test/bonding/BondDepositorty.t.sol | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/bonding/BondDepositorty.t.sol b/test/bonding/BondDepositorty.t.sol index 0f9deff..8f0e6aa 100644 --- a/test/bonding/BondDepositorty.t.sol +++ b/test/bonding/BondDepositorty.t.sol @@ -493,4 +493,53 @@ contract GhostBondDepositoryTest is Test { assertEq(ALICE.balance, amount); assertEq(IERC20(address(weth)).balanceOf(address(treasury)), 0); } + + function test_forceRedeemWorksBasedOnTheBalanceRemidner() public { + uint256 aliceAmount = _createNativeBond(); + uint256 aliceAmountUsed = aliceAmount / 8; + assertEq(ALICE.balance, aliceAmount); + + uint256 i; + for (; i < 8; ) { + vm.prank(ALICE); + depository.deposit{value: aliceAmountUsed}(1, aliceAmountUsed, type(uint256).max, ALICE, ALICE); + unchecked { ++i; } + } + + vm.startPrank(GOVERNOR); + Gatekeeper gatekeeper = new Gatekeeper(address(staking), 0, 0, 0, 0, 0); + staking.setGatekeeperAddress(address(gatekeeper)); + staking.setWarmupPeriod(10); + vm.stopPrank(); + + uint256 bobAmount = aliceAmount / 2; + uint256 bobAmountUsed = bobAmount / 8; + + vm.deal(BOB, bobAmount); + assertEq(BOB.balance, bobAmount); + + i = 0; + for (; i < 7; ) { + vm.prank(BOB); + depository.deposit{value: bobAmountUsed}(1, bobAmountUsed, type(uint256).max, BOB, BOB); + unchecked { ++i; } + } + + skip(DEPOSIT_INTERVAL); + + (, uint256 payout,, bool matured) = staking.warmupInfo(address(depository)); + assertEq(ghst.balanceOf(address(depository)) > 0, true); + assertEq(payout > 0, true); + assertEq(matured, true); + + vm.prank(BOB); + depository.forceRedeemAll(bytes32(0)); + + vm.prank(ALICE); + depository.forceRedeemAll(bytes32(0)); + + (, payout,,) = staking.warmupInfo(address(depository)); + assertEq(ghst.balanceOf(address(depository)), 0); + assertEq(payout, 0); + } }