Skip to content

Commit abccb27

Browse files
committed
test: add coverage for absolute timestamp in setban
1 parent b99f1f2 commit abccb27

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/functional/p2p_disconnect_ban.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ def run_test(self):
6969
self.nodes[1].setban("2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/19", "add", 1000) # ban for 1000 seconds
7070
listBeforeShutdown = self.nodes[1].listbanned()
7171
assert_equal("192.168.0.1/32", listBeforeShutdown[2]['address'])
72+
73+
self.log.info("setban: test banning with absolute timestamp")
74+
self.nodes[1].setban("192.168.0.2", "add", old_time + 120, True)
75+
7276
# Move time forward by 3 seconds so the third ban has expired
7377
self.nodes[1].setmocktime(old_time + 3)
74-
assert_equal(len(self.nodes[1].listbanned()), 3)
78+
assert_equal(len(self.nodes[1].listbanned()), 4)
7579

7680
self.log.info("Test ban_duration and time_remaining")
7781
for ban in self.nodes[1].listbanned():
@@ -81,13 +85,17 @@ def run_test(self):
8185
elif ban["address"] == "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/19":
8286
assert_equal(ban["ban_duration"], 1000)
8387
assert_equal(ban["time_remaining"], 997)
88+
elif ban["address"] == "192.168.0.2/32":
89+
assert_equal(ban["ban_duration"], 120)
90+
assert_equal(ban["time_remaining"], 117)
8491

8592
self.restart_node(1)
8693

8794
listAfterShutdown = self.nodes[1].listbanned()
8895
assert_equal("127.0.0.0/24", listAfterShutdown[0]['address'])
8996
assert_equal("127.0.0.0/32", listAfterShutdown[1]['address'])
90-
assert_equal("/19" in listAfterShutdown[2]['address'], True)
97+
assert_equal("192.168.0.2/32", listAfterShutdown[2]['address'])
98+
assert_equal("/19" in listAfterShutdown[3]['address'], True)
9199

92100
# Clear ban lists
93101
self.nodes[1].clearbanned()

0 commit comments

Comments
 (0)