Skip to content

Commit

Permalink
test(QuestBudget): add test for reserved funds behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
mmackz committed Sep 12, 2024
1 parent 94c82ec commit c341593
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/QuestBudget.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
//////////////////////////////
Expand Down

0 comments on commit c341593

Please sign in to comment.