From 897a08585c35ce2953329025dbec5a970b98f570 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Mon, 14 Oct 2024 03:49:49 +0000 Subject: [PATCH] refactor: update error message --- src/core/CombinedFaucet.sol | 5 ++++- test/foundry/unit/CombinedFaucet.t.sol | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/CombinedFaucet.sol b/src/core/CombinedFaucet.sol index 10ee59f3..18838d0f 100644 --- a/src/core/CombinedFaucet.sol +++ b/src/core/CombinedFaucet.sol @@ -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)) { diff --git a/test/foundry/unit/CombinedFaucet.t.sol b/test/foundry/unit/CombinedFaucet.t.sol index 358893d6..80c3ea62 100644 --- a/test/foundry/unit/CombinedFaucet.t.sol +++ b/test/foundry/unit/CombinedFaucet.t.sol @@ -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(); } @@ -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(); @@ -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); } @@ -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);