diff options
author | Jon Atack <jon@atack.com> | 2021-05-22 22:09:28 +0200 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2021-05-23 10:39:08 +0200 |
commit | 6b1926cf1eac1ad1850599d2753dd22bc21fd327 (patch) | |
tree | 90f1510d75a32837d7e99d830d8a26d69b4906e2 /test | |
parent | be4171679b8eab8205e04ff86140329bd67878a0 (diff) | |
download | bitcoin-6b1926cf1eac1ad1850599d2753dd22bc21fd327.tar.xz |
test: addpeeraddress functional test coverage
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/rpc_net.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py index 2a58f8b3f7..9a2817a6ee 100755 --- a/test/functional/rpc_net.py +++ b/test/functional/rpc_net.py @@ -69,6 +69,7 @@ class NetTest(BitcoinTestFramework): self.test_getaddednodeinfo() self.test_service_flags() self.test_getnodeaddresses() + self.test_addpeeraddress() def test_connection_count(self): self.log.info("Test getconnectioncount") @@ -236,6 +237,30 @@ class NetTest(BitcoinTestFramework): assert_raises_rpc_error(-8, "Address count out of range", self.nodes[0].getnodeaddresses, -1) assert_raises_rpc_error(-8, "Network not recognized: Foo", self.nodes[0].getnodeaddresses, 1, "Foo") + def test_addpeeraddress(self): + self.log.info("Test addpeeraddress") + node = self.nodes[1] + + self.log.debug("Test that addpeerinfo is a hidden RPC") + # It is hidden from general help, but its detailed help may be called directly. + assert "addpeerinfo" not in node.help() + assert "addpeerinfo" in node.help("addpeerinfo") + + self.log.debug("Test that adding an empty address fails") + assert_equal(node.addpeeraddress(address="", port=8333), {"success": False}) + assert_equal(node.getnodeaddresses(count=0), []) + + self.log.debug("Test that adding a valid address succeeds") + assert_equal(node.addpeeraddress(address="1.2.3.4", port=8333), {"success": True}) + addrs = node.getnodeaddresses(count=0) + assert_equal(len(addrs), 1) + assert_equal(addrs[0]["address"], "1.2.3.4") + assert_equal(addrs[0]["port"], 8333) + + self.log.debug("Test that adding the same address again when already present fails") + assert_equal(node.addpeeraddress(address="1.2.3.4", port=8333), {"success": False}) + assert_equal(len(node.getnodeaddresses(count=0)), 1) + if __name__ == '__main__': NetTest().main() |