def test_intro_point_encode(self): """ Encode an introduction point back into a string. """ intro_point = IntroductionPointV3.parse(INTRO_POINT_STR) self.assertEqual(INTRO_POINT_STR.rstrip(), intro_point.encode())
def test_intro_point_parse(self): """ Parse a v3 introduction point. """ intro_point = IntroductionPointV3.parse(INTRO_POINT_STR) self.assertEqual('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=', intro_point.onion_key_raw) self.assertTrue('0Acq8QW8O7O' in intro_point.auth_key_cert.to_base64()) self.assertEqual('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=', intro_point.enc_key_raw) self.assertTrue('4807i5', intro_point.enc_key_cert.to_base64()) self.assertTrue('JAoGBAMO3' in intro_point.legacy_key_raw) self.assertTrue('Ln1ITJ0qP' in intro_point.legacy_key_cert)
def test_intro_point_creation(self): """ Create an introduction point, encode it, then re-parse. """ intro_point = IntroductionPointV3.create_for_address('1.1.1.1', 9001) self.assertEqual(1, len(intro_point.link_specifiers)) self.assertEqual(stem.client.datatype.LinkByIPv4, type(intro_point.link_specifiers[0])) self.assertEqual('1.1.1.1', intro_point.link_specifiers[0].address) self.assertEqual(9001, intro_point.link_specifiers[0].port) reparsed = IntroductionPointV3.parse(intro_point.encode()) self.assertEqual(intro_point, reparsed)