Compare commits
No commits in common. "aedf36cda2e079be430f37303cb097f7e026e273" and "8ab22f32bdd2b6a65c51003729d9becb8620220d" have entirely different histories.
aedf36cda2
...
8ab22f32bd
698
wrapper/tox.py
698
wrapper/tox.py
File diff suppressed because it is too large
Load Diff
@ -302,11 +302,6 @@ TOX_ERR_GROUP_JOIN = {
|
|||||||
'TOX_ERR_GROUP_JOIN_TOO_LONG': 3,
|
'TOX_ERR_GROUP_JOIN_TOO_LONG': 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
TOX_ERR_GROUP_IS_CONNECTED = {
|
|
||||||
'TOX_ERR_GROUP_IS_CONNECTED_OK': 0,
|
|
||||||
'TOX_ERR_GROUP_IS_CONNECTED_GROUP_NOT_FOUND': 1
|
|
||||||
}
|
|
||||||
|
|
||||||
TOX_ERR_GROUP_RECONNECT = {
|
TOX_ERR_GROUP_RECONNECT = {
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -456,7 +451,7 @@ TOX_ERR_GROUP_STATE_QUERIES = {
|
|||||||
#
|
#
|
||||||
'TOX_ERR_GROUP_STATE_QUERIES_OK': 0,
|
'TOX_ERR_GROUP_STATE_QUERIES_OK': 0,
|
||||||
|
|
||||||
#
|
#
|
||||||
# The group number passed did not designate a valid group.
|
# The group number passed did not designate a valid group.
|
||||||
#
|
#
|
||||||
'TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND': 1
|
'TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND': 1
|
||||||
|
@ -69,8 +69,7 @@ except ImportError as e:
|
|||||||
|
|
||||||
import wrapper
|
import wrapper
|
||||||
import wrapper.toxcore_enums_and_consts as enums
|
import wrapper.toxcore_enums_and_consts as enums
|
||||||
from wrapper.tox import Tox, UINT32_MAX, ToxError
|
from wrapper.tox import Tox
|
||||||
|
|
||||||
from wrapper.toxcore_enums_and_consts import (TOX_ADDRESS_SIZE, TOX_CONNECTION,
|
from wrapper.toxcore_enums_and_consts import (TOX_ADDRESS_SIZE, TOX_CONNECTION,
|
||||||
TOX_FILE_CONTROL,
|
TOX_FILE_CONTROL,
|
||||||
TOX_MESSAGE_TYPE,
|
TOX_MESSAGE_TYPE,
|
||||||
@ -280,6 +279,19 @@ class ToxSuite(unittest.TestCase):
|
|||||||
assert oTOX_OPTIONS
|
assert oTOX_OPTIONS
|
||||||
assert oTOX_OARGS
|
assert oTOX_OARGS
|
||||||
|
|
||||||
|
if not hasattr(cls, 'alice') and not hasattr(cls, 'bob'):
|
||||||
|
l = prepare(cls)
|
||||||
|
assert l
|
||||||
|
cls.bob, cls.alice = l
|
||||||
|
if not hasattr(cls.bob, '_main_loop'):
|
||||||
|
cls.bob._main_loop = ToxIterateThread(cls.bob)
|
||||||
|
cls.bob._main_loop.start()
|
||||||
|
LOG.debug(f"cls.bob._main_loop: ") # {threading.enumerate()}
|
||||||
|
if not hasattr(cls.alice, '_main_loop'):
|
||||||
|
cls.alice._main_loop = ToxIterateThread(cls.alice)
|
||||||
|
cls.alice._main_loop.start()
|
||||||
|
LOG.debug(f"cls.alice._main_loop: ") # {threading.enumerate()}
|
||||||
|
|
||||||
cls.lUdp = ts.generate_nodes(
|
cls.lUdp = ts.generate_nodes(
|
||||||
oArgs=oTOX_OARGS,
|
oArgs=oTOX_OARGS,
|
||||||
nodes_count=2*ts.iNODES,
|
nodes_count=2*ts.iNODES,
|
||||||
@ -292,56 +304,29 @@ class ToxSuite(unittest.TestCase):
|
|||||||
ipv='ipv4',
|
ipv='ipv4',
|
||||||
udp_not_tcp=False)
|
udp_not_tcp=False)
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
if hasattr(self, 'bob') and self.bob.self_get_friend_list_size() >= 1:
|
|
||||||
LOG.warn(f"tearDown BOBS STILL HAS A FRIEND LIST {self.bob.self_get_friend_list()}")
|
|
||||||
for elt in self.bob.self_get_friend_list(): self.bob.friend_delete(elt)
|
|
||||||
if hasattr(self, 'alice') and self.alice.self_get_friend_list_size() >= 1:
|
|
||||||
LOG.warn(f"tearDown ALICE STILL HAS A FRIEND LIST {self.alice.self_get_friend_list()}")
|
|
||||||
for elt in self.alice.self_get_friend_list(): self.alice.friend_delete(elt)
|
|
||||||
|
|
||||||
LOG.debug(f"tearDown threads={threading.active_count()}")
|
|
||||||
if hasattr(self, 'bob'):
|
|
||||||
bob.callback_self_connection_status(None)
|
|
||||||
if hasattr(self.bob, 'main_loop'):
|
|
||||||
self.bob._main_loop.stop_thread()
|
|
||||||
del self.bob._main_loop
|
|
||||||
# self.bob.kill()
|
|
||||||
del self.bob
|
|
||||||
if hasattr(self, 'alice'):
|
|
||||||
alice.callback_self_connection_status(None)
|
|
||||||
if hasattr(self.alice, 'main_loop'):
|
|
||||||
self.alice._main_loop.stop_thread()
|
|
||||||
del self.alice._main_loop
|
|
||||||
# self.alice.kill()
|
|
||||||
del self.alice
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
if hasattr(cls, 'bob'):
|
cls.bob._main_loop.stop_thread()
|
||||||
cls.bob._main_loop.stop_thread()
|
cls.alice._main_loop.stop_thread()
|
||||||
|
if False:
|
||||||
|
cls.alice.kill()
|
||||||
cls.bob.kill()
|
cls.bob.kill()
|
||||||
del cls.bob
|
del cls.bob
|
||||||
if hasattr(cls, 'alice'):
|
|
||||||
cls.alice._main_loop.stop_thread()
|
|
||||||
cls.alice.kill()
|
|
||||||
del cls.alice
|
del cls.alice
|
||||||
|
|
||||||
def bBobNeedAlice(self):
|
def bBobSetUp(self):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
if hasattr(self, 'baid') and self.baid >= 0 and \
|
if hasattr(self, 'baid') and self.baid >= 0 and \
|
||||||
self.baid in self.bob.self_get_friend_list():
|
self.baid in self.bob.self_get_friend_list():
|
||||||
LOG.warn(f"setUp ALICE IS ALREADY IN BOBS FRIEND LIST")
|
LOG.warn(f"setUp ALICE IS ALREADY IN BOBS FRIEND LIST")
|
||||||
return False
|
return False
|
||||||
elif self.bob.self_get_friend_list_size() >= 1:
|
elif self.bob.self_get_friend_list_size() >= 1:
|
||||||
LOG.warn(f"setUp BOB STILL HAS A FRIEND LIST")
|
LOG.warn(f"setUp BOB STILL HAS A FRIEND LIST")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def bAliceNeedAddBob (self):
|
def bAliceSetUp(self):
|
||||||
if hasattr(self, 'abid') and self.abid >= 0 and \
|
if hasattr(self, 'abid') and self.abid >= 0 and \
|
||||||
self.abid in self.alice.self_get_friend_list():
|
self.abid in self.alice.self_get_friend_list():
|
||||||
LOG.warn(f"setUp BOB IS ALREADY IN ALICES FRIEND LIST")
|
LOG.warn(f"setUp BOB IS ALREADY IN ALICES FRIEND LIST")
|
||||||
@ -352,22 +337,18 @@ class ToxSuite(unittest.TestCase):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
cls = self
|
self.bBobSetUp()
|
||||||
if not hasattr(cls, 'alice') and not hasattr(cls, 'bob'):
|
self.bAliceSetUp()
|
||||||
l = prepare(cls)
|
|
||||||
assert l
|
|
||||||
cls.bob, cls.alice = l
|
|
||||||
if not hasattr(cls.bob, '_main_loop'):
|
|
||||||
#? cls.bob._main_loop = ToxIterateThread(cls.bob)
|
|
||||||
#? cls.bob._main_loop.start()
|
|
||||||
LOG.debug(f"cls.bob._main_loop: ") # {threading.enumerate()}
|
|
||||||
if not hasattr(cls.alice, '_main_loop'):
|
|
||||||
#? cls.alice._main_loop = ToxIterateThread(cls.alice)
|
|
||||||
#? cls.alice._main_loop.start()
|
|
||||||
LOG.debug(f"cls.alice._main_loop: ") # {threading.enumerate()}
|
|
||||||
|
|
||||||
self.bBobNeedAlice()
|
def tearDown(self):
|
||||||
self.bAliceNeedAddBob()
|
"""
|
||||||
|
"""
|
||||||
|
if self.bob.self_get_friend_list_size() >= 1:
|
||||||
|
LOG.warn(f"tearDown BOBS STILL HAS A FRIEND LIST {self.bob.self_get_friend_list()}")
|
||||||
|
for elt in self.bob.self_get_friend_list(): self.bob.friend_delete(elt)
|
||||||
|
if self.bob.self_get_friend_list_size() >= 1:
|
||||||
|
LOG.warn(f"tearDown ALICE STILL HAS A FRIEND LIST {self.alice.self_get_friend_list()}")
|
||||||
|
for elt in self.alice.self_get_friend_list(): self.alice.friend_delete(elt)
|
||||||
|
|
||||||
def run(self, result=None):
|
def run(self, result=None):
|
||||||
""" Stop after first error """
|
""" Stop after first error """
|
||||||
@ -423,44 +404,6 @@ class ToxSuite(unittest.TestCase):
|
|||||||
LOG.debug(f"call_bootstrap ts.bootstrap_tcp {len(lElts)}")
|
LOG.debug(f"call_bootstrap ts.bootstrap_tcp {len(lElts)}")
|
||||||
ts.bootstrap_tcp(lElts, lToxes)
|
ts.bootstrap_tcp(lElts, lToxes)
|
||||||
|
|
||||||
def group_until_connected(self, group_number, num=None, iMax=THRESHOLD):
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
i = 0
|
|
||||||
bRet = None
|
|
||||||
while i <= iMax :
|
|
||||||
iRet = self.bob.group_is_connected(group_number)
|
|
||||||
if iRet == True or iRet == 0:
|
|
||||||
bRet = True
|
|
||||||
break
|
|
||||||
if i % 5 == 0:
|
|
||||||
j = i//5
|
|
||||||
self.call_bootstrap(num, lToxes=None, i=j)
|
|
||||||
s = ''
|
|
||||||
if i == 0: s = '\n'
|
|
||||||
LOG.info(s+"group_until_connected " \
|
|
||||||
+" #" + str(i) \
|
|
||||||
+" iRet=" +repr(iRet) \
|
|
||||||
+f" BOBS={self.bob.mycon_status}" \
|
|
||||||
+f" last={int(self.bob.mycon_time)}" )
|
|
||||||
i += 1
|
|
||||||
self.loop(100)
|
|
||||||
else:
|
|
||||||
bRet = False
|
|
||||||
|
|
||||||
if bRet:
|
|
||||||
LOG.info(f"group_until_connected returning True {i}" \
|
|
||||||
+f"iMax={iMax}" \
|
|
||||||
+f" BOB={self.bob.self_get_connection_status()}" \
|
|
||||||
+f" last={int(self.bob.mycon_time)}" )
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
LOG.warning(f"group_until_connected returning False {i}" \
|
|
||||||
+f"iMax={iMax}" \
|
|
||||||
+f" BOB={self.bob.self_get_connection_status()}" \
|
|
||||||
+f" last={int(self.bob.mycon_time)}" )
|
|
||||||
return False
|
|
||||||
|
|
||||||
def loop_until_connected(self, num=None):
|
def loop_until_connected(self, num=None):
|
||||||
"""
|
"""
|
||||||
t:on_self_connection_status
|
t:on_self_connection_status
|
||||||
@ -534,7 +477,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
return all([getattr(obj, attr) is not None for obj in objs])
|
return all([getattr(obj, attr) is not None for obj in objs])
|
||||||
|
|
||||||
def wait_otox_attrs(self, obj, attrs):
|
def wait_otox_attrs(self, obj, attrs):
|
||||||
assert all(attrs), f"wait_otox_attrs {attrs}"
|
assert all(attrs)
|
||||||
i = 0
|
i = 0
|
||||||
while i <= THRESHOLD:
|
while i <= THRESHOLD:
|
||||||
if i % 5 == 0:
|
if i % 5 == 0:
|
||||||
@ -552,7 +495,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
self.loop(100)
|
self.loop(100)
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
LOG.warning(f"wait_otox_attrs i >= {THRESHOLD} results={[getattr(obj, attr) for attr in attrs]}")
|
LOG.warning(f"wait_otox_attrs i >= {THRESHOLD} {[getattr(obj, attr) for attr in attrs]}")
|
||||||
|
|
||||||
return all([getattr(obj, attr) for attr in attrs])
|
return all([getattr(obj, attr) for attr in attrs])
|
||||||
|
|
||||||
@ -588,7 +531,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
return oRet
|
return oRet
|
||||||
|
|
||||||
def bob_add_alice_as_friend_norequest(self):
|
def bob_add_alice_as_friend_norequest(self):
|
||||||
if not self.bBobNeedAlice(): return True
|
if not self.bBobSetUp(): return True
|
||||||
|
|
||||||
MSG = 'Hi, this is Bob.'
|
MSG = 'Hi, this is Bob.'
|
||||||
iRet = self.bob.friend_add_norequest(self.alice._address)
|
iRet = self.bob.friend_add_norequest(self.alice._address)
|
||||||
@ -603,7 +546,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def alice_add_bob_as_friend_norequest(self):
|
def alice_add_bob_as_friend_norequest(self):
|
||||||
if not self.bAliceNeedAddBob(): return True
|
if not self.bAliceSetUp(): return True
|
||||||
|
|
||||||
iRet = self.alice.friend_add_norequest(self.bob._address)
|
iRet = self.alice.friend_add_norequest(self.bob._address)
|
||||||
if iRet < 0:
|
if iRet < 0:
|
||||||
@ -616,23 +559,10 @@ class ToxSuite(unittest.TestCase):
|
|||||||
assert self.alice.self_get_friend_list_size() >= 1
|
assert self.alice.self_get_friend_list_size() >= 1
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def both_add_as_friend(self):
|
|
||||||
if bUSE_NOREQUEST:
|
|
||||||
assert self.bob_add_alice_as_friend()
|
|
||||||
assert self.alice_add_bob_as_friend_norequest()
|
|
||||||
else:
|
|
||||||
assert self.bob_add_alice_as_friend_norequest()
|
|
||||||
assert self.alice_add_bob_as_friend_norequest()
|
|
||||||
if not hasattr(self, 'baid') or self.baid < 0:
|
|
||||||
LOG.warn("both_add_as_friend no bob, baid")
|
|
||||||
if not hasattr(self, 'abid') or self.abid < 0:
|
|
||||||
LOG.warn("both_add_as_friend no alice, abid")
|
|
||||||
return True
|
|
||||||
|
|
||||||
def both_add_as_friend_norequest(self):
|
def both_add_as_friend_norequest(self):
|
||||||
if self.bBobNeedAlice():
|
if self.bBobSetUp():
|
||||||
assert self.bob_add_alice_as_friend_norequest()
|
assert self.bob_add_alice_as_friend_norequest()
|
||||||
if self.bAliceNeedAddBob():
|
if self.bAliceSetUp():
|
||||||
assert self.alice_add_bob_as_friend_norequest()
|
assert self.alice_add_bob_as_friend_norequest()
|
||||||
if not hasattr(self, 'baid') or self.baid < 0:
|
if not hasattr(self, 'baid') or self.baid < 0:
|
||||||
LOG.warn("both_add_as_friend_norequest no bob, baid")
|
LOG.warn("both_add_as_friend_norequest no bob, baid")
|
||||||
@ -652,7 +582,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
MSG = 'Alice, this is Bob.'
|
MSG = 'Alice, this is Bob.'
|
||||||
sSlot = 'friend_request'
|
sSlot = 'friend_request'
|
||||||
if not self.bBobNeedAlice(): return True
|
if not self.bBobSetUp(): return True
|
||||||
|
|
||||||
def alices_on_friend_request(iTox,
|
def alices_on_friend_request(iTox,
|
||||||
public_key,
|
public_key,
|
||||||
@ -670,10 +600,11 @@ class ToxSuite(unittest.TestCase):
|
|||||||
|
|
||||||
setattr(self.bob, sSlot, None)
|
setattr(self.bob, sSlot, None)
|
||||||
inum = -1
|
inum = -1
|
||||||
|
self.alice.callback_friend_request(alices_on_friend_request)
|
||||||
try:
|
try:
|
||||||
inum = self.bob.friend_add(self.alice._address, bytes(MSG, 'UTF-8'))
|
inum = self.bob.friend_add(self.alice._address, bytes(MSG, 'UTF-8'))
|
||||||
assert inum >= 0, f"bob.friend_add !>= 0 {inum}"
|
if inum < 0:
|
||||||
self.alice.callback_friend_request(alices_on_friend_request)
|
LOG.warning('bob.friend_add !>= 0 ' +repr(inum))
|
||||||
if not self.wait_otox_attrs(self.bob, [sSlot]):
|
if not self.wait_otox_attrs(self.bob, [sSlot]):
|
||||||
LOG_WARN(f"bob.friend_add NO {sSlot}")
|
LOG_WARN(f"bob.friend_add NO {sSlot}")
|
||||||
# return False
|
# return False
|
||||||
@ -699,7 +630,18 @@ class ToxSuite(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
MSG = 'Bob, this is Alice.'
|
MSG = 'Bob, this is Alice.'
|
||||||
sSlot = 'friend_request'
|
sSlot = 'friend_request'
|
||||||
if not self.bAliceNeedAddBob(): return True
|
if not self.bAliceSetUp(): return True
|
||||||
|
|
||||||
|
try:
|
||||||
|
abid = self.alice.friend_by_public_key(self.bob._address)
|
||||||
|
except Exception as e:
|
||||||
|
# ctypes.ArgumentError
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if abid and abid >= 0 and \
|
||||||
|
abid in self.alice.self_get_friend_list():
|
||||||
|
LOG.warning('alice friend exists ' +repr(abid))
|
||||||
|
return True
|
||||||
|
|
||||||
def bobs_on_friend_request(iTox,
|
def bobs_on_friend_request(iTox,
|
||||||
public_key,
|
public_key,
|
||||||
@ -717,10 +659,11 @@ class ToxSuite(unittest.TestCase):
|
|||||||
|
|
||||||
setattr(self.alice, sSlot, None)
|
setattr(self.alice, sSlot, None)
|
||||||
inum = -1
|
inum = -1
|
||||||
|
self.bob.callback_friend_request(bobs_on_friend_request)
|
||||||
try:
|
try:
|
||||||
inum = self.alice.friend_add(self.bob._address, bytes(MSG, 'UTF-8'))
|
inum = self.alice.friend_add(self.bob._address, bytes(MSG, 'UTF-8'))
|
||||||
assert inum >= 0, f"alice.friend_add !>= 0 {inum}"
|
if not inum >= 0:
|
||||||
self.bob.callback_friend_request(bobs_on_friend_request)
|
LOG.warning('alice.friend_add !>= 0 ' +repr(inum))
|
||||||
if not self.wait_otox_attrs(self.alice, [sSlot]):
|
if not self.wait_otox_attrs(self.alice, [sSlot]):
|
||||||
LOG_WARN(f"alice.friend_add NO wait {sSlot}")
|
LOG_WARN(f"alice.friend_add NO wait {sSlot}")
|
||||||
#? return False
|
#? return False
|
||||||
@ -737,6 +680,11 @@ class ToxSuite(unittest.TestCase):
|
|||||||
self.bob.callback_friend_message(None)
|
self.bob.callback_friend_message(None)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def both_add_as_friend(self):
|
||||||
|
assert self.bob_add_alice_as_friend()
|
||||||
|
assert self.alice_add_bob_as_friend_norequest()
|
||||||
|
return True
|
||||||
|
|
||||||
def bob_add_alice_as_friend_and_status(self):
|
def bob_add_alice_as_friend_and_status(self):
|
||||||
if bUSE_NOREQUEST:
|
if bUSE_NOREQUEST:
|
||||||
assert self.bob_add_alice_as_friend_norequest()
|
assert self.bob_add_alice_as_friend_norequest()
|
||||||
@ -744,8 +692,8 @@ class ToxSuite(unittest.TestCase):
|
|||||||
assert self.bob_add_alice_as_friend()
|
assert self.bob_add_alice_as_friend()
|
||||||
|
|
||||||
#: Wait until both are online
|
#: Wait until both are online
|
||||||
sSlot = 'friend_conn_status'
|
sSlot = friend_conn_status
|
||||||
setattr(self.bob, sSlot, False)
|
self.bob.friend_conn_status = False
|
||||||
def bobs_on_friend_connection_status(iTox, friend_id, iStatus, *largs):
|
def bobs_on_friend_connection_status(iTox, friend_id, iStatus, *largs):
|
||||||
LOG_INFO(f"bobs_on_friend_connection_status {friend_id} ?>=0" +repr(iStatus))
|
LOG_INFO(f"bobs_on_friend_connection_status {friend_id} ?>=0" +repr(iStatus))
|
||||||
if iStatus > 0:
|
if iStatus > 0:
|
||||||
@ -813,7 +761,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def otox_test_groups_create(self,
|
def otox_test_groups(self,
|
||||||
otox,
|
otox,
|
||||||
group_name='test_group',
|
group_name='test_group',
|
||||||
nick='test_nick',
|
nick='test_nick',
|
||||||
@ -829,80 +777,23 @@ class ToxSuite(unittest.TestCase):
|
|||||||
assert otox.group_get_topic(iGrp) == topic
|
assert otox.group_get_topic(iGrp) == topic
|
||||||
assert otox.group_get_topic_size(iGrp) == len(topic)
|
assert otox.group_get_topic_size(iGrp) == len(topic)
|
||||||
|
|
||||||
name = otox.group_get_name(iGrp)
|
assert otox.group_get_name(iGrp) == group_name
|
||||||
if type(name) == bytes: name = str(name, 'utf-8')
|
|
||||||
assert name == group_name, name
|
|
||||||
assert otox.group_get_name_size(iGrp) == len(group_name)
|
assert otox.group_get_name_size(iGrp) == len(group_name)
|
||||||
|
|
||||||
sPk = otox.group_self_get_public_key(iGrp)
|
sPk = otox.group_self_get_public_key(iGrp)
|
||||||
|
LOG.info(f"group pK={sPk}")
|
||||||
assert otox.group_get_password_size(iGrp) >= 0
|
assert otox.group_get_password_size(iGrp) >= 0
|
||||||
sP = otox.group_get_password(iGrp)
|
sP = otox.group_get_password(iGrp)
|
||||||
assert otox.group_get_privacy_state(iGrp) == privacy_state
|
assert otox.group_get_privacy_state(iGrp) == privacy_state
|
||||||
|
|
||||||
assert otox.group_get_number_groups() > 0
|
assert otox.group_get_number_groups() > 0
|
||||||
LOG.info(f"group pK={sPk} iGrp={iGrp} n={otox.group_get_number_groups()}")
|
|
||||||
return iGrp
|
|
||||||
|
|
||||||
# 360497DA684BCE2A500C1AF9B3A5CE949BBB9F6FB1F91589806FB04CA039E313
|
|
||||||
# 75D2163C19FEFFE51508046398202DDC321E6F9B6654E99BAE45FFEC134F05DE
|
|
||||||
def otox_test_groups_join(self, otox,
|
|
||||||
chat_id="75d2163c19feffe51508046398202ddc321e6f9b6654e99bae45ffec134f05de",
|
|
||||||
nick='nick',
|
|
||||||
topic='Test Topic', # str
|
|
||||||
):
|
|
||||||
status = ''
|
|
||||||
password = ''
|
|
||||||
LOG.debug(f"group_join nick={nick} chat_id={chat_id}")
|
|
||||||
try:
|
|
||||||
group_number = otox.group_join(chat_id, password, nick, status)
|
|
||||||
LOG.info(f"otox_test_groups_join SUCCESS group_number={group_number} chat_id={chat_id}")
|
|
||||||
assert type(group_number) == int, "otox_test_groups_join group_number not an int"
|
|
||||||
assert group_number < UINT32_MAX, "otox_test_groups_join group_number failure UINT32_MAX"
|
|
||||||
assert group_number >= 0, f"otox_test_groups_join group_number={group_number} < 0"
|
|
||||||
iGrp = group_number
|
|
||||||
sPk = otox.group_self_get_public_key(iGrp)
|
|
||||||
LOG.info(f"otox_test_groups_join pK={sPk} iGrp={iGrp} n={otox.group_get_number_groups()}")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
# gui
|
|
||||||
LOG.error(f"otox_test_groups_join EXCEPTION {e}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
try:
|
|
||||||
bRet = otox.group_is_connected(group_number)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error(f"group_is_connected EXCEPTION {e}")
|
|
||||||
return -1
|
|
||||||
# chat->connection_state == CS_CONNECTED || chat->connection_state == CS_CONNECTING;
|
|
||||||
if bRet:
|
|
||||||
LOG.warn(f"group_is_connected WARN not connected group_number={group_number} n={otox.group_get_number_groups()}")
|
|
||||||
else:
|
|
||||||
LOG.info(f"group_is_connected SUCCESS connected group_number={group_number} n={otox.group_get_number_groups()}")
|
|
||||||
|
|
||||||
try:
|
|
||||||
bRet = self.group_until_connected(group_number, iMax=2*THRESHOLD)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error(f"group_until_connected EXCEPTION {e}")
|
|
||||||
return -1
|
|
||||||
# chat->connection_state == CS_CONNECTED || chat->connection_state == CS_CONNECTING;
|
|
||||||
if bRet:
|
|
||||||
LOG.warn(f"group_until_connected WARN not connected group_number={group_number} n={otox.group_get_number_groups()}")
|
|
||||||
else:
|
|
||||||
LOG.info(f"group_until_connected SUCCESS connected group_number={group_number} n={otox.group_get_number_groups()}")
|
|
||||||
|
|
||||||
return group_number
|
|
||||||
|
|
||||||
def otox_test_groups(self,
|
|
||||||
otox,
|
|
||||||
group_name='test_group',
|
|
||||||
nick='test_nick',
|
|
||||||
topic='Test Topic', # str
|
|
||||||
):
|
|
||||||
iGrp = self.otox_test_groups_create(otox, group_name, nick, topic)
|
|
||||||
sGrp = otox.group_get_chat_id(iGrp)
|
sGrp = otox.group_get_chat_id(iGrp)
|
||||||
assert len(sGrp) == enums.TOX_GROUP_CHAT_ID_SIZE * 2, \
|
if len(sGrp) != enums.TOX_GROUP_CHAT_ID_SIZE * 2:
|
||||||
f"group sGrp={sGrp} {len(sGrp)} != {enums.TOX_GROUP_CHAT_ID_SIZE * 2}"
|
LOG.error(f"group sGrp={sGrp} {len(sGrp)}")
|
||||||
LOG.info(f"group sGrp={sGrp}")
|
return iGrp
|
||||||
|
else:
|
||||||
|
LOG.info(f"group sGrp={sGrp}")
|
||||||
if False:
|
if False:
|
||||||
# already joined
|
# already joined
|
||||||
try:
|
try:
|
||||||
@ -921,29 +812,23 @@ class ToxSuite(unittest.TestCase):
|
|||||||
#?
|
#?
|
||||||
group_number = iGrp
|
group_number = iGrp
|
||||||
try:
|
try:
|
||||||
bRet = otox.group_is_connected(group_number)
|
iRet = otox.group_is_connected(group_number)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error(f"group_is_connected ERROR {e}")
|
LOG.error(f"group_is_connected ERROR {e}")
|
||||||
return -1
|
iRet = -1
|
||||||
|
|
||||||
try:
|
|
||||||
bRet = self.group_until_connected(group_number, iMax=2*THRESHOLD)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error(f"group_until_connected EXCEPTION {e}")
|
|
||||||
return -1
|
|
||||||
# chat->connection_state == CS_CONNECTED || chat->connection_state == CS_CONNECTING;
|
|
||||||
if bRet:
|
|
||||||
LOG.warn(f"group_until_connected WARN not connected group_number={group_number} n={otox.group_get_number_groups()}")
|
|
||||||
else:
|
else:
|
||||||
LOG.info(f"group_until_connected SUCCESS connected group_number={group_number} n={otox.group_get_number_groups()}")
|
if iRet != enums.TOX_ERR_GROUP_STATE_QUERIES['TOX_ERR_GROUP_STATE_QUERIES_OK']:
|
||||||
|
LOG.warn(f"group_is_connected WARN iRet={iRet}")
|
||||||
|
# The group number passed did not designate a valid group.
|
||||||
|
# TOX_ERR_GROUP_STATE_QUERIES['TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND']
|
||||||
|
if iRet < 0:
|
||||||
|
return iGrp
|
||||||
|
|
||||||
message = bytes('hello', 'utf-8')
|
message = bytes('hello', 'utf-8')
|
||||||
try:
|
try:
|
||||||
bRet = otox.group_send_message(group_number, TOX_MESSAGE_TYPE['NORMAL'], 'hello')
|
bRet = otox.group_send_message(group_number, TOX_MESSAGE_TYPE['NORMAL'], 'hello')
|
||||||
if not bRet:
|
if not bRet:
|
||||||
LOG.warn(f"group_send_message {bRet}")
|
LOG.warn(f"group_send_message {bRet}")
|
||||||
else:
|
|
||||||
LOG.debug(f"group_send_message {bRet}")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error(f"group_send_message ERROR {e}")
|
LOG.error(f"group_send_message ERROR {e}")
|
||||||
|
|
||||||
@ -961,14 +846,14 @@ class ToxSuite(unittest.TestCase):
|
|||||||
while i < n:
|
while i < n:
|
||||||
iRet = otox.friend_get_connection_status(fid)
|
iRet = otox.friend_get_connection_status(fid)
|
||||||
if iRet == TOX_CONNECTION['NONE']:
|
if iRet == TOX_CONNECTION['NONE']:
|
||||||
# LOG.debug(f"wait_friend_get_connection_status NOT CONNECTED i={i} {iRet}")
|
LOG.warning(f"wait_friend_get_connection_status NOT CONNECTED i={i} {iRet}")
|
||||||
self.loop_until_connected()
|
self.loop_until_connected()
|
||||||
else:
|
else:
|
||||||
LOG.info("wait_friend_get_connection_status {iRet}")
|
LOG.info("wait_friend_get_connection_status {iRet}")
|
||||||
return True
|
return True
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
LOG.error(f"wait_friend_get_connection_status n={n}")
|
LOG.error("wait_friend_get_connection_status n={n}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def warn_if_no_cb(self, alice, sSlot):
|
def warn_if_no_cb(self, alice, sSlot):
|
||||||
@ -1050,6 +935,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
LOG.warning(f"bootstrap_local_netstat NOT {port} iStatus={iStatus}")
|
LOG.warning(f"bootstrap_local_netstat NOT {port} iStatus={iStatus}")
|
||||||
|
|
||||||
|
#?? @unittest.skipIf(not bIS_LOCAL, "local test")
|
||||||
def test_bootstrap_local(self): # works
|
def test_bootstrap_local(self): # works
|
||||||
"""
|
"""
|
||||||
t:call_bootstrap
|
t:call_bootstrap
|
||||||
@ -1289,12 +1175,6 @@ class ToxSuite(unittest.TestCase):
|
|||||||
if hasattr(self, 'baid') and self.baid >= 0:
|
if hasattr(self, 'baid') and self.baid >= 0:
|
||||||
self.bob.friend_delete(self.baid)
|
self.bob.friend_delete(self.baid)
|
||||||
|
|
||||||
@unittest.skip('unfinished')
|
|
||||||
def test_alice_add_bob_as_friend_and_status(self):
|
|
||||||
assert self.alice_add_bob_as_friend_and_status()
|
|
||||||
if hasattr(self, 'abid') and self.abid >= 0:
|
|
||||||
self.alice.friend_delete(self.abid)
|
|
||||||
|
|
||||||
def test_loop_until_connected(self): # works
|
def test_loop_until_connected(self): # works
|
||||||
assert self.loop_until_connected()
|
assert self.loop_until_connected()
|
||||||
|
|
||||||
@ -1320,10 +1200,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
|
|
||||||
def test_bob_add_alice_as_friend(self): # works?
|
def test_bob_add_alice_as_friend(self): # works?
|
||||||
try:
|
try:
|
||||||
if bUSE_NOREQUEST:
|
assert self.bob_add_alice_as_friend()
|
||||||
assert self.bob_add_alice_as_friend_norequest()
|
|
||||||
else:
|
|
||||||
assert self.bob_add_alice_as_friend()
|
|
||||||
#: Test last online
|
#: Test last online
|
||||||
assert self.bob.friend_get_last_online(self.baid) is not None
|
assert self.bob.friend_get_last_online(self.baid) is not None
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
@ -1340,10 +1217,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
|
|
||||||
def test_alice_add_bob_as_friend(self): # works!
|
def test_alice_add_bob_as_friend(self): # works!
|
||||||
try:
|
try:
|
||||||
if bUSE_NOREQUEST:
|
assert self.alice_add_bob_as_friend()
|
||||||
assert self.alice_add_bob_as_friend_norequest()
|
|
||||||
else:
|
|
||||||
assert self.alice_add_bob_as_friend()
|
|
||||||
#: Test last online
|
#: Test last online
|
||||||
assert self.alice.friend_get_last_online(self.abid) is not None
|
assert self.alice.friend_get_last_online(self.abid) is not None
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
@ -1364,12 +1238,13 @@ class ToxSuite(unittest.TestCase):
|
|||||||
if len(self.alice.self_get_friend_list()) > 0:
|
if len(self.alice.self_get_friend_list()) > 0:
|
||||||
LOG.warn(f"WTF alice.self_get_friend_list() {alice.self_get_friend_list()}")
|
LOG.warn(f"WTF alice.self_get_friend_list() {alice.self_get_friend_list()}")
|
||||||
|
|
||||||
|
# @unittest.skip('crashes double free or corruption (fasttop)') on update
|
||||||
|
# @expectedFailure # fails
|
||||||
|
#? @unittest.skip('malloc(): unaligned tcache chunk detected')
|
||||||
|
#?? @unittest.skip('segv')
|
||||||
def test_both_add_as_friend(self): # works
|
def test_both_add_as_friend(self): # works
|
||||||
try:
|
try:
|
||||||
if bUSE_NOREQUEST:
|
assert self.both_add_as_friend()
|
||||||
assert self.both_add_as_friend_norequest()
|
|
||||||
else:
|
|
||||||
assert self.both_add_as_friend()
|
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
LOG.warn(f"Failed test {e}")
|
LOG.warn(f"Failed test {e}")
|
||||||
raise
|
raise
|
||||||
@ -1382,30 +1257,6 @@ class ToxSuite(unittest.TestCase):
|
|||||||
if hasattr(self,'abid') and self.abid >= 0:
|
if hasattr(self,'abid') and self.abid >= 0:
|
||||||
self.alice.friend_delete(self.abid)
|
self.alice.friend_delete(self.abid)
|
||||||
|
|
||||||
def test_groups_join(self):
|
|
||||||
"""
|
|
||||||
t:group_join
|
|
||||||
t:group_disconnect
|
|
||||||
t:group_leave
|
|
||||||
"""
|
|
||||||
if not self.get_connection_status():
|
|
||||||
LOG.warning(f"test_groups_join NOT CONNECTED")
|
|
||||||
self.loop_until_connected()
|
|
||||||
|
|
||||||
iGrp = self.otox_test_groups_join(self.bob)
|
|
||||||
LOG.info(f"test_groups_join iGrp={iGrp}")
|
|
||||||
assert iGrp >= 0, f"test_groups_join iGrp={iGrp}"
|
|
||||||
try:
|
|
||||||
self.bob.group_disconnect(iGrp)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error(f"bob.group_disconnect EXCEPTION {e}")
|
|
||||||
raise
|
|
||||||
try:
|
|
||||||
self.bob.group_leave(iGrp, None)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error(f"bob.group_leave EXCEPTION {e}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
def test_groups(self):
|
def test_groups(self):
|
||||||
"""
|
"""
|
||||||
t:group_new
|
t:group_new
|
||||||
@ -1427,6 +1278,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
t:group_invite_accept
|
t:group_invite_accept
|
||||||
t:group_invite_friend
|
t:group_invite_friend
|
||||||
t:group_is_connected
|
t:group_is_connected
|
||||||
|
t:group_join
|
||||||
t:group_leave
|
t:group_leave
|
||||||
t:group_mod_set_role
|
t:group_mod_set_role
|
||||||
"""
|
"""
|
||||||
@ -1444,8 +1296,12 @@ class ToxSuite(unittest.TestCase):
|
|||||||
LOG.error(f"bob.group_leave EXCEPTION {e}")
|
LOG.error(f"bob.group_leave EXCEPTION {e}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@unittest.skip("double free or corruption (fasttop)")
|
@unittest.skip('unfinished')
|
||||||
# @expectedFail('fails') # assertion fails on == MSG
|
def test_bob_add_alice_as_friend_and_status(self):
|
||||||
|
assert self.bob_add_alice_as_friend_and_status()
|
||||||
|
if hasattr(self, 'baid') and self.baid >= 0:
|
||||||
|
self.bob.friend_delete(self.baid)
|
||||||
|
|
||||||
def test_on_friend_status_message(self): # fails
|
def test_on_friend_status_message(self): # fails
|
||||||
"""
|
"""
|
||||||
t:self_set_status_message
|
t:self_set_status_message
|
||||||
@ -1501,6 +1357,10 @@ class ToxSuite(unittest.TestCase):
|
|||||||
if hasattr(self, 'abid') and self.abid >= 0:
|
if hasattr(self, 'abid') and self.abid >= 0:
|
||||||
self.alice.friend_delete(self.abid)
|
self.alice.friend_delete(self.abid)
|
||||||
|
|
||||||
|
#? @unittest.skip('malloc(): unaligned tcache chunk detected')
|
||||||
|
#? @unittest.skip('double free or corruption (fasttop)')
|
||||||
|
#?segv after TestS DEBUG wait_otox_attrs alice for ['friend_request'] 0 last=1701822930
|
||||||
|
#?? @unittest.skip('segv')
|
||||||
def test_friend(self): # works! sometimes
|
def test_friend(self): # works! sometimes
|
||||||
"""
|
"""
|
||||||
t:friend_get_name
|
t:friend_get_name
|
||||||
@ -1539,7 +1399,8 @@ class ToxSuite(unittest.TestCase):
|
|||||||
if hasattr(self, 'abid') and self.abid >= 0:
|
if hasattr(self, 'abid') and self.abid >= 0:
|
||||||
self.alice.friend_delete(self.abid)
|
self.alice.friend_delete(self.abid)
|
||||||
|
|
||||||
@expectedFail('fails') # assert self.bob.friend_get_status(self.baid) == TOX_USER_STATUS['BUSY']
|
#! @expectedFail('fails') # assert self.bob.friend_get_status(self.baid) == TOX_USER_STATUS['BUSY']
|
||||||
|
@unittest.skip('malloc(): unaligned tcache chunk detected')
|
||||||
def test_user_status(self): # fails
|
def test_user_status(self): # fails
|
||||||
"""
|
"""
|
||||||
t:self_get_status
|
t:self_get_status
|
||||||
@ -1549,6 +1410,10 @@ class ToxSuite(unittest.TestCase):
|
|||||||
t:on_friend_status
|
t:on_friend_status
|
||||||
"""
|
"""
|
||||||
sSlot = 'friend_status'
|
sSlot = 'friend_status'
|
||||||
|
if bUSE_NOREQUEST:
|
||||||
|
assert self.bob_add_alice_as_friend_norequest()
|
||||||
|
else:
|
||||||
|
assert self.bob_add_alice_as_friend()
|
||||||
|
|
||||||
setattr(self.bob, sSlot, None)
|
setattr(self.bob, sSlot, None)
|
||||||
def bobs_on_friend_set_status(iTox, friend_id, new_status, *largs):
|
def bobs_on_friend_set_status(iTox, friend_id, new_status, *largs):
|
||||||
@ -1561,10 +1426,6 @@ class ToxSuite(unittest.TestCase):
|
|||||||
setattr(self.bob, sSlot, True)
|
setattr(self.bob, sSlot, True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if bUSE_NOREQUEST:
|
|
||||||
assert self.bob_add_alice_as_friend_norequest()
|
|
||||||
else:
|
|
||||||
assert self.bob_add_alice_as_friend()
|
|
||||||
if not self.get_connection_status():
|
if not self.get_connection_status():
|
||||||
LOG.warning(f"test_user_status NOT CONNECTED self.get_connection_status")
|
LOG.warning(f"test_user_status NOT CONNECTED self.get_connection_status")
|
||||||
self.loop_until_connected()
|
self.loop_until_connected()
|
||||||
@ -1573,16 +1434,15 @@ class ToxSuite(unittest.TestCase):
|
|||||||
self.warn_if_no_cb(self.bob, sSlot)
|
self.warn_if_no_cb(self.bob, sSlot)
|
||||||
sSTATUS = TOX_USER_STATUS['BUSY']
|
sSTATUS = TOX_USER_STATUS['BUSY']
|
||||||
self.alice.self_set_status(sSTATUS)
|
self.alice.self_set_status(sSTATUS)
|
||||||
sSlot = 'friend_status'
|
|
||||||
if not self.wait_otox_attrs(self.bob, [sSlot]):
|
if not self.wait_otox_attrs(self.bob, [sSlot]):
|
||||||
# malloc(): unaligned tcache chunk detected
|
# malloc(): unaligned tcache chunk detected
|
||||||
LOG_WARN(f'test_user_status NO {sSlot}')
|
LOG_WARN(f' NO {sSlot}')
|
||||||
|
|
||||||
assert self.bob.friend_get_status(self.baid) == TOX_USER_STATUS['BUSY'], \
|
assert self.bob.friend_get_status(self.baid) == TOX_USER_STATUS['BUSY'], \
|
||||||
f"friend_get_status {self.bob.friend_get_status(self.baid)} != {TOX_USER_STATUS['BUSY']}"
|
f"{self.bob.friend_get_status(self.baid)} != {TOX_USER_STATUS['BUSY']}"
|
||||||
|
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
LOG.error(f"test_user_status FAILED {e}")
|
LOG.error(f"Failed test_user_status {e}")
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error(f"test_user_status EXCEPTION {e}")
|
LOG.error(f"test_user_status EXCEPTION {e}")
|
||||||
@ -1610,13 +1470,13 @@ class ToxSuite(unittest.TestCase):
|
|||||||
setattr(self.bob, sSlot, True)
|
setattr(self.bob, sSlot, True)
|
||||||
|
|
||||||
opts = oToxygenToxOptions(oTOX_OARGS)
|
opts = oToxygenToxOptions(oTOX_OARGS)
|
||||||
setattr(self.bob, sSlot, True)
|
|
||||||
try:
|
try:
|
||||||
if bUSE_NOREQUEST:
|
if bUSE_NOREQUEST:
|
||||||
assert self.bob_add_alice_as_friend_norequest()
|
assert self.bob_add_alice_as_friend_norequest()
|
||||||
else:
|
else:
|
||||||
assert self.bob_add_alice_as_friend()
|
assert self.bob_add_alice_as_friend()
|
||||||
|
|
||||||
|
setattr(self.bob, sSlot, True)
|
||||||
self.bob.callback_friend_connection_status(bobs_on_friend_connection_status)
|
self.bob.callback_friend_connection_status(bobs_on_friend_connection_status)
|
||||||
|
|
||||||
LOG.info("test_connection_status killing alice")
|
LOG.info("test_connection_status killing alice")
|
||||||
@ -1638,8 +1498,10 @@ class ToxSuite(unittest.TestCase):
|
|||||||
if hasattr(self, 'baid') and self.baid >= 0:
|
if hasattr(self, 'baid') and self.baid >= 0:
|
||||||
self.bob.friend_delete(self.baid)
|
self.bob.friend_delete(self.baid)
|
||||||
|
|
||||||
@expectedFail('fails') # new name is empty
|
# TestS DEBUG wait_otox_attrs bob for ['friend_name'] 5 last=1701826540
|
||||||
def test_friend_name(self): # works!
|
# @unittest.skip('crashes')
|
||||||
|
@expectedFail('fails') # new name if empty
|
||||||
|
def test_friend_name(self): # works! or crashes!
|
||||||
"""
|
"""
|
||||||
t:self_set_name
|
t:self_set_name
|
||||||
t:friend_get_name
|
t:friend_get_name
|
||||||
@ -1695,7 +1557,9 @@ class ToxSuite(unittest.TestCase):
|
|||||||
self.warn_if_cb(self.bob, sSlot)
|
self.warn_if_cb(self.bob, sSlot)
|
||||||
|
|
||||||
|
|
||||||
@expectedFail('fails') # This client is currently not connected to the friend.
|
# wait_ensure_exec ArgumentError This client is currently not connected to the friend.
|
||||||
|
@expectedFail('fails')
|
||||||
|
# This client is currently not connected to the friend.
|
||||||
def test_friend_message(self): # fails
|
def test_friend_message(self): # fails
|
||||||
"""
|
"""
|
||||||
t:on_friend_action
|
t:on_friend_action
|
||||||
@ -1726,34 +1590,35 @@ class ToxSuite(unittest.TestCase):
|
|||||||
assert self.both_add_as_friend_norequest()
|
assert self.both_add_as_friend_norequest()
|
||||||
else:
|
else:
|
||||||
assert self.both_add_as_friend()
|
assert self.both_add_as_friend()
|
||||||
assert hasattr(self, 'baid'), \
|
if not self.wait_friend_get_connection_status(self.alice, self.abid, n=iN):
|
||||||
"both_add_as_friend_norequest no bob, baid"
|
|
||||||
assert hasattr(self, 'abid'), \
|
|
||||||
"both_add_as_friend_norequest no alice, abid"
|
|
||||||
if not self.wait_friend_get_connection_status(self.bob, self.baid, n=2*iN):
|
|
||||||
LOG.warn('baid not connected')
|
|
||||||
if not self.wait_friend_get_connection_status(self.alice, self.abid, n=2*iN):
|
|
||||||
LOG.warn('abid not connected')
|
LOG.warn('abid not connected')
|
||||||
self.alice.callback_friend_message(alices_on_friend_message)
|
self.alice.callback_friend_message(alices_on_friend_message)
|
||||||
self.warn_if_no_cb(self.alice, sSlot)
|
self.warn_if_no_cb(self.alice, sSlot)
|
||||||
|
|
||||||
# dunno - both This client is currently NOT CONNECTED to the friend.
|
# dunno - both This client is currently NOT CONNECTED to the friend.
|
||||||
iMesId = self.bob.friend_send_message(self.baid,
|
if True:
|
||||||
TOX_MESSAGE_TYPE['NORMAL'],
|
iMesId = self.bob.friend_send_message(self.baid,
|
||||||
bytes(MSG, 'UTF-8'))
|
TOX_MESSAGE_TYPE['NORMAL'],
|
||||||
assert iMesId >= 0, "iMesId >= 0"
|
bytes(MSG, 'UTF-8'))
|
||||||
|
# ArgumentError('This client is currently NOT CONNECTED to the friend.')
|
||||||
|
else:
|
||||||
|
iMesId = self.wait_ensure_exec(self.bob.friend_send_message,
|
||||||
|
[self.baid,
|
||||||
|
TOX_MESSAGE_TYPE['NORMAL'],
|
||||||
|
bytes(MSG, 'UTF-8')])
|
||||||
|
assert iMesId >= 0
|
||||||
if not self.wait_otox_attrs(self.alice, [sSlot]):
|
if not self.wait_otox_attrs(self.alice, [sSlot]):
|
||||||
LOG_WARN(f"alices_on_friend_message NO {sSlot}")
|
LOG_WARN(f"alices_on_friend_message NO {sSlot}")
|
||||||
except ArgumentError as e:
|
except ArgumentError as e:
|
||||||
# ArgumentError('This client is currently NOT CONNECTED to the friend.')
|
# ArgumentError('This client is currently NOT CONNECTED to the friend.')
|
||||||
# dunno
|
# dunno
|
||||||
LOG.error(f"test_friend_message ArgumentError {e}")
|
LOG.error(f"test_friend_message {e}")
|
||||||
raise
|
raise
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
LOG.error(f"test_friend_message AssertionError {e}")
|
LOG.error(f"test_friend_message {e}")
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error(f"test_friend_message EXCEPTION {e}")
|
LOG.error(f"test_friend_message {e}")
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
self.alice.callback_friend_message(None)
|
self.alice.callback_friend_message(None)
|
||||||
@ -2085,6 +1950,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
|
|
||||||
@unittest.skip('crashes')
|
@unittest.skip('crashes')
|
||||||
def test_tox_savedata(self): # works sorta
|
def test_tox_savedata(self): # works sorta
|
||||||
|
# but "{addr} != {self.alice.self_get_address()}"
|
||||||
"""
|
"""
|
||||||
t:get_savedata_size
|
t:get_savedata_size
|
||||||
t:get_savedata
|
t:get_savedata
|
||||||
@ -2118,13 +1984,6 @@ class ToxSuite(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
LOG.info("passed test_tox_savedata")
|
LOG.info("passed test_tox_savedata")
|
||||||
|
|
||||||
def test_kill(self): #
|
|
||||||
import threading
|
|
||||||
LOG.info(f"THE END {threading.active_count()}")
|
|
||||||
self.tearDown()
|
|
||||||
LOG.info(f"THE END {threading.enumerate()}")
|
|
||||||
|
|
||||||
|
|
||||||
def vOargsToxPreamble(oArgs, Tox, ToxTest):
|
def vOargsToxPreamble(oArgs, Tox, ToxTest):
|
||||||
|
|
||||||
ts.vSetupLogging(oArgs)
|
ts.vSetupLogging(oArgs)
|
||||||
@ -2141,7 +2000,6 @@ def vOargsToxPreamble(oArgs, Tox, ToxTest):
|
|||||||
if len(not_tested):
|
if len(not_tested):
|
||||||
logging.info('Not tested:\n %s' % "\n ".join(sorted(list(not_tested))))
|
logging.info('Not tested:\n %s' % "\n ".join(sorted(list(not_tested))))
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
def iMain(oArgs):
|
def iMain(oArgs):
|
||||||
@ -2254,3 +2112,6 @@ def main(lArgs=None):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main(sys.argv[1:]))
|
sys.exit(main(sys.argv[1:]))
|
||||||
|
|
||||||
|
#Ran 38 tests in 194.492s
|
||||||
|
#OK (skipped=10, expected failures=4)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user