diff options
author | John Newbery <john@johnnewbery.com> | 2017-05-09 17:20:24 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2017-05-09 17:20:24 -0400 |
commit | 3ba2c08980dddb3c109a144a818f23a9188426c3 (patch) | |
tree | 4f45707f07f5158a6efd2b3dcf81baee284b17fb /test | |
parent | 7ee523604851af62c0a47c07ee023a8710ef32f7 (diff) |
[tests] fix disconnect_ban intermittency
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/disconnect_ban.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/test/functional/disconnect_ban.py b/test/functional/disconnect_ban.py index 50d79db903..f453fc0261 100755 --- a/test/functional/disconnect_ban.py +++ b/test/functional/disconnect_ban.py @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test node disconnect and ban behavior""" +import time from test_framework.mininode import wait_until from test_framework.test_framework import BitcoinTestFramework @@ -56,11 +57,16 @@ class DisconnectBanTest(BitcoinTestFramework): self.log.info("setban: test persistence across node restart") self.nodes[1].setban("127.0.0.0/32", "add") self.nodes[1].setban("127.0.0.0/24", "add") + # Set the mocktime so we can control when bans expire + old_time = int(time.time()) + self.nodes[1].setmocktime(old_time) self.nodes[1].setban("192.168.0.1", "add", 1) # ban for 1 seconds self.nodes[1].setban("2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/19", "add", 1000) # ban for 1000 seconds listBeforeShutdown = self.nodes[1].listbanned() assert_equal("192.168.0.1/32", listBeforeShutdown[2]['address']) - assert wait_until(lambda: len(self.nodes[1].listbanned()) == 3, timeout=10) + # Move time forward by 3 seconds so the third ban has expired + self.nodes[1].setmocktime(old_time + 3) + assert_equal(len(self.nodes[1].listbanned()), 3) stop_node(self.nodes[1], 1) |