Opened 4 years ago

Closed 4 years ago

#18659 closed defect (fixed)

test_connections_ipv6 test failure on OSX

Reported by: Sebastian Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Looks like assertEqual can't correctly compare ipv6 addresses:

-  Connection(local_address='2a01:4f8:190:514a::2', local_port=443, remote_address='2001:858:2:2:aabb:0:563b:1526', remote_port=44469, protocol='tcp', is_ipv6=True)]
+  Connection(local_address='2a01:4f8:190:514a::2', local_port=443, remote_address='2001:858:2:2:aabb::563b:1526', remote_port=44469, protocol='tcp', is_ipv6=True)]

one way to resolve this would be to depend on ipaddress to canonicalize the addresses, but I guess Stem doesn't want to do that. Another idea would be to disable the test on OSX, as it doesn't even have a /proc

Child Tickets

Change History (4)

comment:1 Changed 4 years ago by Sebastian

full stacktrace:

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mock.py", line 1201, in patched
    return func(*args, **keywargs)
  File "/tor-git/stem/test/unit/util/proc.py", line 272, in test_connections_ipv6
    self.assertEqual(expected_results, proc.connections(pid = pid))
AssertionError: Lists differ: [Connection(local_address='2a0... != [Connection(local_address='2a0...

First differing element 1:
Connection(local_address='2a01:4f8:190:514a::2', local_port=443, remote_address='2001:858:2:2:aabb:0:563b:1526', remote_port=44469, protocol='tcp', is_ipv6=True)
Connection(local_address='2a01:4f8:190:514a::2', local_port=443, remote_address='2001:858:2:2:aabb::563b:1526', remote_port=44469, protocol='tcp', is_ipv6=True)

  [Connection(local_address='2a01:4f8:190:514a::2', local_port=443, remote_address='2001:638:a000:4140::ffff:189', remote_port=40435, protocol='tcp', is_ipv6=True),
-  Connection(local_address='2a01:4f8:190:514a::2', local_port=443, remote_address='2001:858:2:2:aabb:0:563b:1526', remote_port=44469, protocol='tcp', is_ipv6=True)]
?                                                                                                     -

+  Connection(local_address='2a01:4f8:190:514a::2', local_port=443, remote_address='2001:858:2:2:aabb::563b:1526', remote_port=44469, protocol='tcp', is_ipv6=True)]

comment:2 Changed 4 years ago by atagar

Narrowed this down. Frustratingly I think it might be a platform different in how python's socket module behaves. Mind running the following?

>>> import stem.util.proc
>>> stem.util.proc._decode_proc_address_encoding('58080120020002000000BBAA26153B56:ADB5', True)
('2001:858:2:2:aabb:0:563b:1526', 44469)

>>> import socket
>>> import base64
>>> socket.inet_ntop(socket.AF_INET6, base64.b16decode('2001085800020002AABB0000563B1526'))
'2001:858:2:2:aabb:0:563b:1526'

Since the difference is between ':0:' and '::' we can probably just change the test to make them both acceptable.

comment:3 Changed 4 years ago by atagar

Fix pushed, thanks for the catch!

comment:4 Changed 4 years ago by atagar

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.