aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-07-02 16:28:44 -0400
committerAva Chow <github@achow101.com>2024-07-02 16:28:44 -0400
commit6afc707c4f86e67411c260c408a1459fe0290d16 (patch)
tree113760c5a2e84f2763f5023afcbc77fedd336503 /test
parentd2c8d161b46bd62256a17abd086d8ae138c043c3 (diff)
parente38eadb2c2d93d2ee3c9accb649b2de144b3732e (diff)
downloadbitcoin-6afc707c4f86e67411c260c408a1459fe0290d16.tar.xz
Merge bitcoin/bitcoin#30339: test: add coverage for `node` field of `getaddednodeinfo` RPC
e38eadb2c2d93d2ee3c9accb649b2de144b3732e test: change comments to `self.log.info` for `test_addnode_getaddednodeinfo` (brunoerg) c838e3b6106adfe3fe3173aaf5b0a7dee023adce test: add coverage for `node` field of `getaddednodeinfo` RPC (brunoerg) Pull request description: We currently do not test a successful call to `getaddednodeinfo` filtering by `node`, we only test it with an unknown address and checks whether it fails. This PR adds coverage to it. ACKs for top commit: kevkevinpal: ACK [e38eadb](https://github.com/bitcoin/bitcoin/pull/30339/commits/e38eadb2c2d93d2ee3c9accb649b2de144b3732e)[e38eadb](https://github.com/bitcoin/bitcoin/pull/30339/commits/e38eadb2c2d93d2ee3c9accb649b2de144b3732e) achow101: ACK e38eadb2c2d93d2ee3c9accb649b2de144b3732e tdb3: re ACK e38eadb2c2d93d2ee3c9accb649b2de144b3732e BrandonOdiwuor: Code Review ACK e38eadb2c2d93d2ee3c9accb649b2de144b3732e rkrux: tACK [e38eadb](https://github.com/bitcoin/bitcoin/pull/30339/commits/e38eadb2c2d93d2ee3c9accb649b2de144b3732e) Tree-SHA512: e9f768b7aa86e58b0b0ced089ead57040ff9a5204493da1ab99c8bc897b6dcdce7c856855f74c52010fceef19af1e12a39eee9f8f2e7294b42476b6f980fe754
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/rpc_net.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 2701d2471d..37e2c1fb71 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -237,28 +237,35 @@ class NetTest(BitcoinTestFramework):
def test_addnode_getaddednodeinfo(self):
self.log.info("Test addnode and getaddednodeinfo")
assert_equal(self.nodes[0].getaddednodeinfo(), [])
- # add a node (node2) to node0
+ self.log.info("Add a node (node2) to node0")
ip_port = "127.0.0.1:{}".format(p2p_port(2))
self.nodes[0].addnode(node=ip_port, command='add')
- # try to add an equivalent ip
- # (note that OpenBSD doesn't support the IPv4 shorthand notation with omitted zero-bytes)
+ self.log.info("Try to add an equivalent ip and check it fails")
+ self.log.debug("(note that OpenBSD doesn't support the IPv4 shorthand notation with omitted zero-bytes)")
if platform.system() != "OpenBSD":
ip_port2 = "127.1:{}".format(p2p_port(2))
assert_raises_rpc_error(-23, "Node already added", self.nodes[0].addnode, node=ip_port2, command='add')
- # check that the node has indeed been added
+ self.log.info("Check that the node has indeed been added")
added_nodes = self.nodes[0].getaddednodeinfo()
assert_equal(len(added_nodes), 1)
assert_equal(added_nodes[0]['addednode'], ip_port)
- # check that node cannot be added again
+ self.log.info("Check that filtering by node works")
+ self.nodes[0].addnode(node="11.22.33.44", command='add')
+ first_added_node = self.nodes[0].getaddednodeinfo(node=ip_port)
+ assert_equal(added_nodes, first_added_node)
+ assert_equal(len(self.nodes[0].getaddednodeinfo()), 2)
+ self.log.info("Check that node cannot be added again")
assert_raises_rpc_error(-23, "Node already added", self.nodes[0].addnode, node=ip_port, command='add')
- # check that node can be removed
+ self.log.info("Check that node can be removed")
self.nodes[0].addnode(node=ip_port, command='remove')
- assert_equal(self.nodes[0].getaddednodeinfo(), [])
- # check that an invalid command returns an error
+ added_nodes = self.nodes[0].getaddednodeinfo()
+ assert_equal(len(added_nodes), 1)
+ assert_equal(added_nodes[0]['addednode'], "11.22.33.44")
+ self.log.info("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')
- # check that trying to remove the node again returns an error
+ self.log.info("Check that trying to remove the node again returns an error")
assert_raises_rpc_error(-24, "Node could not be removed", self.nodes[0].addnode, node=ip_port, command='remove')
- # check that a non-existent node returns an error
+ self.log.info("Check that a non-existent node returns an error")
assert_raises_rpc_error(-24, "Node has not been added", self.nodes[0].getaddednodeinfo, '1.1.1.1')
def test_service_flags(self):