-
Notifications
You must be signed in to change notification settings - Fork 97
tests: Divide by the win_prob to get the correct expected value #7227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: Divide by the win_prob to get the correct expected value #7227
Conversation
📝 WalkthroughWalkthroughThe tests for ticket redemption and relay behavior were updated to increase tolerance for winning ticket count deviations and to adjust the expected unredeemed ticket value calculations, incorporating terms involving the inverse of the win probability. No changes to logic or control flow were made. Changes
Sequence Diagram(s)sequenceDiagram
participant Test
participant RelayNode
Test->>RelayNode: Send packets with tickets (win_prob < 1)
RelayNode-->>Test: Update unredeemed ticket value with adjusted expectation
Test->>Test: Await unredeemed value = unredeemed_value_before + (ticket_price + ticket_price / win_prob)
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (8)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Fix the smoke test for win_prob
by adjusting the expected unredeemed ticket value to account for the probability factor.
- Update the expected value calculation in the test to divide total ticket value by the win probability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/test_win_prob.py (1)
118-118
: Correct expected value calculation for probabilistic tickets.The change properly accounts for the winning probability in the expected value calculation. When
win_prob = 0.1
, dividing by the probability correctly scales the expected unredeemed ticket value, which aligns with the mathematical expectation for probabilistic systems and is consistent with similar calculations throughout the file.However, the line exceeds the 120-character limit. Consider breaking it for better readability:
- swarm7[relay], statistics_before.unredeemed_value + (ticket_count * ticket_price / Decimal(win_prob)) + swarm7[relay], + statistics_before.unredeemed_value + (ticket_count * ticket_price / Decimal(win_prob))🧰 Tools
🪛 Ruff (0.11.9)
118-118: Line too long (125 > 120)
(E501)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/test_win_prob.py
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: NumberFour8
PR: hoprnet/hoprnet#6511
File: tests/test_integration.py:1182-1198
Timestamp: 2024-10-01T04:47:11.992Z
Learning: In the test `test_hoprd_should_not_accept_tickets_with_lower_than_min_win_prob`, the relay's `rejected_tickets_value` and `unredeemed_value` are already being verified to ensure tickets are rejected and the unredeemed value does not increase.
tests/test_win_prob.py (1)
Learnt from: NumberFour8
PR: hoprnet/hoprnet#6511
File: tests/test_integration.py:1182-1198
Timestamp: 2024-10-01T04:47:11.992Z
Learning: In the test `test_hoprd_should_not_accept_tickets_with_lower_than_min_win_prob`, the relay's `rejected_tickets_value` and `unredeemed_value` are already being verified to ensure tickets are rejected and the unredeemed value does not increase.
🪛 Ruff (0.11.9)
tests/test_win_prob.py
118-118: Line too long (125 > 120)
(E501)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: hopli / docker
- GitHub Check: Docs / Rust docs
- GitHub Check: tests-unit
- GitHub Check: Build Candidate Binaries (hoprd)
- GitHub Check: tests-unit-nightly
- GitHub Check: Linter
- GitHub Check: zizmor
- GitHub Check: Cargo Audit
53253b4
to
4230375
Compare
Fix the win_prob smoke test to properly divide by the probability to get the correct incentive.