added is_friend test for onionrusers and fixed bug where isFriend was setting instead of getting the value

master
Kevin Froman 2020-04-05 23:35:03 -05:00
parent ae8d1fc5ea
commit d13d9a3039
2 changed files with 15 additions and 9 deletions

View File

@ -87,7 +87,7 @@ class OnionrUser:
keydb.userinfo.set_user_info(self.publicKey, 'trust', newTrust) keydb.userinfo.set_user_info(self.publicKey, 'trust', newTrust)
def isFriend(self): def isFriend(self):
if keydb.userinfo.set_peer_info(self.publicKey, 'trust') == 1: if keydb.userinfo.get_user_info(self.publicKey, 'trust') == 1:
return True return True
return False return False

View File

@ -23,7 +23,6 @@ class OnionrUserTests(unittest.TestCase):
def test_users(self): def test_users(self):
keypair = crypto.generate() keypair = crypto.generate()
onionrusers.OnionrUser(keypair[0]) onionrusers.OnionrUser(keypair[0])
return
def test_contact_init_no_save(self): def test_contact_init_no_save(self):
contact = crypto.generate()[0] contact = crypto.generate()[0]
@ -60,6 +59,13 @@ class OnionrUserTests(unittest.TestCase):
self.assertEqual(contact.get_info('fail', forceReload=True), None) self.assertEqual(contact.get_info('fail', forceReload=True), None)
self.assertEqual(contact.get_info('fail'), None) self.assertEqual(contact.get_info('fail'), None)
def test_is_friend(self):
contact = crypto.generate()[0]
contact = onionrusers.OnionrUser(contact, saveUser=True)
self.assertFalse(contact.isFriend())
contact.setTrust(1)
self.assertTrue(contact.isFriend())
def test_encrypt(self): def test_encrypt(self):
contactPair = crypto.generate() contactPair = crypto.generate()
contact = contactmanager.ContactManager(contactPair[0], saveUser=True) contact = contactmanager.ContactManager(contactPair[0], saveUser=True)