Skip to content

Commit

Permalink
fix: ensure question history suppresses duplicates (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Dec 15, 2023
1 parent 73d3ab9 commit 6f23656
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/zeroconf/_history.pxd
Expand Up @@ -9,10 +9,10 @@ cdef class QuestionHistory:

cdef cython.dict _history

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

@cython.locals(than=cython.double, previous_question=cython.tuple, previous_known_answers=cython.set)
cpdef bint suppresses(self, DNSQuestion question, cython.double now, cython.set known_answers)
@cython.locals(than=double, previous_question=cython.tuple, previous_known_answers=cython.set)
cpdef bint suppresses(self, DNSQuestion question, double now, cython.set known_answers)

@cython.locals(than=cython.double, now_known_answers=cython.tuple)
cpdef async_expire(self, cython.double now)
@cython.locals(than=double, now_known_answers=cython.tuple)
cpdef async_expire(self, double now)
9 changes: 7 additions & 2 deletions tests/test_history.py
Expand Up @@ -47,11 +47,16 @@ def test_question_suppression():
def test_question_expire():
history = QuestionHistory()

question = r.DNSQuestion("_hap._tcp._local.", const._TYPE_PTR, const._CLASS_IN)
now = r.current_time_millis()
question = r.DNSQuestion("_hap._tcp._local.", const._TYPE_PTR, const._CLASS_IN)
other_known_answers: Set[r.DNSRecord] = {
r.DNSPointer(
"_hap._tcp.local.", const._TYPE_PTR, const._CLASS_IN, 10000, 'known-to-other._hap._tcp.local.'
"_hap._tcp.local.",
const._TYPE_PTR,
const._CLASS_IN,
10000,
'known-to-other._hap._tcp.local.',
created=now,
)
}
history.add_question_at_time(question, now, other_known_answers)
Expand Down

0 comments on commit 6f23656

Please sign in to comment.