Skip to content

fix: #172 mock data behind #if DEBUG #178

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

Merged
merged 1 commit into from
Mar 25, 2025

Conversation

danielnordh
Copy link
Collaborator

@danielnordh danielnordh commented Mar 24, 2025

Fixes issue by removing if DEBUG check

Summary by CodeRabbit

  • Chores
    • Adjusted the build configuration to ensure backup management and network operations are available consistently across all environments.

Copy link
Contributor

coderabbitai bot commented Mar 24, 2025

Walkthrough

The update removes the conditional compilation directives (#if DEBUG / #endif) that were wrapping the mock extension on the KeyClient struct. As a result, the extension is now always included in builds. The functional implementation for backup operations, network handling, and URL configurations remains unchanged.

Changes

File(s) Change Summary
LDKNodeMonday/.../KeyService.swift Removed #if DEBUG / #endif directives surrounding the mock extension in the KeyClient struct.

Poem

Oh, I’m a rabbit, full of cheer,
Hopping through code, my eyes so clear,
Debug flags gone, all changes in sight,
Mocking enabled, day and night,
My little paws tap a happy beat,
Celebrating code that’s clean and neat!
🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a924828 and df56ee0.

📒 Files selected for processing (1)
  • LDKNodeMonday/Service/KeyService/KeyService.swift (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
LDKNodeMonday/Service/KeyService/KeyService.swift (2)
LDKNodeMonday/Service/Lightning Service/LightningNodeService.swift (1)
  • getBackupInfo (322-325)
LDKNodeMonday/View Model/Profile/SettingsViewModel.swift (1)
  • getNetwork (65-84)
🔇 Additional comments (1)
LDKNodeMonday/Service/KeyService/KeyService.swift (1)

124-134:

❓ Verification inconclusive

Verify if including mock implementation in all builds is intended.

The change removes the #if DEBUG / #endif directives around the KeyClient.mock extension, making it available in all builds (including release builds) rather than just debug builds. While this aligns with the PR objective to remove the conditional compilation, it's worth confirming if this is the desired behavior since mock implementations are typically not included in production code.

Additionally, I notice that mockBackupInfo is referenced in line 127 but isn't defined in the visible code. This could lead to compilation errors if it's not defined elsewhere in the codebase.


🏁 Script executed:

#!/bin/bash
# Check if mockBackupInfo is defined somewhere in the codebase
echo "Searching for mockBackupInfo definition..."
rg "let\s+mockBackupInfo|var\s+mockBackupInfo" --type swift

Length of output: 230


Attention: Confirm Production Inclusion of Mocks

  • The search confirms that mockBackupInfo is defined in LDKNodeMonday/Model/BackupInfo.swift, so the reference in the mock implementation won’t cause compilation errors.
  • However, note that the removal of the #if DEBUG/#endif directives makes the KeyClient.mock available in all builds, including production. Since mocks are traditionally confined to debug or testing builds, please verify that this behavior is intended for the application.
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@danielnordh danielnordh mentioned this pull request Mar 24, 2025
@reez
Copy link
Owner

reez commented Mar 24, 2025

My only thoughts were if we wanted to do it differently than this or not (we want to hide mock data from the user and thus hide it behind the DEBUG check so it will never go out in a prod build). But since AppMode needs to go out in a prod build yet also holds mock data, I didn't know if there was an alternative path where we could keep mock data hidden yet still use AppMode in some way.

Maybe that's a problem that will be solved by just reconfiguring AppMode down the road to not hold mock data or not use AppMode at the point where we have it in front of users, I dunno really, what do you think?

@danielnordh
Copy link
Collaborator Author

Since it's (so far) a developer focused wallet I didn't think it was a big issue.
If we want to avoid exposing the .mock mode to users, I'd imagine we simply remove the option from the settings menu.

I don't have a better idea at the moment.

@reez
Copy link
Owner

reez commented Mar 24, 2025

Since it's (so far) a developer focused wallet I didn't think it was a big issue. If we want to avoid exposing the .mock mode to users, I'd imagine we simply remove the option from the settings menu.

I don't have a better idea at the moment.

yep that's basically what I think too atm, can do something later when we get to a different stage/userbase

@reez
Copy link
Owner

reez commented Mar 24, 2025

ACK

@danielnordh danielnordh merged commit 37ef115 into reez:main Mar 25, 2025
1 check passed
@danielnordh
Copy link
Collaborator Author

Closes #172

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