示例#1
0
 def tearDown(self):
     """
     Clears the database after the test.
     """
     self.evt_pool_manager.close()
     remove(TestEvtPoolManager.db_file)
     TestEvtPoolManager.PROCESSED = []
    def prepare_test(self):
        self.__config = fetch_config(inject_contract=True)
        self.__audit_node = QSPAuditNode(self.__config)
        self.__audit_node.config._Config__upload_provider = DummyProvider()
        self.__mk_unique_storage_dir()

        # Forces analyzer wrapper to always execute their `once` script prior
        # to executing `run`
        for analyzer in self.__config.analyzers:
            remove(analyzer.wrapper.storage_dir + '/.once')

        self.__getNextAuditRequest_filter = \
            self.__config.audit_contract.events.getNextAuditRequest_called.createFilter(
                fromBlock=max(0, self.__config.event_pool_manager.get_latest_block_number())
            )
        self.__submitReport_filter = \
            self.__config.audit_contract.events.submitReport_called.createFilter(
                fromBlock=max(0, self.__config.event_pool_manager.get_latest_block_number())
            )
        self.__setAnyRequestAvailableResult_filter = \
            self.__config.audit_contract.events.setAnyRequestAvailableResult_called.createFilter(
                fromBlock=max(0, self.__config.event_pool_manager.get_latest_block_number())
            )

        # Disables the claim rewards threading from continuously running ahead;
        # negate the default mocking behaviour of always having rewards
        # available
        claim_rewards_instance = ClaimRewardsThread(self.__config)
        claim_rewards_instance._ClaimRewardsThread__has_available_rewards = MagicMock(
        )
        claim_rewards_instance._ClaimRewardsThread__has_available_rewards.return_value = False
        replace_thread(self.__audit_node, ClaimRewardsThread,
                       claim_rewards_instance)

        def exec_audit_node():
            self.__audit_node.start()

        audit_node_thread = Thread(target=exec_audit_node, name="Audit node")
        audit_node_thread.start()

        max_initialization_seconds = 5
        num_checks = 0
        while not self.__audit_node.is_initialized:
            sleep(TestQSPAuditNode.__SLEEP_INTERVAL)
            num_checks += 100
            if num_checks == max_initialization_seconds:
                self.__audit_node.stop()
                raise Exception("Node threads could not be initialized")
示例#3
0
 def setUpClass(cls):
     cfg = load_yaml(fetch_file(resource_uri("test_config.yaml")))
     TestEvtPoolManager.db_file = config_value(cfg, '/dev/evt_db_path')
     remove(TestEvtPoolManager.db_file)
示例#4
0
 def setUpClass(cls):
     QSPTest.setUpClass()
     config = fetch_config(inject_contract=True)
     remove(config.evt_db_path)
示例#5
0
    def tearDown(self):
        if self.__audit_node.exec:
            self.__audit_node.stop()

        remove(self.__config.evt_db_path)
示例#6
0
 def tearDown(self):
     """
     Stops the execution of the current QSP audit node.
     """
     self.__audit_node.stop()
     remove(self.__config.evt_db_path)
示例#7
0
    def tearDown(self):
        if self.__claim_rewards_thread.exec:
            self.__claim_rewards_thread.stop()

        remove(self.__config.evt_db_path)
 def tearDown(self):
     """
     Clears the database after the test.
     """
     self.worker.close()
     remove(TestSqlLite3Worker.db_file)
 def setUpClass(cls):
     QSPTest.setUpClass()
     cfg = load_yaml(fetch_file(resource_uri("test_config.yaml")))
     TestSqlLite3Worker.db_file = config_value(cfg, '/dev/evt_db_path')
     remove(TestSqlLite3Worker.db_file)