Skip to content

Commit

Permalink
Debit 0 value check (#10930)
Browse files Browse the repository at this point in the history
  • Loading branch information
pahor167 committed Feb 9, 2024
1 parent c7a5553 commit 0bfa0e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ contract FeeCurrencyAdapter is Initializable, CalledByVm, IFeeCurrencyAdapter {
*/
function debitGasFees(address from, uint256 value) external onlyVm {
uint256 valueScaled = downscale(value);
require(valueScaled > 0, "Scaled debit value must be > 0.");
debited = valueScaled;
adaptedToken.debitGasFees(from, valueScaled);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/protocol/test-sol/stability/FeeCurrencyAdapter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ contract FeeCurrencyAdapter_DebitGasFees is FeeCurrencyAdapterTest {
feeCurrencyAdapter.debitGasFees(address(this), 1000);
}

function test_ShouldRevert_WhenScaledDebitValueIs0() public {
vm.expectRevert("Scaled debit value must be > 0.");
vm.prank(address(0));
feeCurrencyAdapter.debitGasFees(address(this), 1e7);
}

function test_ShouldDebitCorrectAmount_WhenExpectedDigitsOnlyOneBigger() public {
debitFuzzyHelper(7, 1e1);
}
Expand Down

0 comments on commit 0bfa0e3

Please sign in to comment.