Fix input sanitation for listchaintxns lncli cmd#9558
Conversation
|
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
4f4641d to
fa5d0b4
Compare
guggero
left a comment
There was a problem hiding this comment.
Thanks for the fix. Makes sense, I think the "will be queried in reverse" was probably from an earlier version of the PR that added the offset.
fa5d0b4 to
60b4c13
Compare
This wording has been there for a long time, and its what inspired the original issue/PR, even before the offset PR. But now we fixed the help text, we don't have to implement it. |
|
@guggero I would like to potentially add a test for this, but I am not really sure where? Maybe there isnt tests for these kinds of things. |
You could extract the argument parsing into a function, then write a unit test for that in The other approach would be an integration test that executes the binary directly. See Line 14 in 64c660c |
|
@guggero: review reminder |
|
!lightninglabs-deploy mute |
42436ba to
3bf1cf6
Compare
|
I have added a test with a decent number of test cases. I also modified the Finally, as much as I would like to remove the cli context from the test itself, since it makes the test code a decent bit more verbose, I think it is necessary because of testing the behavior like in the paragraph above, where there are certain values unset in the CLI. Also I think it is good because it could provide an example for others how to test the CLI. Please let me know if you would like me to improve the test structure. I potentially could make the inputs inside a loop and reusing variables, but there is funkiness there with redefining values in flag which I'd have to tackle. |
|
Been running my new test like this: |
MPins
left a comment
There was a problem hiding this comment.
Good job for your first PR 👍
I ran the test and it’s working — maybe just a few small adjustments are needed.
303b741 to
8690d93
Compare
|
I also made a commit with some changes to the help text of the command. It feels like too much of the |
4efbbe2 to
1ea7067
Compare
MPins
left a comment
There was a problem hiding this comment.
Great progress! 👍
I’d suggest squashing the commits into two: one for the doc release and one for the other files — what do you think?
387cc42 to
1cd4d7d
Compare
Sounds good. Squashed to 2 commits. Getting better at managing the commit history, but still learning where to split the commits. Getting closer I hope! |
1cd4d7d to
3988024
Compare
There was a problem hiding this comment.
Some final comments and LGTM! 👍
It would be a good idea to have some description on commit message. Something like:
commands: add a parsing block height function
Added parseBlockHeightInputs function to parse start_height and end_height
from the CLI, ensuring start_height is non-negative and not greater than
end_height (unless it's -1), returning both values and any validation error.
3988024 to
0354a72
Compare
|
rebased to fix a merge conflict and to improve commit message. |
You should leave just one of the following lines in the commit message: Maybe the first is better 😉 |
0354a72 to
23f6368
Compare
Rebased again onto master, and modified the commit message... Hopefully acceptable now. Its been hard to get all of the integration tests to always pass consistently? I don't think it is related to my changes though? Please let me know. |
guggero
left a comment
There was a problem hiding this comment.
Thanks for the updates. Getting closer.
add a parsing block height function and error when block heights would produce invalid results
23f6368 to
2d82956
Compare

Change Description
This PR was based originally on the PR #7496 and issue #7316. Upon rebasing and looking at the solutions there, I found the bigger problem with the command was the lack of error messaging when the
end_height < start_heightrather than the necessity to support a "reverse ordering" feature.In this PR, I added additional checks to the block height input arguments which prevents providing arguments which get passed down the stack which yields incorrect results.
For example:
This is my first code commit to LND, 2nd including a comment update, so I appreciate the help to getting this PR mergable!
Steps to Test
Try using different options for
start_heightandend_height, including them, not including them, and having integer values in a way which doesn't make sense, and ensure that the proper errors are shown.Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.