fix: avoid static initialization of payment_address in tests#211
fix: avoid static initialization of payment_address in tests#211fpelliccioni merged 1 commit intomasterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReplaced a namespace-scope Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
ab31d67 to
1906b22
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/domain/test/wallet/coin_selection.cpp`:
- Line 985: The vector initializations use the function symbol test_address
instead of calling it, causing a type mismatch for std::vector<payment_address>;
replace bare test_address with calls to the function (test_address()) in the
change_addrs initializer at the occurrences (e.g., change_addrs =
{test_address(), test_address(), test_address()}), and do the same for the other
occurrence around line 1142 so each element is a payment_address instance rather
than a function pointer.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 99ec2249-a144-4f2a-9204-6aada289f7c2
📒 Files selected for processing (1)
src/domain/test/wallet/coin_selection.cpp
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #211 +/- ##
===========================================
+ Coverage 0.26% 47.61% +47.35%
===========================================
Files 326 326
Lines 16066 16066
Branches 5826 5826
===========================================
+ Hits 42 7650 +7608
+ Misses 15999 6242 -9757
- Partials 25 2174 +2149 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
test_addressfrom a namespace-scope static constant to a function returning a local static reference, avoiding static initialization order issues withpayment_addressconstructorProblem
kth_domain_testsegfaults during Catch2 test discovery on GCC 15 with sanitizers. Thepayment_addressconstructor parses a cashaddr string at static initialization time, which may depend on other statics not yet initialized.Test plan
Closes #210
Note
Low Risk
Low risk: test-only change that delays
payment_addressconstruction to runtime to avoid static initialization order crashes; no production wallet/coin-selection logic is modified.Overview
Updates
coin_selection.cpptests to replace the namespace-scopepayment_addressconstant with atest_address()accessor that returns a function-local static.All test call sites are updated to use
test_address()so the cashaddr parsing inpayment_addresshappens on first use, preventing static initialization order issues during Catch2 test discovery.Written by Cursor Bugbot for commit 1906b22. This will update automatically on new commits. Configure here.
Summary by CodeRabbit