From c341593b2e629ccb135871842d8d53141a93ff81 Mon Sep 17 00:00:00 2001 From: mmackz Date: Wed, 11 Sep 2024 22:09:21 -0700 Subject: [PATCH] test(QuestBudget): add test for reserved funds behavior --- test/QuestBudget.t.sol | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/QuestBudget.t.sol b/test/QuestBudget.t.sol index 74a6281a..3f6878d7 100644 --- a/test/QuestBudget.t.sol +++ b/test/QuestBudget.t.sol @@ -920,6 +920,27 @@ contract QuestBudgetTest is Test, TestUtils, IERC1155Receiver { assertEq(questBudget.available(address(otherMockERC20)), 0); } + function testAvailable_ReservedFunds() public { + // Mint some tokens to the questBudget + uint256 totalBalance = 100 ether; + mockERC20.mint(address(questBudget), totalBalance); + + // Set reserved funds equal to total balance + uint256 reservedFunds = totalBalance; + bytes32 reservedFundsSlot = bytes32(uint256(6)); // reservedFunds is at slot 6 + vm.store(address(questBudget), reservedFundsSlot, bytes32(reservedFunds)); + + uint256 availableBalance = questBudget.available(address(mockERC20)); + assertEq(availableBalance, 0, "Available balance should be 0 when reserved funds equal total balance"); + + // Set reserved funds greater than total balance + reservedFunds = totalBalance + 1 wei; + vm.store(address(questBudget), reservedFundsSlot, bytes32(reservedFunds)); + + availableBalance = questBudget.available(address(mockERC20)); + assertEq(availableBalance, 0, "Available balance should be 0 when reserved funds are > total balance"); + } + ////////////////////////////// // QuestBudget.distributed // //////////////////////////////