Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(RNSCommission): allow send 0 #286

Open
wants to merge 9 commits into
base: feature/bulk-renew
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/RNSCommission.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ contract RNSCommission is Initializable, AccessControlEnumerable, INSCommission
* @dev Helper method to allocate commission and take fee into recipient address.
*/
function _allocateCommissionAndTransferToRecipient(uint256 ronAmount) internal {
if (ronAmount == 0) revert InvalidAmountOfRON();
if (ronAmount == 0) return;

uint256 length = _commissionInfos.length;
if (length == 0) revert InvalidArrayLength();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ contract RNSCommisson__allocateCommissionAndTransferToRecipient_Test is RNSCommi
assertEq(random.balance, 0);
}

function test_RevertWhen_RonAmount_is_zero() external {
function testConcrete_Success_When_RonAmount_is_zero() external {
vm.deal(_senders[0], 1e18);

bool sent;
vm.expectRevert(INSCommission.InvalidAmountOfRON.selector);
vm.prank(_senders[0]);
(sent,) = address(_rnsCommission).call{ value: 0 }(new bytes(0));
tringuyenskymavis marked this conversation as resolved.
Show resolved Hide resolved

assertEq(_skyMavisTreasuryAddr.balance, 0);
assertEq(_roninNetworkTreasuryAddr.balance, 0);
assertEq(address(_rnsCommission).balance, 0);
assertEq(_senders[0].balance, 1e18);
}
}
Loading