Skip to content

Commit 00f2161

Browse files
committed
wip
Signed-off-by: chrismaree <christopher.maree@gmail.com>
1 parent 3ee5280 commit 00f2161

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/HoneyPot.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ contract HoneyPot is Ownable {
3030

3131
function createHoneyPot() external payable {
3232
require(honeyPots[msg.sender].liquidationPrice == 0, "Liquidation price already set for this user");
33+
require(msg.value > 0, "No value sent");
3334

3435
(, int256 currentPrice,,,) = oracle.latestRoundData();
3536

@@ -55,6 +56,7 @@ contract HoneyPot is Ownable {
5556
HoneyPotDetails storage userPot = honeyPots[honeyPotCreator];
5657

5758
require(currentPrice != userPot.liquidationPrice, "Liquidation price reached for this user");
59+
require(userPot.balance > 0, "No balance to withdraw");
5860

5961
_emptyPotForUser(honeyPotCreator, msg.sender);
6062
emit HoneyPotEmptied(honeyPotCreator, msg.sender, userPot.balance);

test/HoneyPot.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,19 @@ contract HoneyPotTest is CommonTest {
171171

172172
assertTrue(liquidatorBalanceAfter == liquidatorBalanceBefore + honeyPotBalance);
173173
}
174+
175+
function testCreateHoneyPotWithNoValue() public {
176+
vm.expectRevert("No value sent");
177+
honeyPot.createHoneyPot{value: 0}();
178+
}
179+
180+
function testEmptyHoneyPotWithZeroBalance() public {
181+
// Assuming honeyPot has been created before
182+
// Reset HoneyPot for the caller to ensure balance is 0
183+
honeyPot.resetPot();
184+
185+
vm.prank(liquidator);
186+
vm.expectRevert("No balance to withdraw");
187+
honeyPot.emptyHoneyPot(address(this));
188+
}
174189
}

0 commit comments

Comments
 (0)