def test_get_daemon_status(self, mock_post, snapshot ): mock_post.return_value = self._mock_response(json_data={"data": "foo"}) client = Client() client.get_daemon_status() snapshot.assert_match(mock_post.call_args_list)
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='|%(asctime)s| %(message)s') logger = logging.getLogger(__name__) c = yaml.load(open('config.yml', encoding='utf8'), Loader=yaml.SafeLoader) logger.info("version 1.1") WORKER_PUB_KEY = c["WORKER_PUB_KEY"] WORKER_FEE = c["WORKER_FEE"] CHECK_PERIOD_SEC = c["CHECK_PERIOD_SEC"] STOP_WORKER_FOR_MIN = c["STOP_WORKER_FOR_MIN"] STOP_WORKER_BEFORE_MIN = c["STOP_WORKER_BEFORE_MIN"] GRAPHQL_HOST = c["GRAPHQL_HOST"] GRAPHQL_PORT = c["GRAPHQL_PORT"] coda = Client(graphql_host=GRAPHQL_HOST, graphql_port=GRAPHQL_PORT) daemon_status = coda.get_daemon_status() if type(WORKER_PUB_KEY) is not str or len(WORKER_PUB_KEY) != 55: try: WORKER_PUB_KEY = daemon_status["daemonStatus"]["snarkWorker"] BLOCK_PROD_KEY = daemon_status["daemonStatus"]["blockProductionKeys"][ 0] if WORKER_PUB_KEY is None: logger.info( f'Worker public key is None\n' f'Automatically apply Block production key to {WORKER_PUB_KEY}' ) WORKER_PUB_KEY = BLOCK_PROD_KEY worker_manager(mode="on")