You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This helper seems kinda selective for just the newly added test, when there are already existing tests with shared code that could be refactored as well.
Looking through payjoin-mailroom/src/lib.rs, I noticed duplicated setup in the metrics tests, along with some shared setup across the service tests.
I'm thinking of extracting reusable test fixtures for the common configuration and app setup, while keeping the test-specific behavior and assertions unchanged.
Would that be a reasonable scope for this issue? @DanGould
@Christopherdominic may you be a bit more specific about what'd be shared and where the fixtures and "configuration" (what configuration) would live? I want to get this one nailed down so the actual PR review only has to happen once, and it's pretty far off of our mainline path so hoping if you pick it up you can apply some good taste to whatever bot output helps clean this up.
Thanks for the feedback. I took another look at payjoin-mailroom/src/lib.rs, and here's the specific scope I have in mind.
I'd keep the helpers local to the existing #[cfg(test)] mod tests in src/lib.rs, rather than introducing a separate fixtures module.
Configuration: Reuse the existing test_config(storage_dir) helper, which creates a Config with an ephemeral listener address ([::]:0), temporary storage directory, 2-second timeout, and no optional configuration. Both metrics tests currently construct this same Config manually.
Metrics setup: Extract a small async helper, something like metrics_test_app(), shared by middleware_records_metrics and middleware_bounds_endpoint_labels_in_metrics. It would create the in-memory metric exporter/provider, initialize the directory and relay services, and build the Axum app. It would return the app, provider, and exporter so each test can make its own requests and inspect its own metrics.
TLS service tests: Keep start_service() as the shared service-startup helper for self_loop_request_is_rejected and cross_instance_request_is_accepted. I don't plan to merge it with health_status(), since the latter specifically tests access-control behavior across HTTP and HTTPS.
The refactor would be limited to test setup in payjoin-mailroom/src/lib.rs. No changes to production code, assertions, or feature behavior. I'd run the mailroom tests with default and all features, plus formatting and Clippy.
The goal is to remove actual duplication without introducing a generic fixture framework or unnecessary abstractions.
Does that sound like the right scope before I start implementing it? @DanGould
AI disclosure: I used AI assistance to inspect the duplicated setup and refine this proposal; I'll review the implementation myself.
@DanGould following up on the scope above: helpers stay local to the existing #[cfg(test)] mod tests in payjoin-mailroom/src/lib.rs, the metrics tests reuse test_config, and one shared metrics setup helper serves both metrics tests, with no new fixtures module. Does that match what you had in mind? I'll hold off on the PR until it's agreed so review only has to happen once.
Activity
unrealtim-tech commentedon Oct 9, 2026
Hi maintainer, I would love to pick this up, could you assign this to me
Christopherdominic commentedon Oct 13, 2026
I'd like to work on this.
Looking through
payjoin-mailroom/src/lib.rs, I noticed duplicated setup in the metrics tests, along with some shared setup across the service tests.I'm thinking of extracting reusable test fixtures for the common configuration and app setup, while keeping the test-specific behavior and assertions unchanged.
Would that be a reasonable scope for this issue? @DanGould
DanGould commentedon Oct 13, 2026
@Christopherdominic may you be a bit more specific about what'd be shared and where the fixtures and "configuration" (what configuration) would live? I want to get this one nailed down so the actual PR review only has to happen once, and it's pretty far off of our mainline path so hoping if you pick it up you can apply some good taste to whatever bot output helps clean this up.
Christopherdominic commentedon Oct 14, 2026
Thanks for the feedback. I took another look at
payjoin-mailroom/src/lib.rs, and here's the specific scope I have in mind.I'd keep the helpers local to the existing
#[cfg(test)] mod testsinsrc/lib.rs, rather than introducing a separate fixtures module.Configuration: Reuse the existing
test_config(storage_dir)helper, which creates aConfigwith an ephemeral listener address ([::]:0), temporary storage directory, 2-second timeout, and no optional configuration. Both metrics tests currently construct this sameConfigmanually.Metrics setup: Extract a small async helper, something like
metrics_test_app(), shared bymiddleware_records_metricsandmiddleware_bounds_endpoint_labels_in_metrics. It would create the in-memory metric exporter/provider, initialize the directory and relay services, and build the Axum app. It would return the app, provider, and exporter so each test can make its own requests and inspect its own metrics.TLS service tests: Keep
start_service()as the shared service-startup helper forself_loop_request_is_rejectedandcross_instance_request_is_accepted. I don't plan to merge it withhealth_status(), since the latter specifically tests access-control behavior across HTTP and HTTPS.The refactor would be limited to test setup in
payjoin-mailroom/src/lib.rs. No changes to production code, assertions, or feature behavior. I'd run the mailroom tests with default and all features, plus formatting and Clippy.The goal is to remove actual duplication without introducing a generic fixture framework or unnecessary abstractions.
Does that sound like the right scope before I start implementing it? @DanGould
AI disclosure: I used AI assistance to inspect the duplicated setup and refine this proposal; I'll review the implementation myself.
Christopherdominic commentedon Nov 5, 2026
@DanGould following up on the scope above: helpers stay local to the existing
#[cfg(test)] mod testsinpayjoin-mailroom/src/lib.rs, the metrics tests reusetest_config, and one shared metrics setup helper serves both metrics tests, with no new fixtures module. Does that match what you had in mind? I'll hold off on the PR until it's agreed so review only has to happen once.