fix: ensure question history suppresses duplicates (#1338) · python-zeroconf/python-zeroconf@6f23656

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -9,10 +9,10 @@ cdef class QuestionHistory:

99
1010

cdef cython.dict _history

1111
12-

cpdef add_question_at_time(self, DNSQuestion question, float now, cython.set known_answers)

12+

cpdef add_question_at_time(self, DNSQuestion question, double now, cython.set known_answers)

1313
14-

@cython.locals(than=cython.double, previous_question=cython.tuple, previous_known_answers=cython.set)

15-

cpdef bint suppresses(self, DNSQuestion question, cython.double now, cython.set known_answers)

14+

@cython.locals(than=double, previous_question=cython.tuple, previous_known_answers=cython.set)

15+

cpdef bint suppresses(self, DNSQuestion question, double now, cython.set known_answers)

1616
17-

@cython.locals(than=cython.double, now_known_answers=cython.tuple)

18-

cpdef async_expire(self, cython.double now)

17+

@cython.locals(than=double, now_known_answers=cython.tuple)

18+

cpdef async_expire(self, double now)

Original file line numberDiff line numberDiff line change

@@ -47,11 +47,16 @@ def test_question_suppression():

4747

def test_question_expire():

4848

history = QuestionHistory()

4949
50-

question = r.DNSQuestion("_hap._tcp._local.", const._TYPE_PTR, const._CLASS_IN)

5150

now = r.current_time_millis()

51+

question = r.DNSQuestion("_hap._tcp._local.", const._TYPE_PTR, const._CLASS_IN)

5252

other_known_answers: Set[r.DNSRecord] = {

5353

r.DNSPointer(

54-

"_hap._tcp.local.", const._TYPE_PTR, const._CLASS_IN, 10000, 'known-to-other._hap._tcp.local.'

54+

"_hap._tcp.local.",

55+

const._TYPE_PTR,

56+

const._CLASS_IN,

57+

10000,

58+

'known-to-other._hap._tcp.local.',

59+

created=now,

5560

)

5661

}

5762

history.add_question_at_time(question, now, other_known_answers)