Drop redundant imports and fix related code

This commit is contained in:
UdjinM6 2019-05-21 11:01:57 +03:00 committed by Pasta
parent 6f91144f22
commit 15fa1873d8
No known key found for this signature in database
GPG Key ID: 0B8EB7A31A44D9C6

View File

@ -12,7 +12,6 @@ import shutil
import tempfile
import time
from concurrent.futures import ThreadPoolExecutor
from time import time, sleep
from .util import (
assert_equal,
@ -551,7 +550,7 @@ class DashTestFramework(BitcoinTestFramework):
def wait_for_instantlock(self, txid, node):
# wait for instantsend locks
start = time()
start = time.time()
locked = False
while True:
try:
@ -562,17 +561,17 @@ class DashTestFramework(BitcoinTestFramework):
except:
# TX not received yet?
pass
if time() > start + 10:
if time.time() > start + 10:
break
sleep(0.5)
time.sleep(0.5)
return locked
def wait_for_sporks_same(self, timeout=30):
st = time()
while time() < st + timeout:
st = time.time()
while time.time() < st + timeout:
if self.check_sporks_same():
return
sleep(0.5)
time.sleep(0.5)
raise AssertionError("wait_for_sporks_same timed out")
def check_sporks_same(self):
@ -584,8 +583,8 @@ class DashTestFramework(BitcoinTestFramework):
return True
def wait_for_quorum_phase(self, phase, check_received_messages, check_received_messages_count, timeout=30):
t = time()
while time() - t < timeout:
t = time.time()
while time.time() - t < timeout:
all_ok = True
for mn in self.mninfo:
s = mn.node.quorum("dkgstatus")["session"]
@ -605,12 +604,12 @@ class DashTestFramework(BitcoinTestFramework):
break
if all_ok:
return
sleep(0.1)
time.sleep(0.1)
raise AssertionError("wait_for_quorum_phase timed out")
def wait_for_quorum_commitment(self, timeout = 15):
t = time()
while time() - t < timeout:
t = time.time()
while time.time() - t < timeout:
all_ok = True
for node in self.nodes:
s = node.quorum("dkgstatus")
@ -623,7 +622,7 @@ class DashTestFramework(BitcoinTestFramework):
break
if all_ok:
return
sleep(0.1)
time.sleep(0.1)
raise AssertionError("wait_for_quorum_commitment timed out")
def mine_quorum(self, expected_contributions=5, expected_complaints=0, expected_justifications=0, expected_commitments=5):
@ -640,7 +639,7 @@ class DashTestFramework(BitcoinTestFramework):
# Make sure all reached phase 1 (init)
self.wait_for_quorum_phase(1, None, 0)
# Give nodes some time to connect to neighbors
sleep(2)
time.sleep(2)
set_mocktime(get_mocktime() + 1)
set_node_times(self.nodes, get_mocktime())
self.nodes[0].generate(2)
@ -685,7 +684,7 @@ class DashTestFramework(BitcoinTestFramework):
set_node_times(self.nodes, get_mocktime())
self.nodes[0].generate(1)
while quorums == self.nodes[0].quorum("list"):
sleep(2)
time.sleep(2)
set_mocktime(get_mocktime() + 1)
set_node_times(self.nodes, get_mocktime())
self.nodes[0].generate(1)