Skip to content

Commit

Permalink
refactor: update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed Oct 14, 2024
1 parent a1c6aa7 commit 897a085
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/core/CombinedFaucet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ contract CombinedFaucet is

function _withdraw(address dst) internal {
if (lastRequestTime[dst] != 0) {
require(block.timestamp >= lastRequestTime[dst] + ONE_DAY, "CombinedFaucet: 24h rate limit breached");
require(
block.timestamp >= lastRequestTime[dst] + ONE_DAY,
"CombinedFaucet: Rate limit exceeded. Please wait 24 hours."
);
}
lastRequestTime[dst] = block.timestamp;
if (token != address(0)) {
Expand Down
12 changes: 6 additions & 6 deletions test/foundry/unit/CombinedFaucet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract ERC20FaucetTest is BaseFaucetTest {
assertEq(token.balanceOf(address(faucet)), tokenAmount * 4);

// Ensure 24h rate limit is enforced
vm.expectRevert("CombinedFaucet: 24h rate limit breached");
vm.expectRevert("CombinedFaucet: Rate limit exceeded. Please wait 24 hours.");
vm.prank(user1);
faucet.requestTokens();
}
Expand All @@ -84,7 +84,7 @@ contract ERC20FaucetTest is BaseFaucetTest {
faucet.requestTokens();

// Try again before 24 hours have passed
vm.expectRevert("CombinedFaucet: 24h rate limit breached");
vm.expectRevert("CombinedFaucet: Rate limit exceeded. Please wait 24 hours.");
vm.prank(user1);
faucet.requestTokens();

Expand Down Expand Up @@ -200,7 +200,7 @@ contract NativeTokenFaucetTest is BaseFaucetTest {
assertEq(address(faucet).balance, tokenAmount * 4);

// Ensure 24h rate limit is enforced
vm.expectRevert("CombinedFaucet: 24h rate limit breached");
vm.expectRevert("CombinedFaucet: Rate limit exceeded. Please wait 24 hours.");
vm.prank(owner);
faucet.withdraw(user1);
}
Expand Down Expand Up @@ -230,14 +230,14 @@ contract NativeTokenFaucetTest is BaseFaucetTest {
faucet.withdraw(user1);

// Try again before 24 hours have passed
vm.expectRevert("CombinedFaucet: 24h rate limit breached");
vm.expectRevert("CombinedFaucet: Rate limit exceeded. Please wait 24 hours.");
vm.prank(owner);
faucet.withdraw(user1);

// // Fast forward time by 24 hours
// Fast forward time by 24 hours
vm.warp(block.timestamp + 1 days);

// // Should work now
// Should work now
vm.prank(owner);
faucet.withdraw(user1);
assertEq(user1.balance, tokenAmount * 2);
Expand Down

0 comments on commit 897a085

Please sign in to comment.