Moved a test script from network.tcp to tests.core

This commit is contained in:
Dmitri Bogomolov 2019-07-10 13:23:10 +03:00
parent 391b5ded87
commit bbab0010e6
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
2 changed files with 14 additions and 12 deletions

View File

@ -381,14 +381,3 @@ class TCPServer(AdvancedDispatcher):
TCPConnection(sock=sock))
except socket.error:
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

View File

@ -14,6 +14,8 @@ import unittest
import knownnodes
import state
from helper_msgcoding import MsgEncode, MsgDecode
from network import asyncore_pollchoose as asyncore
from network.tcp import TCPConnection
from queues import excQueue
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)
except Exception as e:
self.fail(
'Exception %s whyle trying to encode message'
'Exception %s while trying to encode message'
' 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):
with knownnodes.knownNodesLock:
knownnodes.knownNodes = {stream: {} for stream in range(1, 4)}