Skip to content

Conversation

@grunch
Copy link
Member

@grunch grunch commented Feb 11, 2026

Add 18 integration tests verifying cross-component flows between MostroNodesNotifier and SettingsNotifier. Tests cover node switching with relay reset, custom node lifecycle, backward compatibility, persistence round-trips, and relay reconnection behavior.

Update MULTI_MOSTRO_SUPPORT.md Phase 4 section with implementation details, test group descriptions, and coverage summary (64 total tests across Phases 1-4).

Summary by CodeRabbit

  • Documentation

    • Marked Phase 4 complete and expanded the integration testing doc with a consolidated test plan, key decisions, grouped scenarios, and updated coverage summary.
  • Tests

    • Added a comprehensive integration test suite validating node switching, custom-node lifecycle, persistence across restarts, relay reconnection behavior, backwards compatibility, case handling, and multi-step end-to-end flows (coverage now 69 tests).
  • Bug Fixes

    • Improved node selection and addition to treat pubkeys case-insensitively, reducing duplicate/selection errors.

Add 18 integration tests verifying cross-component flows between
MostroNodesNotifier and SettingsNotifier. Tests cover node switching
with relay reset, custom node lifecycle, backward compatibility,
persistence round-trips, and relay reconnection behavior.

Update MULTI_MOSTRO_SUPPORT.md Phase 4 section with implementation
details, test group descriptions, and coverage summary (64 total
tests across Phases 1-4).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Walkthrough

Phase 4 of multi-Mostro integration testing is marked completed; a new comprehensive integration test file for MostroNodesNotifier is added, docs updated with test plans and decisions, and small code tweaks normalize pubkey handling and a comment in SettingsNotifier.

Changes

Cohort / File(s) Summary
Documentation
docs/MULTI_MOSTRO_SUPPORT.md
Phase 4 header changed to "Completed"; expanded goal, detailed test groups (23 integration tests across 7 groups), key decisions, and updated test coverage summary.
Integration Tests
test/features/mostro/mostro_integration_test.dart
New comprehensive integration test suite using mocked Settings, NostrService, and in-memory SharedPreferences; covers node switching, custom-node lifecycle, backward-compat/import, relay clearing/reconnect behavior, case-insensitive pubkey handling, multi-session persistence, and robustness scenarios.
Mostro Notifier
lib/features/mostro/mostro_nodes_notifier.dart
Normalize input pubkey to lowercase in selectNode and addCustomNode to ensure case-insensitive duplicate detection and selection.
Settings Notifier (minor)
lib/features/settings/settings_notifier.dart
Only inline comment around Mostro instance update modified; behavior that resets blacklistedRelays and userRelays and updates mostroPublicKey remains unchanged.

Sequence Diagram(s)

(Skipped — changes are primarily tests, small normalization, and documentation; no new multi-component control flow requiring visualization.)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • AndreaDiazCorreia
  • BraCR10
  • Catrya

Poem

🐰 Hopping through mocks and memory bright,
I bind pubkeys, relays, and tests tonight.
Lowercase steps, persistence in tow,
Nodes pick up where past sessions go,
A carrot-coded cheer — hop, tests, go! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main change: adding multi-Mostro integration tests for Phase 4, which comprises the majority of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch phase-4-integration-testing

No actionable comments were generated in the recent review. 🎉


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Add 4 missing edge case tests: selectNode with unknown pubkey
  (no-op), empty mostroPublicKey (null selectedNode), duplicate
  addCustomNode rejection, main relays list preserved on switch
- Rename group "Case-insensitive pubkey handling" to "Pubkey case
  sensitivity" to accurately reflect exact-match behavior
- Rename test "selected node persists via settings notifier" to
  "selectNode updates settings notifier state" for accuracy
- Fix Spanish comments in settings_notifier.dart to English
- Update MULTI_MOSTRO_SUPPORT.md with new test counts (22 tests,
  68 total across Phases 1-4)
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@test/features/mostro/mostro_integration_test.dart`:
- Around line 467-489: The addCustomNode and selectNode paths allow case-variant
pubkeys to be treated as distinct because duplicates and selection use direct
string comparison (e.g., state.any((n) => n.pubkey == pubkey) and if (n.pubkey
== pubkey)); fix by normalizing incoming pubkey strings to a canonical form
(lowercase) before validation and before comparisons in addCustomNode and
selectNode (ensure the validator still accepts hex with /^[0-9a-fA-F]{64}$/ but
apply pubkey = pubkey.toLowerCase() at the start of both methods), so all stored
MostroNode.pubkey values and lookup keys are lowercase and
duplicate/preselection logic works correctly.

Apply pubkey.toLowerCase() at the start of addCustomNode() and
selectNode() so all stored MostroNode.pubkey values and lookup keys
are in canonical lowercase form. This prevents case-variant duplicates
(e.g. uppercase hex treated as distinct from lowercase) and ensures
selectNode finds nodes regardless of input casing.

The hex validator still accepts [0-9a-fA-F]{64} but normalization
happens before validation and before all comparisons.

Update integration tests to verify the new behavior: uppercase
duplicate rejected, uppercase selectNode finds lowercase-stored node.
@grunch grunch requested a review from mostronator February 11, 2026 20:07
Copy link
Collaborator

@mostronator mostronator left a comment

Choose a reason for hiding this comment

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

Thorough integration test suite! 👏

What I like:

  • 23 tests across 7 well-organized groups covering the full multi-Mostro lifecycle
  • In-memory SharedPreferences mock for persistence round-trip testing is clever
  • Dynamic mock ref pattern ensures state changes from updateMostroInstance() are visible to subsequent reads
  • Good edge cases: malformed pubkey, empty pubkey, duplicate rejection, active node removal prevention
  • Pubkey lowercase normalization in both addCustomNode and selectNode is a nice defensive fix
  • Spanish comments cleaned up in settings_notifier.dart

Minor note:

  • The doc says 23 tests but the summary table adds up to 23 (4+4+4+3+4+2+2) ✅ consistent

LGTM! 🚀

@grunch grunch merged commit c6d6307 into main Feb 11, 2026
2 checks passed
@grunch grunch deleted the phase-4-integration-testing branch February 11, 2026 20:30
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.

2 participants