graph: replace fatal assertions and simplify test helpers#10609
graph: replace fatal assertions and simplify test helpers#10609ellemouton merged 5 commits intolightningnetwork:masterfrom
Conversation
Summary of ChangesHello @ellemouton, 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 refactors the testing infrastructure within the 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
|
🟢 PR Severity: LOW
🟢 Low (6 files)
AnalysisThis PR is a test-only change. All 6 modified files are No non-test, non-generated files were changed, so no severity bump rules apply (0 non-test files, 0 non-test lines changed). The changes appear to be refactoring or cleanup of existing graph-related tests, with a net reduction of 510 lines across 6 test files, suggesting test simplification or consolidation. To override, add a |
There was a problem hiding this comment.
Code Review
This pull request refactors tests in graph/ and graph/db/ to consistently use the testify/require package for assertions, replacing t.Fatal* and manual if err != nil checks. It also simplifies several test helper functions (randEdgePolicy, createChannelEdge, compareEdgePolicies) by making them perform assertions internally and removing error return values. The changes significantly improve the readability and conciseness of the test code. The refactoring is well-executed and follows best practices for testing in Go.
0e69874 to
fa2d502
Compare
bhandras
left a comment
There was a problem hiding this comment.
LGTM! Readability ftw! ✨
bitromortac
left a comment
There was a problem hiding this comment.
LGTM, nice improvements 🎉
Replace remaining fatal-style assertions in graph/db tests with direct testify/require helpers. This simplifies control flow and reduces indentation by using NoError, True/False, Equal, Len, Empty, and Nil assertions directly.
Replace remaining fatal-style assertions in graph package tests with direct testify/require helpers. This simplifies control flow and makes test intent clearer by using NoError, True/False, Len, Empty, and Equal/EqualValues assertions. Also remove FailNow-style patterns in favor of specific assertion helpers.
Update randEdgePolicy to take a testing handle, mark itself as a helper, and assert internal packing errors directly with require. Call sites now receive only the policy value without plumbing an error through immediate require.NoError checks.
Update createChannelEdge to take a testing handle, mark itself as a helper, and call require.NoError for funding script generation. All call sites now consume only returned values and no longer plumb an immediately-asserted error value.
Convert compareEdgePolicies into a test helper that accepts a testing handle and performs assertions directly. Update call sites to invoke the helper instead of threading errors into immediate require.NoError checks.
fa2d502 to
160c2a9
Compare
graph/andgraph/db/tests fromt.Fatal*/FailNow*patterns to directrequireassertions.t.Helper()and return only concrete values (randEdgePolicy,createChannelEdge,compareEdgePolicies).