chore(fee-processor): add regression tests and improve overall coverage#1410
Open
F3Joule wants to merge 4 commits intofeat/gigahdx-implfrom
Open
chore(fee-processor): add regression tests and improve overall coverage#1410F3Joule wants to merge 4 commits intofeat/gigahdx-implfrom
F3Joule wants to merge 4 commits intofeat/gigahdx-implfrom
Conversation
Make it closer to production scenario with 3-pots distribution
|
Crate versions that have not been updated:
Runtime version has not been increased. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR improves test coverage for
pallet-fee-processorandpallet-referralsfollowing the fee processing refactor. It also aligns the test mock with the productionHdxFeeReceiversconfiguration.Found issues / follow-up
process_trade_fee(amount=0)inserts asset intoPendingConversionsdespite no tokens being transferred, leading to infinite failed conversions inon_idle. Needs a decision: early return on zero amount, or guard indo_convert.PendingConversions. A permanently failing asset (e.g. no liquidity pool) will consume anon_idleslot every block indefinitely.Changes
pallet-fee-processorMock updated to reflect production HDX receiver shape
Replaced the previous 2-receiver mock (50/50 including a fake referrals receiver) with 3 receivers matching the structural shape of the runtime config:
HdxGigaHdxFeeReceiver— 70%HdxGigaRewardFeeReceiver— 20%HdxStakingFeeReceiver— 10%Referrals is not part of the HDX fee path and has been removed from
HdxFeeReceiversin the mock accordingly.New tests —
convert.rson_idle_retries_failed_conversion_on_next_block- confirms retry behavior (intentional divergence from old referrals pallet which removed failed assets)convert_extrinsic_for_asset_not_in_pending_still_executes- documents permissionless nature ofdo_converton_idle_returns_zero_when_weight_below_single_conversion- verifies weight guard early exiton_idle_processes_only_one_when_weight_fits_exactly_one- verifies weight budget precisiondistribute_to_pots_uses_total_param_not_actual_pot_balance- regression test for suspicious unused_balanceread at lib.rs:280; confirms pre-existing HDX on pot is not redistributedNew tests —
process_fee.rsprocess_trade_fee_same_asset_twice_does_not_duplicate_pending_countprocess_trade_fee_fails_when_source_has_insufficient_balanceprocess_trade_fee_nothing_changes_when_pre_deposit_callback_fails- confirms Substrate transactional rollback, so we are sure no assets stuck on pot because of failing handler.pallet-referralsNew tests —
accumulator.rs(new file)Covers the new reward-per-share accumulator logic that replaced the old share-based distribution:
on_hdx_deposited_bumps_reward_per_share_correctlyon_hdx_deposited_does_nothing_when_total_shares_is_zeroon_hdx_deposited_accumulates_correctly_over_multiple_callson_fee_received_calculates_shares_correctly_for_all_partieson_fee_received_skips_referrer_share_when_no_code_linkedon_fee_received_external_account_none_shares_droppedcheckpoint_user_accumulates_pending_rewards_before_share_changeclaim_rewards_cannot_double_claim_via_debt_mechanismclaim_rewards_combines_accumulated_and_pending_rewardsExtBuilderextended withwith_reward_per_share,with_user_reward_debts,with_user_accumulated_rewardsbuilders to support accumulator state setup in tests.