Skip to content

Commit 74dc858

Browse files
committed
Merge bitcoin/bitcoin#30174: test: Set mocktime in p2p_disconnect_ban.py to avoid intermittent test failure
4444de1 test: Set mocktime in p2p_disconnect_ban.py to avoid intermittent test failure (MarcoFalke) fa6aa40 test: Fix typos and use names args (MarcoFalke) Pull request description: Otherwise, the test may fail on slow hardware when running in valgrind. Also, use named args for the absolute timepoint, while touching this file. ACKs for top commit: tdb3: ACK for 4444de1 AngusP: re-ACK 4444de1 Tree-SHA512: 660269c8dd18887d69b284f38656899caf028159ce83ddf921f3e9c080a5d0e663989f0e42b4baf4c4939f20f34da0e7e844dff9b7c91d0cab570c60958bd0e1
2 parents 23b3dc2 + 4444de1 commit 74dc858

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/functional/p2p_disconnect_ban.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2014-2022 The Bitcoin Core developers
2+
# Copyright (c) 2014-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test node disconnect and ban behavior"""
@@ -18,7 +18,7 @@ def set_test_params(self):
1818
self.supports_cli = False
1919

2020
def run_test(self):
21-
self.log.info("Connect nodes both way")
21+
self.log.info("Connect nodes both ways")
2222
# By default, the test framework sets up an addnode connection from
2323
# node 1 --> node0. By connecting node0 --> node 1, we're left with
2424
# the two nodes being connected both ways.
@@ -84,7 +84,7 @@ def run_test(self):
8484
assert_equal("192.168.0.1/32", listBeforeShutdown[2]['address'])
8585

8686
self.log.info("setban: test banning with absolute timestamp")
87-
self.nodes[1].setban("192.168.0.2", "add", old_time + 120, True)
87+
self.nodes[1].setban("192.168.0.2", "add", old_time + 120, absolute=True)
8888

8989
# Move time forward by 3 seconds so the fourth ban has expired
9090
self.nodes[1].setmocktime(old_time + 3)
@@ -102,7 +102,9 @@ def run_test(self):
102102
assert_equal(ban["ban_duration"], 120)
103103
assert_equal(ban["time_remaining"], 117)
104104

105-
self.restart_node(1)
105+
# Keep mocktime, to avoid ban expiry when restart takes longer than
106+
# time_remaining
107+
self.restart_node(1, extra_args=[f"-mocktime={old_time+4}"])
106108

107109
listAfterShutdown = self.nodes[1].listbanned()
108110
assert_equal("127.0.0.0/24", listAfterShutdown[0]['address'])
@@ -113,7 +115,7 @@ def run_test(self):
113115

114116
# Clear ban lists
115117
self.nodes[1].clearbanned()
116-
self.log.info("Connect nodes both way")
118+
self.log.info("Connect nodes both ways")
117119
self.connect_nodes(0, 1)
118120
self.connect_nodes(1, 0)
119121

0 commit comments

Comments
 (0)