fix(referral_registry): reject unregistered referrers in register_referral - #125
Open
Anichris-koded wants to merge 2 commits into
Open
Conversation
…erral Closes SPulse-Org#71 - Add UnregisteredReferrer = 7 to ReferralError enum - Guard in register_referral validates the referrer is already a registered user before accepting the relationship; returns Err(ReferralError::UnregisteredReferrer) otherwise - Prevents fee routing to arbitrary/attacker-controlled addresses and stops inflation of ReferralCount for non-participants - Add test_reject_unregistered_referrer (expects Error SPulse-Org#7) - Update test_register_with_referrer, test_credit_with_referrer, test_earnings_accumulation, test_referrer_bonus_points_accumulate, and test_referral_count_tracking to pre-register the referrer; fix points assertions that now include the referrer's welcome bonus
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.
Summary
Fixes #71
register_referralaccepted anyreferrer: Option<Address>with no check that the address was a registered user. This allowed:ReferralCount/ReferralEarningsfor non-participantsChanges
referral_registry/src/lib.rsUnregisteredReferrer = 7toReferralErrorregister_referralimmediately after the self-referral check:is_registered()helper, which handles both the newProfilekey and legacyRegisteredkey — so legacy users remain valid referrers.referral_registry/src/tests.rstest_reject_unregistered_referrer— assertsError(Contract, #7)when a never-registered address is used as referrertest_register_with_referrer,test_credit_with_referrer,test_earnings_accumulation,test_referrer_bonus_points_accumulate,test_referral_count_trackingtest_credit_with_referrer(5 welcome + 3 credit = 8) andtest_referrer_bonus_points_accumulate(5 welcome + 3×3 credit = 14)What was tested
register_referral)