Skip to content

Commit c09e025

Browse files
committed
shorter comments, fmt
1 parent 6169fe9 commit c09e025

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

pallets/referrals/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,8 @@ pub mod pallet {
482482
let who = ensure_signed(origin)?;
483483
for (asset_id, _) in PendingConversions::<T>::iter() {
484484
let asset_balance = T::Currency::balance(asset_id.clone(), &Self::pot_account_id());
485-
// Best-effort, matching `on_idle`: a slice that can't be converted (e.g. below the
486-
// converter's min trading limit) is skipped, not fatal — the funds stay in the pot
487-
// and the entry is dropped so it can't block this or anyone else's claim.
485+
// Best-effort, like `on_idle`: skip an un-convertible slice rather than revert the
486+
// whole claim. Funds stay in the pot and re-queue on the next fee.
488487
let _ = T::Convert::convert(
489488
Self::pot_account_id(),
490489
asset_id.clone(),

pallets/referrals/src/tests.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ thread_local! {
7070
pub static TIER_VOLUME: RefCell<HashMap<Level, Option<Balance>>> = RefCell::new(HashMap::default());
7171
pub static TIER_REWARDS: RefCell<HashMap<Level, FeeDistribution>> = RefCell::new(HashMap::default());
7272
pub static SEED_AMOUNT: RefCell<Balance> = RefCell::new(Balance::zero());
73-
// Mirrors the runtime `MinTradingLimit`: `AssetConvert` rejects sub-minimum amounts with a
74-
// non-referrals error, exactly as `ConvertViaOmnipool` -> `Omnipool::sell` does in production.
75-
// 0 disables the gate so existing tests are unaffected.
73+
// Mirrors runtime `MinTradingLimit`: reject sub-minimum amounts. 0 = disabled.
7674
pub static CONVERT_MIN_AMOUNT: RefCell<Balance> = RefCell::new(Balance::zero());
7775
}
7876

@@ -380,9 +378,7 @@ impl Convert<AccountId, AssetId, Balance> for AssetConvert {
380378
) -> Result<Balance, Self::Error> {
381379
let min_amount = CONVERT_MIN_AMOUNT.with(|v| *v.borrow());
382380
if amount > 0 && amount < min_amount {
383-
// Production parity: the omnipool-backed converter rejects sub-`MinTradingLimit`
384-
// amounts with `pallet_omnipool::Error::InsufficientTradingAmount` — an error that
385-
// is *not* one of the two referrals-specific variants `claim_rewards` tolerates.
381+
// Like `ConvertViaOmnipool`: sub-min amounts fail with a non-referrals error.
386382
return Err(DispatchError::Other("InsufficientTradingAmount"));
387383
}
388384
let price = CONVERSION_RATE

pallets/referrals/src/tests/claim.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ fn claim_rewards_should_remove_assets_from_the_list_when_not_successful() {
7474
});
7575
}
7676

77-
// Regression: a sub-`MinTradingLimit` dust balance of a non-reward asset in `PendingConversions`
78-
// must not block reward claims. The converter rejects the dust with a non-referrals error
79-
// (`InsufficientTradingAmount`), which the claim loop only tolerates for its own two legacy
80-
// variants — so today it reverts the whole claim instead of skipping the dust like `on_idle`
81-
// does. This test asserts the desired self-healing behaviour and currently FAILS, proving the bug.
77+
// Regression: sub-`MinTradingLimit` dust in `PendingConversions` must not block reward claims.
8278
#[test]
8379
fn claim_rewards_should_succeed_when_pending_asset_balance_is_below_min_trading_limit() {
8480
ExtBuilder::default()

0 commit comments

Comments
 (0)