Skip to content

Commit

Permalink
style: error message inconsistent input
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD committed Aug 9, 2023
1 parent 621a7e9 commit bf7b8fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Blue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ contract Blue is IBlue {
{
Id id = market.id();
require(lastUpdate[id] != 0, Errors.MARKET_NOT_CREATED);
require((shares == 0 && amount > 0) || (shares > 0 && amount == 0));
require((shares == 0 && amount > 0) || (shares > 0 && amount == 0), Errors.INCONSISTENT_INPUT);
require(onBehalf != address(0), Errors.ZERO_ADDRESS);

_accrueInterests(market, id);
Expand All @@ -170,7 +170,7 @@ contract Blue is IBlue {
{
Id id = market.id();
require(lastUpdate[id] != 0, Errors.MARKET_NOT_CREATED);
require((shares == 0 && amount > 0) || (shares > 0 && amount == 0));
require((shares == 0 && amount > 0) || (shares > 0 && amount == 0), Errors.INCONSISTENT_INPUT);
// No need to verify that onBehalf != address(0) thanks to the authorization check.
require(receiver != address(0), Errors.ZERO_ADDRESS);
require(_isSenderAuthorized(onBehalf), Errors.UNAUTHORIZED);
Expand Down Expand Up @@ -201,7 +201,7 @@ contract Blue is IBlue {
{
Id id = market.id();
require(lastUpdate[id] != 0, Errors.MARKET_NOT_CREATED);
require((shares == 0 && amount > 0) || (shares > 0 && amount == 0));
require((shares == 0 && amount > 0) || (shares > 0 && amount == 0), Errors.INCONSISTENT_INPUT);
// No need to verify that onBehalf != address(0) thanks to the authorization check.
require(receiver != address(0), Errors.ZERO_ADDRESS);
require(_isSenderAuthorized(onBehalf), Errors.UNAUTHORIZED);
Expand Down Expand Up @@ -231,7 +231,7 @@ contract Blue is IBlue {
{
Id id = market.id();
require(lastUpdate[id] != 0, Errors.MARKET_NOT_CREATED);
require((shares == 0 && amount > 0) || (shares > 0 && amount == 0));
require((shares == 0 && amount > 0) || (shares > 0 && amount == 0), Errors.INCONSISTENT_INPUT);
require(onBehalf != address(0), Errors.ZERO_ADDRESS);

_accrueInterests(market, id);
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ library Errors {

string internal constant ZERO_AMOUNT = "zero amount";

string internal constant ZERO_SHARES = "zero shares";
string internal constant INCONSISTENT_INPUT = "inconsistent input";

string internal constant ZERO_ADDRESS = "zero address";

Expand Down
18 changes: 9 additions & 9 deletions test/forge/Blue.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -712,24 +712,24 @@ contract BlueTest is
}

function testInputZero() public {
vm.expectRevert();
vm.expectRevert(bytes(Errors.INCONSISTENT_INPUT));
blue.supply(market, 0, 0, address(this), hex"");
vm.expectRevert();
vm.expectRevert(bytes(Errors.INCONSISTENT_INPUT));
blue.supply(market, 1, 1, address(this), hex"");

vm.expectRevert();
vm.expectRevert(bytes(Errors.INCONSISTENT_INPUT));
blue.withdraw(market, 0, 0, address(this), address(this));
vm.expectRevert();
vm.expectRevert(bytes(Errors.INCONSISTENT_INPUT));
blue.withdraw(market, 1, 1, address(this), address(this));

vm.expectRevert();
vm.expectRevert(bytes(Errors.INCONSISTENT_INPUT));
blue.borrow(market, 0, 0, address(this), address(this));
vm.expectRevert();
blue.borrow(market, 0, 1, address(this), address(this));
vm.expectRevert(bytes(Errors.INCONSISTENT_INPUT));
blue.borrow(market, 1, 1, address(this), address(this));

vm.expectRevert();
vm.expectRevert(bytes(Errors.INCONSISTENT_INPUT));
blue.repay(market, 0, 0, address(this), hex"");
vm.expectRevert();
vm.expectRevert(bytes(Errors.INCONSISTENT_INPUT));
blue.repay(market, 1, 1, address(this), hex"");

vm.expectRevert(bytes(Errors.ZERO_AMOUNT));
Expand Down

0 comments on commit bf7b8fb

Please sign in to comment.