twisted.protocols.sip assumes DelayedCalls are scheduled by wallclock time

[email protected] Tue, 05 Jan 2010 02:47:24 -0000
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from ivank <[email protected]>:

twisted/protocols/sip.py has `dc.getTime() - time.time()` in two places, which is wrong because DelayedCall``s are not guaranteed to be scheduled by `time.time()`. Perhaps it should use `twisted.python.runtime.seconds()`, or do something else entirely.

Using a monotonic clock breaks these tests (line numbers may be wrong):

{{{
===============================================================================
[FAIL]: twisted.test.test_sip.RegistrationTestCase.testRegister

Traceback (most recent call last):
  File "/opt/Python-latest/lib/python2.7/site-packages/twisted/test/test_sip.py", line 540, in testRegister
    int(m.headers["expires"][0]) in (3600, 3601, 3599, 3598))
twisted.trial.unittest.FailTest: None
===============================================================================
[ERROR]: twisted.test.test_sip.AuthorizationTestCase.testChallenge

Traceback (most recent call last):
  File "/opt/Python-latest/lib/python2.7/site-packages/twisted/test/test_sip.py", line 883, in testChallenge
    self.transport.written[-1],
exceptions.IndexError: list index out of range
===============================================================================
[ERROR]: twisted.test.test_sip.AuthorizationTestCase.testChallenge

Traceback (most recent call last):
  File "/opt/Python-latest/lib/python2.7/site-packages/twisted/test/test_sip.py", line 832, in _cbReg
    "bad seconds to expire: %s" % reg.secondsToExpiry)
exceptions.RuntimeError: bad seconds to expire: -1260891498
}}}

----------
Type     : defect
Component: core
Keywords : 
Priority : low
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/4198