-
Notifications
You must be signed in to change notification settings - Fork 38.7k
rpc, test: addnode improv + add test coverage for invalid command
#26366
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
getpeerinfo clean-ups + add test coverage for invalid commandgetpeerinfo improv + add test coverage for invalid command
theStack
left a 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.
Code-review ACK 40660d517022b30e3ab4dcf852a6c86502fa97f3
|
CI failure seems unrelated to these changes. |
Thanks, fixed in #27777 |
getpeerinfo improv + add test coverage for invalid commandaddnode improv + add test coverage for invalid command
40660d5 to
c2349d6
Compare
theStack
left a 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.
re-ACK c2349d6a04832d9c96a8746fc588bae8fc85376d
The only change since my last ACK was adapting the first commit's subject (s/getpeerinfo/addnode/). Sorry for late re-review, I must have missed the force-push two months ago.
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.
ACK c2349d6a04832d9c96a8746fc588bae8fc85376d
some non-blocking suggestions
Edit: suggest dropping "p2p" from the PR title and the first commit title.
1. Use const where possible; 2. Rename variables to make them clearer; 3. There is no need to check whether `command` is null since it's a non-optional field.
c2349d6 to
f52cb02
Compare
addnode improv + add test coverage for invalid commandaddnode improv + add test coverage for invalid command
|
Force-pushed addressing @jonatack's review. Addressed: |
jonatack
left a 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.
ACK f52cb02
Two non-blocking suggestions.
| self.nodes[0].addnode(node=ip_port, command='remove') | ||
| assert_equal(self.nodes[0].getaddednodeinfo(), []) | ||
| # check that an invalid command returns an error | ||
| assert_raises_rpc_error(-1, 'addnode "node" "command"', self.nodes[0].addnode, node=ip_port, command='abc') |
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.
"remove the check for nullance for command since it's a non-optional field"
while here, maybe test that assertion
- # check that an invalid command returns an error
+ # check that an invalid or missing command returns an error
assert_raises_rpc_error(-1, 'addnode "node" "command"', self.nodes[0].addnode, node=ip_port, command='abc')
+ assert_raises_rpc_error(-1, 'addnode "node" "command"', self.nodes[0].addnode, node=ip_port)| if (!connman.RemoveAddedNode(strNode)) { | ||
| if (!connman.RemoveAddedNode(node_arg)) { | ||
| throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node could not be removed. It has not been added previously."); | ||
| } |
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.
suggestion while touching this
- if (command == "onetry")
- {
+ if (command == "onetry") {
CAddress addr;
connman.OpenNetworkConnection(addr, /*fCountFailure=*/false, /*grantOutbound=*/nullptr, node_arg.c_str(), ConnectionType::MANUAL);
return UniValue::VNULL;
- }
-
- if (command == "add")
- {
+ } elsif (command == "add") {
if (!connman.AddNode(node_arg)) {
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Node already added");
}
- }
- else if (command == "remove")
- {
+ } else if (command == "remove") {
if (!connman.RemoveAddedNode(node_arg)) {
throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node could not be removed. It has not been added previously.");
}
theStack
left a 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.
re-ACK f52cb02
|
ACK f52cb02 |
jonesk7734
left a 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.
Ok
…for invalid command f52cb02 doc: make it clear that `node` in `addnode` refers to the node's address (brunoerg) effd1ef test: `addnode` with an invalid command should throw an error (brunoerg) 56b27b8 rpc, refactor: clean-up `addnode` (brunoerg) Pull request description: This PR: - Adds test coverage for an invalid `command` in `addnode`. - Rename `test_getaddednodeinfo` to `test_addnode_getaddednodeinfo` and its log since this function also tests `addnode` and it doesn't worth to split into 2 ones. - Makes it clear in docs that `node` in `addnode` refers to the node's address. It seemed a little weird for me "The node (see getpeerinfo for nodes)", it could mean a lot of things e.g. the node id. - Some small improv/clean-up: use `const` where possible, rename some vars, and remove the check for nullance for `command` since it's a non-optional field. ACKs for top commit: achow101: ACK f52cb02 jonatack: ACK f52cb02 theStack: re-ACK f52cb02 Tree-SHA512: e4a69e58b784e233463945b4d55a401957f9fe4562c129f59216a44f44fb3221d3449ac578fb35e665ca654c6ade2e741b72c3df78040f7527229c77b6c5b82e
…for invalid command f52cb02 doc: make it clear that `node` in `addnode` refers to the node's address (brunoerg) effd1ef test: `addnode` with an invalid command should throw an error (brunoerg) 56b27b8 rpc, refactor: clean-up `addnode` (brunoerg) Pull request description: This PR: - Adds test coverage for an invalid `command` in `addnode`. - Rename `test_getaddednodeinfo` to `test_addnode_getaddednodeinfo` and its log since this function also tests `addnode` and it doesn't worth to split into 2 ones. - Makes it clear in docs that `node` in `addnode` refers to the node's address. It seemed a little weird for me "The node (see getpeerinfo for nodes)", it could mean a lot of things e.g. the node id. - Some small improv/clean-up: use `const` where possible, rename some vars, and remove the check for nullance for `command` since it's a non-optional field. ACKs for top commit: achow101: ACK f52cb02 jonatack: ACK f52cb02 theStack: re-ACK f52cb02 Tree-SHA512: e4a69e58b784e233463945b4d55a401957f9fe4562c129f59216a44f44fb3221d3449ac578fb35e665ca654c6ade2e741b72c3df78040f7527229c77b6c5b82e
This PR:
commandinaddnode.test_getaddednodeinfototest_addnode_getaddednodeinfoand its log since this function also testsaddnodeand it doesn't worth to split into 2 ones.nodeinaddnoderefers to the node's address. It seemed a little weird for me "The node (see getpeerinfo for nodes)", it could mean a lot of things e.g. the node id.constwhere possible, rename some vars, and remove the check for nullance forcommandsince it's a non-optional field.