Made trust distance test graph generation reliable

This commit is contained in:
Kevin F 2022-09-15 20:01:59 -05:00
parent 05e04ef557
commit fae9521d8f
1 changed files with 8 additions and 2 deletions

View File

@ -29,8 +29,14 @@ def generate_graph(iden: Identity, depth, max_neighbors):
class IdentityDistanceTest(unittest.TestCase):
def test_distance(self):
iden = Identity(os.urandom(32), "1" + secrets.token_hex(4))
generate_graph(iden, 10, 5)
iden2 = list(list(iden.trusted)[0].trusted)[0]
while True:
generate_graph(iden, 10, 5)
try:
iden2 = list(list(iden.trusted)[0].trusted)[0]
except IndexError:
pass
else:
break
self.assertEqual(get_distance(iden, iden2), 2)