-
Notifications
You must be signed in to change notification settings - Fork 2.2k
rpc: proper error code for GetChanInfo #9810
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
base: master
Are you sure you want to change the base?
rpc: proper error code for GetChanInfo #9810
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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
1f4cbf5
to
f6b50e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks for the PR!
When a channel edge is not found, return `NotFound` instead of the generic `Unknown` error code.
f6b50e0
to
80792fe
Compare
Thanks @guggero, addressed your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. This one is probably addressing part of #6729? I've left some nit comments otherwise LGTM
// testGetChannelInfoNotFound verifies that a missing channel reports an | ||
// appropriate gRPC status code when calling GetChanInfo | ||
func testGetChannelInfoNotFound(ht *lntest.HarnessTest) { | ||
ctx, cancel := context.WithTimeout(context.Background(), lntest.DefaultTimeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lint code
CI test didn't pass here because of 87 chars exceeds 80 chars. This could be:
ctx, cancel := context.WithTimeout(
context.Background(), lntest.DefaultTimeout
)
You could run make lint
and make fmt
to see if there are no linting issues in local dev.
@@ -420,6 +424,24 @@ func testNodeAnnouncement(ht *lntest.HarnessTest) { | |||
assertAddrs(nodeUpdate.Addresses, advertisedAddrs...) | |||
} | |||
|
|||
// testGetChannelInfoNotFound verifies that a missing channel reports an | |||
// appropriate gRPC status code when calling GetChanInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: .
at the end of the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the release the note needs to be in a separate git commit after adding the changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: there're no hard requirements on this, but yeah nice to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: there're no hard requirements on this, but yeah nice to have.
|
||
# Bug Fixes | ||
|
||
* [Fix a bug](https://github.com/lightningnetwork/lnd/pull/9810) where the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this under ## RPC Updates
so the node runners can update accordingly, as it's a behavior change in the RPC.
@@ -420,6 +424,24 @@ func testNodeAnnouncement(ht *lntest.HarnessTest) { | |||
assertAddrs(nodeUpdate.Addresses, advertisedAddrs...) | |||
} | |||
|
|||
// testGetChannelInfoNotFound verifies that a missing channel reports an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this test belongs to lnd_misc_test.go
defer cancel() | ||
|
||
alice := ht.NewNode("Alice", nil) | ||
_, err := alice.RPC.LN.GetChanInfo(ctx, &lnrpc.ChanInfoRequest{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create a GetChanInfoAssertErr
instead to keep the format consistent? sth like,
Lines 366 to 390 in 3707b1f
// SendCoins sends a given amount of money to the specified address from the | |
// passed node. | |
func (h *HarnessRPC) SendCoins( | |
req *lnrpc.SendCoinsRequest) *lnrpc.SendCoinsResponse { | |
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout) | |
defer cancel() | |
resp, err := h.LN.SendCoins(ctxt, req) | |
h.NoError(err, "SendCoins") | |
return resp | |
} | |
// SendCoinsAssertErr sends a given amount of money to the specified address | |
// from the passed node and asserts an error has returned. | |
func (h *HarnessRPC) SendCoinsAssertErr(req *lnrpc.SendCoinsRequest) error { | |
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout) | |
defer cancel() | |
_, err := h.LN.SendCoins(ctxt, req) | |
require.Error(h, err, "node %s didn't not return an error", h.Name) | |
return err | |
} |
Change Description
When a channel edge is not found, return
NotFound
instead of the genericUnknown
error code.Steps to Test
GetChanInfo
RPC endpoint on an unknown channel.NotFound
error code is returned.Pull Request Checklist
Testing
Code Style and Documentation
[ ] Any new logging statements use an appropriate subsystem and logging level.[ ] Any new lncli commands have appropriate tags in the comments for the rpc in the proto file.[skip ci]
in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.