diff options
author | John Newbery <john@johnnewbery.com> | 2017-04-19 13:44:16 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2017-04-19 13:47:56 -0400 |
commit | d54297f1a85612dab100c473ad04c4f9d279f473 (patch) | |
tree | fed8fc3b2d4a731b3d55136c67a1f27a8f4e5cfc /test/functional/disconnect_ban.py | |
parent | 5cc3ee24d29397737f2746d78b19a2509c0dedbb (diff) |
[tests] disconnect_ban: add tests for disconnect-by-nodeid
Diffstat (limited to 'test/functional/disconnect_ban.py')
-rwxr-xr-x | test/functional/disconnect_ban.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/functional/disconnect_ban.py b/test/functional/disconnect_ban.py index aeb4199c0f..3f451d49d2 100755 --- a/test/functional/disconnect_ban.py +++ b/test/functional/disconnect_ban.py @@ -80,6 +80,14 @@ class DisconnectBanTest(BitcoinTestFramework): self.log.info("Test disconnectrnode RPCs") + self.log.info("disconnectnode: fail to disconnect when calling with address and nodeid") + address1 = self.nodes[0].getpeerinfo()[0]['addr'] + node1 = self.nodes[0].getpeerinfo()[0]['addr'] + assert_raises_jsonrpc(-32602, "Only one of address and nodeid should be provided.", self.nodes[0].disconnectnode, address=address1, nodeid=node1) + + self.log.info("disconnectnode: fail to disconnect when calling with junk address") + assert_raises_jsonrpc(-29, "Node not found in connected nodes", self.nodes[0].disconnectnode, address="221B Baker Street") + self.log.info("disconnectnode: successfully disconnect node by address") address1 = self.nodes[0].getpeerinfo()[0]['addr'] self.nodes[0].disconnectnode(address=address1) @@ -88,7 +96,14 @@ class DisconnectBanTest(BitcoinTestFramework): self.log.info("disconnectnode: successfully reconnect node") connect_nodes_bi(self.nodes, 0, 1) # reconnect the node + assert_equal(len(self.nodes[0].getpeerinfo()), 2) assert [node for node in self.nodes[0].getpeerinfo() if node['addr'] == address1] + self.log.info("disconnectnode: successfully disconnect node by node id") + id1 = self.nodes[0].getpeerinfo()[0]['id'] + self.nodes[0].disconnectnode(nodeid=id1) + wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 1) + assert not [node for node in self.nodes[0].getpeerinfo() if node['id'] == id1] + if __name__ == '__main__': DisconnectBanTest().main() |