Skip to content

test(referral): add edge case tests for cycle detection - #69

Merged
merlik787-droi merged 1 commit into
Riddlrealm:mainfrom
usmanimamu17-create:fix/issue-20-self-referral-cycle-detection
Jul 22, 2026
Merged

test(referral): add edge case tests for cycle detection#69
merlik787-droi merged 1 commit into
Riddlrealm:mainfrom
usmanimamu17-create:fix/issue-20-self-referral-cycle-detection

Conversation

@usmanimamu17-create

@usmanimamu17-create usmanimamu17-create commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Add edge case tests for referral cycle detection to improve coverage and document depth-limit behavior.

Changes

  • test_direct_two_hop_cycle_should_fail: Verifies A?B?A direct cycle is rejected
  • test_cycle_beyond_max_depth_not_detected: Documents that cycles beyond max_chain_depth are not detected (expected depth-limit behavior)

Existing Implementation

The referral contract already has comprehensive cycle detection:

  • Self-referral prevention (Cannot refer yourself)
  • Ancestor walk with configurable max_chain_depth
  • Existing tests for 5-node cycles and deep chains

These tests verify edge cases and document the depth-limit limitation.

Closes #20

Add tests for cycle detection edge cases:
- test_direct_two_hop_cycle_should_fail: A->B->A direct cycle
- test_cycle_beyond_max_depth_not_detected: documents depth-limit behavior

The referral contract already has comprehensive cycle detection:
- Self-referral prevention ('Cannot refer yourself')
- Ancestor walk with configurable max_chain_depth
- Existing tests for 5-node cycles and deep chains

These tests verify edge cases and document the depth-limit limitation.

Implements Issue Riddlrealm#20
@usmanimamu17-create
usmanimamu17-create force-pushed the fix/issue-20-self-referral-cycle-detection branch from a4c3d00 to 5aea95e Compare July 22, 2026 10:20

@merlik787-droi merlik787-droi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@merlik787-droi
merlik787-droi merged commit 8f2ac03 into Riddlrealm:main Jul 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent self-referral graph cycles in referral chains

2 participants