Moved a test script from network.tcp to tests.core
This commit is contained in:
parent
391b5ded87
commit
bbab0010e6
|
@ -381,14 +381,3 @@ class TCPServer(AdvancedDispatcher):
|
||||||
TCPConnection(sock=sock))
|
TCPConnection(sock=sock))
|
||||||
except socket.error:
|
except socket.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
# initial fill
|
|
||||||
|
|
||||||
for host in (("127.0.0.1", 8448),):
|
|
||||||
direct = TCPConnection(host)
|
|
||||||
while asyncore.socket_map:
|
|
||||||
print "loop, state = %s" % (direct.state)
|
|
||||||
asyncore.loop(timeout=10, count=1)
|
|
||||||
continue
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ import unittest
|
||||||
import knownnodes
|
import knownnodes
|
||||||
import state
|
import state
|
||||||
from helper_msgcoding import MsgEncode, MsgDecode
|
from helper_msgcoding import MsgEncode, MsgDecode
|
||||||
|
from network import asyncore_pollchoose as asyncore
|
||||||
|
from network.tcp import TCPConnection
|
||||||
from queues import excQueue
|
from queues import excQueue
|
||||||
|
|
||||||
knownnodes_file = os.path.join(state.appdata, 'knownnodes.dat')
|
knownnodes_file = os.path.join(state.appdata, 'knownnodes.dat')
|
||||||
|
@ -74,10 +76,21 @@ class TestCore(unittest.TestCase):
|
||||||
MsgEncode({'body': 'A msg with no subject'}, 3)
|
MsgEncode({'body': 'A msg with no subject'}, 3)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.fail(
|
self.fail(
|
||||||
'Exception %s whyle trying to encode message'
|
'Exception %s while trying to encode message'
|
||||||
' with no subject!' % e
|
' with no subject!' % e
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_tcpconnection(self):
|
||||||
|
"""initial fill script from network.tcp"""
|
||||||
|
try:
|
||||||
|
for peer in (state.Peer("127.0.0.1", 8448),):
|
||||||
|
direct = TCPConnection(peer)
|
||||||
|
while asyncore.socket_map:
|
||||||
|
print("loop, state = %s" % direct.state)
|
||||||
|
asyncore.loop(timeout=10, count=1)
|
||||||
|
except:
|
||||||
|
self.fail('Exception in test loop')
|
||||||
|
|
||||||
def _wipe_knownnodes(self):
|
def _wipe_knownnodes(self):
|
||||||
with knownnodes.knownNodesLock:
|
with knownnodes.knownNodesLock:
|
||||||
knownnodes.knownNodes = {stream: {} for stream in range(1, 4)}
|
knownnodes.knownNodes = {stream: {} for stream in range(1, 4)}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user