Revert "Merge #10376: [tests] fix disconnect_ban intermittency"

This reverts commit b6b486c274.
This commit is contained in:
Pasta 2019-07-05 12:11:56 -05:00
parent b791821c80
commit de33753f06
No known key found for this signature in database
GPG Key ID: D362C9F7142766AE

View File

@ -3,7 +3,6 @@
# 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
@ -58,18 +57,13 @@ 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'])
set_mocktime(get_mocktime() + 2)
set_node_times(self.nodes, get_mocktime())
# 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)
assert wait_until(lambda: len(self.nodes[1].listbanned()) == 3, timeout=10)
self.stop_node(1)