mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
[tests] disconnect_ban: remove dependency on urllib
This commit is contained in:
parent
12de2f252c
commit
5cc3ee24d2
@ -3,14 +3,12 @@
|
|||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test node disconnect and ban behavior"""
|
"""Test node disconnect and ban behavior"""
|
||||||
import urllib.parse
|
|
||||||
|
|
||||||
from test_framework.mininode import wait_until
|
from test_framework.mininode import wait_until
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import (assert_equal,
|
from test_framework.util import (assert_equal,
|
||||||
assert_raises_jsonrpc,
|
assert_raises_jsonrpc,
|
||||||
connect_nodes_bi,
|
connect_nodes_bi,
|
||||||
p2p_port,
|
|
||||||
start_node,
|
start_node,
|
||||||
stop_node,
|
stop_node,
|
||||||
)
|
)
|
||||||
@ -82,20 +80,15 @@ class DisconnectBanTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
self.log.info("Test disconnectrnode RPCs")
|
self.log.info("Test disconnectrnode RPCs")
|
||||||
|
|
||||||
self.log.info("disconnectnode: successfully disconnect node")
|
self.log.info("disconnectnode: successfully disconnect node by address")
|
||||||
url = urllib.parse.urlparse(self.nodes[1].url)
|
address1 = self.nodes[0].getpeerinfo()[0]['addr']
|
||||||
self.nodes[0].disconnectnode(url.hostname + ":" + str(p2p_port(1)))
|
self.nodes[0].disconnectnode(address=address1)
|
||||||
wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 1)
|
wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 1)
|
||||||
for node in self.nodes[0].getpeerinfo():
|
assert not [node for node in self.nodes[0].getpeerinfo() if node['addr'] == address1]
|
||||||
assert(node['addr'] != url.hostname + ":" + str(p2p_port(1)))
|
|
||||||
|
|
||||||
self.log.info("disconnectnode: successfully reconnect node")
|
self.log.info("disconnectnode: successfully reconnect node")
|
||||||
connect_nodes_bi(self.nodes, 0, 1) # reconnect the node
|
connect_nodes_bi(self.nodes, 0, 1) # reconnect the node
|
||||||
found = False
|
assert [node for node in self.nodes[0].getpeerinfo() if node['addr'] == address1]
|
||||||
for node in self.nodes[0].getpeerinfo():
|
|
||||||
if node['addr'] == url.hostname + ":" + str(p2p_port(1)):
|
|
||||||
found = True
|
|
||||||
assert(found)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
DisconnectBanTest().main()
|
DisconnectBanTest().main()
|
||||||
|
Loading…
Reference in New Issue
Block a user