getaddednodeinfo
filtering by node
, we only test it with an unknown address and checks whether it fails. This PR adds coverage to it.
node
field of getaddednodeinfo
RPC
#30339
getaddednodeinfo
filtering by node
, we only test it with an unknown address and checks whether it fails. This PR adds coverage to it.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For detailed information about the code coverage, see the test coverage report.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | kevkevinpal, tdb3, BrandonOdiwuor, rkrux |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
248@@ -249,11 +249,17 @@ def test_addnode_getaddednodeinfo(self):
249 added_nodes = self.nodes[0].getaddednodeinfo()
250 assert_equal(len(added_nodes), 1)
251 assert_equal(added_nodes[0]['addednode'], ip_port)
252+ # check that filtering by node works
253+ self.nodes[0].addnode(node="11.22.33.44", command='add')
254+ added_node = self.nodes[0].getaddednodeinfo(node=ip_port)
first_added_node
or added_node_0
instead of added_node
to make it clearer that the node being referred to is the one added before 11.22.33.44. Alternatively, could update the comment/log message instead.
added_node_0
seems weird because it can be confused with nodes[0], I prefer first_added_node
. I will address it.
248@@ -249,11 +249,17 @@ def test_addnode_getaddednodeinfo(self):
249 added_nodes = self.nodes[0].getaddednodeinfo()
250 assert_equal(len(added_nodes), 1)
251 assert_equal(added_nodes[0]['addednode'], ip_port)
252+ # check that filtering by node works
nit: How about making this comment a log message instead?
https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#general-test-writing-advice
Instead of inline comments or no test documentation at all, log the comments to the test log, e.g. self.log.info(‘Create enough transactions to fill a block’). Logs make the test code easier to read and the test logic easier to debug.
Also, since we’re touching this function, it might be reasonable to add a commit to convert the surrounding comments of this function to log messages. Any objections from others?
248@@ -249,11 +249,17 @@ def test_addnode_getaddednodeinfo(self):
249 added_nodes = self.nodes[0].getaddednodeinfo()
250 assert_equal(len(added_nodes), 1)
251 assert_equal(added_nodes[0]['addednode'], ip_port)
252+ # check that filtering by node works
253+ self.nodes[0].addnode(node="11.22.33.44", command='add')
254+ added_node = self.nodes[0].getaddednodeinfo(node=ip_port)
255+ assert_equal(added_nodes, added_node)
getaddednodeinfo(node="192.168.99.99")
. Test failed as expected.
Approach ACK
Good update to exercise the filtering feature of the RPC. Left a suggestion and nit.
258 # check that node can be removed
259 self.nodes[0].addnode(node=ip_port, command='remove')
260- assert_equal(self.nodes[0].getaddednodeinfo(), [])
261+ added_nodes = self.nodes[0].getaddednodeinfo()
262+ assert_equal(len(added_nodes), 1)
263+ assert_equal(added_nodes[0]['addednode'], "11.22.33.44")
self.nodes[0].addnode(node="11.22.33.44", command='remove')
instead?
Concept ACK 13a871f
ran locally and it passed for me
Force-pushed:
self.log.info
Thanks, @kevkevinpal and @tdb3.