示例#1
0
    def test_load_state_sets_values_to_saved_values(self):
        # Set Redis values manually
        hash_name = Keys.get_hash_blockchain(self.blockchain.name)
        self.redis.hset_multiple_unsafe(
            hash_name, {
                Keys.get_blockchain_referendum_count(self.blockchain.name):
                self.dummy_referendum_count,
                Keys.get_blockchain_public_prop_count(self.blockchain.name):
                self.dummy_public_prop_count,
                Keys.get_blockchain_council_prop_count(self.blockchain.name):
                self.dummy_council_prop_count,
                Keys.get_blockchain_validator_set_size(self.blockchain.name):
                self.dummy_validator_set_size,
            })

        # Load the Redis values
        self.blockchain.load_state(self.logger)

        # Assert
        self.assertEqual(self.blockchain.referendum_count,
                         self.dummy_referendum_count)
        self.assertEqual(self.blockchain.public_prop_count,
                         self.dummy_public_prop_count)
        self.assertEqual(self.blockchain.council_prop_count,
                         self.dummy_council_prop_count)
        self.assertEqual(self.blockchain.validator_set_size,
                         self.dummy_validator_set_size)
示例#2
0
    def __init__(self, name: str, redis: Optional[RedisApi]) -> None:
        super().__init__()

        self.name = name
        self._redis = redis
        self._redis_enabled = redis is not None
        self._redis_hash = Keys.get_hash_blockchain(name)

        self._referendum_count = None
        self._public_prop_count = None
        self._council_prop_count = None
        self._validator_set_size = None
示例#3
0
    def test_save_state_sets_values_to_current_values(self):
        # Set blockchain values manually
        self.blockchain.set_referendum_count(self.dummy_referendum_count,
                                             self.channel_set, self.logger)
        self.blockchain.set_council_prop_count(self.dummy_council_prop_count,
                                               self.channel_set, self.logger)
        self.blockchain.set_public_prop_count(self.dummy_public_prop_count,
                                              self.channel_set, self.logger)
        self.blockchain.set_validator_set_size(self.dummy_validator_set_size,
                                               self.channel_set, self.logger)

        # Save the values to Redis
        self.blockchain.save_state(self.logger)

        # Assert
        hash_name = Keys.get_hash_blockchain(self.blockchain.name)
        self.assertEqual(
            self.redis.hget_int_unsafe(
                hash_name,
                Keys.get_blockchain_referendum_count(self.blockchain.name)),
            self.dummy_referendum_count)
        self.assertEqual(
            self.redis.hget_int_unsafe(
                hash_name,
                Keys.get_blockchain_public_prop_count(self.blockchain.name)),
            self.dummy_public_prop_count)
        self.assertEqual(
            self.redis.hget_int_unsafe(
                hash_name,
                Keys.get_blockchain_council_prop_count(self.blockchain.name)),
            self.dummy_council_prop_count)
        self.assertEqual(
            self.redis.hget_int_unsafe(
                hash_name,
                Keys.get_blockchain_validator_set_size(self.blockchain.name)),
            self.dummy_validator_set_size)
示例#4
0
    def __init__(self,
                 name: str,
                 redis: Optional[RedisApi],
                 node: Node,
                 internal_conf: InternalConfig = InternalConf) -> None:
        super().__init__()

        self.name = name
        self._node = node
        self._redis = redis
        self._redis_enabled = redis is not None
        self._redis_hash = Keys.get_hash_blockchain(node.chain)

        self._process_cpu_seconds_total = None

        # Process memory usage
        self._process_memory_usage = None

        # Virtual memory usage
        self._virtual_memory_usage = None

        # Open file descriptors
        self._open_file_descriptors = None

        # System CPU usage
        self._system_cpu_usage = None

        # System RAM usage
        self._system_ram_usage = None

        # System storage used
        self._system_storage_usage = None

        self._validator_process_memory_usage_danger_boundary = \
            internal_conf.validator_process_memory_usage_danger_boundary
        self._validator_process_memory_usage_safe_boundary = \
            internal_conf.validator_process_memory_usage_safe_boundary
        self._validator_open_file_descriptors_danger_boundary = \
            internal_conf.validator_open_file_descriptors_danger_boundary
        self._validator_open_file_descriptors_safe_boundary = \
            internal_conf.validator_open_file_descriptors_safe_boundary
        self._validator_system_cpu_usage_danger_boundary = \
            internal_conf.validator_system_cpu_usage_danger_boundary
        self._validator_system_cpu_usage_safe_boundary = \
            internal_conf.validator_system_cpu_usage_safe_boundary
        self._validator_system_ram_usage_danger_boundary = \
            internal_conf.validator_system_ram_usage_danger_boundary
        self._validator_system_ram_usage_safe_boundary = \
            internal_conf.validator_system_ram_usage_safe_boundary
        self._validator_system_storage_usage_danger_boundary = \
            internal_conf.validator_system_storage_usage_danger_boundary
        self._validator_system_storage_usage_safe_boundary = \
            internal_conf.validator_system_storage_usage_safe_boundary

        self._node_process_memory_usage_danger_boundary = \
            internal_conf.node_process_memory_usage_danger_boundary
        self._node_process_memory_usage_safe_boundary = \
            internal_conf.node_process_memory_usage_safe_boundary
        self._node_open_file_descriptors_danger_boundary = \
            internal_conf.node_open_file_descriptors_danger_boundary
        self._node_open_file_descriptors_safe_boundary = \
            internal_conf.node_open_file_descriptors_safe_boundary
        self._node_system_cpu_usage_danger_boundary = \
            internal_conf.node_system_cpu_usage_danger_boundary
        self._node_system_cpu_usage_safe_boundary = \
            internal_conf.node_system_cpu_usage_safe_boundary
        self._node_system_ram_usage_danger_boundary = \
            internal_conf.node_system_ram_usage_danger_boundary
        self._node_system_ram_usage_safe_boundary = \
            internal_conf.node_system_ram_usage_safe_boundary
        self._node_system_storage_usage_danger_boundary = \
            internal_conf.node_system_storage_usage_danger_boundary
        self._node_system_storage_usage_safe_boundary = \
            internal_conf.node_system_storage_usage_safe_boundary