diff options
author | Andrew Chow <github@achow101.com> | 2023-09-21 06:04:05 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-09-21 06:35:16 -0400 |
commit | 5027d41988d4a92be5a9fc846a680e805fc71383 (patch) | |
tree | 76f8eadfa6f6ef9ba8edbc72c4197f51eddb98cd /test/functional/rpc_net.py | |
parent | 1d4846a8443be901b8a5deb0e357481af22838d0 (diff) | |
parent | f52cb02f700b58bca921a7aa24bfeee04760262b (diff) |
Merge bitcoin/bitcoin#26366: rpc, test: `addnode` improv + add test coverage for invalid command
f52cb02f700b58bca921a7aa24bfeee04760262b doc: make it clear that `node` in `addnode` refers to the node's address (brunoerg)
effd1efefb53c58f0e43fec4f019a19f97795553 test: `addnode` with an invalid command should throw an error (brunoerg)
56b27b84877376ffc32b3bad09f1047b23de4ba1 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 f52cb02f700b58bca921a7aa24bfeee04760262b
jonatack:
ACK f52cb02f700b58bca921a7aa24bfeee04760262b
theStack:
re-ACK f52cb02f700b58bca921a7aa24bfeee04760262b
Tree-SHA512: e4a69e58b784e233463945b4d55a401957f9fe4562c129f59216a44f44fb3221d3449ac578fb35e665ca654c6ade2e741b72c3df78040f7527229c77b6c5b82e
Diffstat (limited to 'test/functional/rpc_net.py')
-rwxr-xr-x | test/functional/rpc_net.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py index 4fbe22a846..117802b812 100755 --- a/test/functional/rpc_net.py +++ b/test/functional/rpc_net.py @@ -61,7 +61,7 @@ class NetTest(BitcoinTestFramework): self.test_getpeerinfo() self.test_getnettotals() self.test_getnetworkinfo() - self.test_getaddednodeinfo() + self.test_addnode_getaddednodeinfo() self.test_service_flags() self.test_getnodeaddresses() self.test_addpeeraddress() @@ -205,8 +205,8 @@ class NetTest(BitcoinTestFramework): # Check dynamically generated networks list in getnetworkinfo help output. assert "(ipv4, ipv6, onion, i2p, cjdns)" in self.nodes[0].help("getnetworkinfo") - def test_getaddednodeinfo(self): - self.log.info("Test getaddednodeinfo") + def test_addnode_getaddednodeinfo(self): + self.log.info("Test addnode and getaddednodeinfo") assert_equal(self.nodes[0].getaddednodeinfo(), []) # add a node (node2) to node0 ip_port = "127.0.0.1:{}".format(p2p_port(2)) @@ -220,6 +220,8 @@ class NetTest(BitcoinTestFramework): # 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 + 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 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 |