示例#1
0
    def test_gt_height_forked(self):
        update = {
            'cumulative_difficulty': '1010101010101',
            'height': 641104,
        }

        with mock.patch('scan.peers.get_last_cumulative_difficulty',
                        return_value={'height': 641103, 'cumulative_difficulty': '64770577730996744870'}):
            self.assertEqual(get_state(update, None), PeerMonitor.State.FORKED)
示例#2
0
    def test_stuck(self):
        update = {
            'cumulative_difficulty': '1010101010101',
            'height': 641102,
        }
        peer_obj = PeerMonitor(height=641102, cumulative_difficulty='1010101010101')

        with mock.patch('scan.peers.get_last_cumulative_difficulty',
                        return_value={'height': 641103, 'cumulative_difficulty': '64770577730996744870'}):
            self.assertEqual(get_state(update, peer_obj), PeerMonitor.State.STUCK)
示例#3
0
    def test_gt_height_forked(self):
        update = {"cumulative_difficulty": "1010101010101", "height": 641104}

        with mock.patch(
            "scan.peers.get_last_cumulative_difficulty",
            return_value={
                "height": 641103,
                "cumulative_difficulty": "64770577730996744870",
            },
        ):
            self.assertEqual(get_state(update, None), PeerMonitor.State.FORKED)
示例#4
0
    def test_lt_height_forked(self):
        update = {
            'cumulative_difficulty': '1010101010101',
            'height': 641102,
        }
        peer_obj = PeerMonitor(height=641101, cumulative_difficulty='20202020202020')

        with mock.patch('scan.peers.get_last_cumulative_difficulty',
                        return_value={'height': 641103, 'cumulative_difficulty': '64770577730996744870'}):
            with mock.patch('scan.peers.get_block_cumulative_difficulty', return_value='303030303030303030'):
                self.assertEqual(get_state(update, peer_obj), PeerMonitor.State.FORKED)
示例#5
0
    def test_stuck(self):
        update = {"cumulative_difficulty": "1010101010101", "height": 641102}
        peer_obj = PeerMonitor(height=641102, cumulative_difficulty="1010101010101")

        with mock.patch(
            "scan.peers.get_last_cumulative_difficulty",
            return_value={
                "height": 641103,
                "cumulative_difficulty": "64770577730996744870",
            },
        ):
            self.assertEqual(get_state(update, peer_obj), PeerMonitor.State.STUCK)
示例#6
0
    def test_online_ok(self):
        update = {
            'announced_address': 'wallet.burst.devtrue.net',
            'application': 'BRS',
            'country_code': 'FR',
            'cumulative_difficulty': '64770577730996744870',
            'height': 641103,
            'last_online_at': datetime.datetime(2019, 7, 10, 17, 47, 6, 963229),
            'platform': 'BURST-BTKF-8WT9-L98N-98JH2',
            'version': 'v2.4.0'
        }

        with mock.patch('scan.peers.get_last_cumulative_difficulty',
                        return_value={'height': 641103, 'cumulative_difficulty': '64770577730996744870'}):
            self.assertEqual(get_state(update, None), PeerMonitor.State.ONLINE)
示例#7
0
    def test_lt_height_forked(self):
        update = {"cumulative_difficulty": "1010101010101", "height": 641102}
        peer_obj = PeerMonitor(height=641101, cumulative_difficulty="20202020202020")

        with mock.patch(
            "scan.peers.get_last_cumulative_difficulty",
            return_value={
                "height": 641103,
                "cumulative_difficulty": "64770577730996744870",
            },
        ):
            with mock.patch(
                "scan.peers.get_block_cumulative_difficulty",
                return_value="303030303030303030",
            ):
                self.assertEqual(get_state(update, peer_obj), PeerMonitor.State.FORKED)
示例#8
0
    def test_online_ok(self):
        update = {
            "announced_address": "wallet.burst.devtrue.net",
            "application": "BRS",
            "country_code": "FR",
            "cumulative_difficulty": "64770577730996744870",
            "height": 641103,
            "last_online_at": datetime(2019, 7, 10, 17, 47, 6, 963229),
            "platform": "BURST-BTKF-8WT9-L98N-98JH2",
            "version": "v2.4.0",
        }

        with mock.patch(
            "scan.peers.get_last_cumulative_difficulty",
            return_value={
                "height": 641103,
                "cumulative_difficulty": "64770577730996744870",
            },
        ):
            self.assertEqual(get_state(update, None), PeerMonitor.State.ONLINE)