示例#1
0
 def test_statistics_population(self):
     """Test for population of statistics database."""
     logger.info("TEST for population of statistics.")
     populate_statistics(500)
     for s in BlockStatistics.objects.all():
         logger.info(s.bin_start)
     logger.info("Number of block statistics generated: {}".format(
         BlockStatistics.objects.count()))
示例#2
0
    def test_update_hashrate(self):
        """Test if updating of hashrate works"""
        logger.info("TEST Update hashrate.")

        populate_statistics(720)
        stats_before = BlockStatistics.objects.all()
        stats_before = save_stats(stats_before)

        update_statistics(360, 720)
        stats_after = BlockStatistics.objects.all()
        stats_after = save_stats(stats_after)

        for ss1, ss2 in zip(stats_before, stats_after):
            self.assertEqual(ss1, ss2)
示例#3
0
    def test_update_difficulty(self):
        """Test if updating of difficulty works"""
        logger.info("TEST Update difficulty.")

        populate_statistics(500)
        stats_before = BlockStatistics.objects.all()
        difficulties_before = []
        for s in stats_before:
            difficulties_before.append(s.difficulty)

        update_statistics(500, 720)
        stats_after = BlockStatistics.objects.all()
        difficulties_after = []

        for s in stats_after:
            difficulties_after.append(s.difficulty)

        for s1, s2 in zip(difficulties_before, difficulties_after):
            self.assertEqual(s1, s2)
示例#4
0
 def test_discard_height_stats(self):
     bins = (500 // BLOCKS_PER_STATS_BIN)
     populate_statistics(500)
     self.assertEqual(get_height_stats(), bins * BLOCKS_PER_STATS_BIN)
     discard_statistics(1)
     self.assertEqual(get_height_stats(), (bins - 1) * BLOCKS_PER_STATS_BIN)
示例#5
0
 def test_get_height_stats(self):
     populate_statistics(500)
     self.assertEqual(get_height_stats(),
                      (500 // BLOCKS_PER_STATS_BIN) * BLOCKS_PER_STATS_BIN)