Match viewer resend behaviour

This commit is contained in:
Salad Dais
2021-12-10 07:04:36 +00:00
parent ec4b2d0770
commit 16c808bce8
2 changed files with 5 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ class ReliableResendInfo:
last_resent: dt.datetime
message: Message
completed: asyncio.Future = dataclasses.field(default_factory=asyncio.Future)
tries_left: int = 3
tries_left: int = 10
class Circuit:
@@ -34,7 +34,7 @@ class Circuit:
self.last_packet_at = dt.datetime.now()
self.packet_id_base = 0
self.unacked_reliable: Dict[Tuple[Direction, int], ReliableResendInfo] = {}
self.resend_every: float = 5.0
self.resend_every: float = 3.0
def _send_prepared_message(self, message: Message, transport=None):
try:

View File

@@ -250,7 +250,7 @@ class PacketIDTests(unittest.IsolatedAsyncioTestCase):
resend_info = self.circuit.unacked_reliable[(Direction.OUT, 1)]
self.circuit.resend_unacked()
# Should have been too soon to retry
self.assertEqual(3, resend_info.tries_left)
self.assertEqual(10, resend_info.tries_left)
# Switch to allowing resends every 0s
self.circuit.resend_every = 0.0
self.circuit.resend_unacked()
@@ -259,8 +259,8 @@ class PacketIDTests(unittest.IsolatedAsyncioTestCase):
# Should have resent
(1, "ChatFromViewer", Direction.OUT, True, ()),
])
self.assertEqual(2, resend_info.tries_left)
for _ in range(3):
self.assertEqual(9, resend_info.tries_left)
for _ in range(resend_info.tries_left):
self.circuit.resend_unacked()
# Should have used up all the retry attempts and been kicked out of the retry queue
self.assertEqual(set(), set(self.circuit.unacked_reliable))