Skip to content

Commit e30e862

Browse files
committed
test: remove duplicated ban test
Test the ban list is preserved through restart has been done by both `rpc_setban` and `p2p_disconnect_ban`. Since `p2p_disconnect_ban` does it in a more elegant way, we can keep only it and remove the duplicated one.
1 parent 71b6319 commit e30e862

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

test/functional/p2p_disconnect_ban.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def run_test(self):
7777
self.nodes[1].setmocktime(old_time)
7878
self.nodes[1].setban("127.0.0.0/32", "add")
7979
self.nodes[1].setban("127.0.0.0/24", "add")
80+
self.nodes[1].setban("pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion", "add")
8081
self.nodes[1].setban("192.168.0.1", "add", 1) # ban for 1 seconds
8182
self.nodes[1].setban("2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/19", "add", 1000) # ban for 1000 seconds
8283
listBeforeShutdown = self.nodes[1].listbanned()
@@ -85,13 +86,13 @@ def run_test(self):
8586
self.log.info("setban: test banning with absolute timestamp")
8687
self.nodes[1].setban("192.168.0.2", "add", old_time + 120, True)
8788

88-
# Move time forward by 3 seconds so the third ban has expired
89+
# Move time forward by 3 seconds so the fourth ban has expired
8990
self.nodes[1].setmocktime(old_time + 3)
90-
assert_equal(len(self.nodes[1].listbanned()), 4)
91+
assert_equal(len(self.nodes[1].listbanned()), 5)
9192

9293
self.log.info("Test ban_duration and time_remaining")
9394
for ban in self.nodes[1].listbanned():
94-
if ban["address"] in ["127.0.0.0/32", "127.0.0.0/24"]:
95+
if ban["address"] in ["127.0.0.0/32", "127.0.0.0/24", "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion"]:
9596
assert_equal(ban["ban_duration"], 86400)
9697
assert_equal(ban["time_remaining"], 86397)
9798
elif ban["address"] == "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/19":
@@ -108,6 +109,7 @@ def run_test(self):
108109
assert_equal("127.0.0.0/32", listAfterShutdown[1]['address'])
109110
assert_equal("192.168.0.2/32", listAfterShutdown[2]['address'])
110111
assert_equal("/19" in listAfterShutdown[3]['address'], True)
112+
assert_equal("pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion", listAfterShutdown[4]['address'])
111113

112114
# Clear ban lists
113115
self.nodes[1].clearbanned()

test/functional/rpc_setban.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,10 @@ def run_test(self):
6464
assert self.is_banned(node, tor_addr)
6565
assert not self.is_banned(node, ip_addr)
6666

67-
self.log.info("Test the ban list is preserved through restart")
68-
69-
self.restart_node(1)
70-
assert self.is_banned(node, tor_addr)
71-
assert not self.is_banned(node, ip_addr)
72-
7367
node.setban(tor_addr, "remove")
7468
assert not self.is_banned(self.nodes[1], tor_addr)
7569
assert not self.is_banned(node, ip_addr)
7670

77-
self.restart_node(1)
78-
assert not self.is_banned(node, tor_addr)
79-
assert not self.is_banned(node, ip_addr)
80-
8171
self.log.info("Test -bantime")
8272
self.restart_node(1, ["-bantime=1234"])
8373
self.nodes[1].setban("127.0.0.1", "add")

0 commit comments

Comments
 (0)