Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances database integrity by implementing foreign key constraints between chain-related records and the AssetRecord, ensuring data consistency. Concurrently, it refactors the testing infrastructure by introducing a dedicated utility for pre-populating chain data, which simplifies test setup and improves the reliability of tests involving chain-specific assets. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces foreign key constraints to enhance database integrity by ensuring AccountRecord, NodeRecord, and NodeSelectedRecord reference valid assets. The migration order is correctly updated to accommodate these dependencies. A new test helper, DB.mockWithChains, is added to simplify test setup, and existing tests are updated to use it, which is a solid improvement. The changes are logical and well-executed. I have one suggestion to make the new test helper more robust in handling errors.
| static func mockWithChains(_ chains: [Chain] = [.bitcoin]) -> DB { | ||
| let db = Self.mock() | ||
| let assetStore = AssetStore(db: db) | ||
| try? assetStore.add(assets: chains.map { .mock(asset: .mock(id: $0.assetId)) }) |
There was a problem hiding this comment.
Using try? here can obscure errors during test setup, making debugging more difficult. If assetStore.add fails, the test will proceed with an incorrectly configured database, likely causing a less obvious failure later. It's better for the test setup to fail immediately and explicitly. Using try! is a good option here, as it will crash the test with a clear error if the asset addition fails, which is desirable for setup code that is not expected to fail.
| try? assetStore.add(assets: chains.map { .mock(asset: .mock(id: $0.assetId)) }) | |
| try! assetStore.add(assets: chains.map { .mock(asset: .mock(id: $0.assetId)) }) |
cfe2fa4 to
82bc578
Compare
Introduce DB.mockWithChains to pre-seed AssetStore for tests and update test cases to use it. Add foreign key references to AssetRecord on chain columns in AccountRecord, NodeRecord and NodeSelectedRecord to enforce referential integrity, and adjust migration ordering so AccountRecord is created after AssetRecord. Update WalletConnectorSigner.mock to seed the DB with chains derived from provided wallets.
82bc578 to
8c0527e
Compare
Introduce DB.mockWithChains to pre-seed AssetStore for tests and update test cases to use it. Add foreign key references to AssetRecord on chain columns in AccountRecord, NodeRecord and NodeSelectedRecord to enforce referential integrity, and adjust migration ordering so AccountRecord is created after AssetRecord. Update WalletConnectorSigner.mock to seed the DB with chains derived from provided wallets.
Close: #1723