diff --git a/ntunnel.py b/ntunnel.py index d7350a8..cc3b9b3 100644 --- a/ntunnel.py +++ b/ntunnel.py @@ -518,8 +518,6 @@ class TestMain(unittest.TestCase): badclientkeypath = os.path.join(self.tempdir, 'badclient_key') await self.genkey(badclientkeypath) - await asyncio.sleep(.1) - # forwards connectsion to this socket (created by client) ptclientpath = os.path.join(self.tempdir, 'incclient.sock') ptclientstr = _makeunix(ptclientpath) @@ -560,8 +558,6 @@ class TestMain(unittest.TestCase): # wait for client to start await _awaitfile(ptclientpath) - await asyncio.sleep(.1) - # Connect to the client reader, writer = await connectsockstr(ptclientstr) @@ -588,9 +584,6 @@ class TestMain(unittest.TestCase): clientkeypath = os.path.join(self.tempdir, 'client_key') await self.genkey(clientkeypath) - await asyncio.sleep(.1) - #import pdb; pdb.set_trace() - # forwards connectsion to this socket (created by client) ptclientpath = os.path.join(self.tempdir, 'incclient.sock') ptclientstr = _makeunix(ptclientpath) @@ -633,8 +626,6 @@ class TestMain(unittest.TestCase): # wait for client to start await _awaitfile(ptclientpath) - await asyncio.sleep(.1) - # Connect to the client reader, writer = await connectsockstr(ptclientstr) @@ -781,8 +772,10 @@ class TestNoiseFowarder(unittest.TestCase): # Setup pt target listener pttarg = _makeunix(servptpath) ptsock = [] + ptsockevent = asyncio.Event() def ptsockaccept(reader, writer, ptsock=ptsock): ptsock.append((reader, writer)) + ptsockevent.set() # Bind to pt listener lsock = await listensockstr(pttarg, ptsockaccept) @@ -846,8 +839,8 @@ class TestNoiseFowarder(unittest.TestCase): writer.write(enclenfun(encmsg)) writer.write(encmsg) - # XXX - how to sync? - await asyncio.sleep(.1) + # wait for the connection to arrive + await ptsockevent.wait() ptreader, ptwriter = ptsock[0] # read the test message @@ -861,9 +854,6 @@ class TestNoiseFowarder(unittest.TestCase): writer.write(enclenfun(encmsg)) writer.write(encmsg) - # XXX - how to sync? - await asyncio.sleep(.1) - # read the test message rptmsg = await ptreader.readexactly(len(ptmsg))