[tests] disconnect_ban: add tests for disconnect-by-nodeid
This commit is contained in:
parent
5cc3ee24d2
commit
d54297f1a8
1 changed files with 15 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue