Example #1
0
    def test_retry_connection(self):
        p = PeerId()
        interval = p.retry_interval
        p.update_retry_timestamp(0)
        self.assertEqual(
            settings.PEER_CONNECTION_RETRY_INTERVAL_MULTIPLIER * interval,
            p.retry_interval)
        self.assertEqual(p.retry_interval, p.retry_timestamp)

        # when retry_interval is already 180
        p.retry_interval = 190
        p.update_retry_timestamp(0)
        self.assertEqual(180, p.retry_interval)

        # reset
        p.reset_retry_timestamp()
        self.assertEqual(p.retry_interval, 5)
        self.assertEqual(p.retry_timestamp, 0)
Example #2
0
    def test_retry_connection(self):
        p = PeerId()
        interval = p.retry_interval
        p.increment_retry_attempt(0)
        self.assertEqual(
            settings.PEER_CONNECTION_RETRY_INTERVAL_MULTIPLIER * interval,
            p.retry_interval)
        self.assertEqual(interval, p.retry_timestamp)

        # when retry_interval is already 180
        p.retry_interval = settings.PEER_CONNECTION_RETRY_MAX_RETRY_INTERVAL + 10
        p.increment_retry_attempt(0)
        self.assertEqual(settings.PEER_CONNECTION_RETRY_MAX_RETRY_INTERVAL,
                         p.retry_interval)

        # reset
        p.reset_retry_timestamp()
        self.assertEqual(p.retry_interval, 5)
        self.assertEqual(p.retry_timestamp, 0)