diff --git a/DEV_config.json b/DEV_config.json index 7a2fac46289d15acb4b86752e99a0a58a3c4859e..4c6750c2e1365cd0b03cbd278c79f678dad6129f 100644 --- a/DEV_config.json +++ b/DEV_config.json @@ -6,91 +6,91 @@ }, "upstreams": [ { - "name": "steemd", + "name": "hived", "translate_to_appbase": true, "urls": [ [ - "steemd", - "https://api.steemit.com" + "hived", + "https://api.hive.blog" ] ], "ttls": [ [ - "steemd", + "hived", 3 ], [ - "steemd.login_api", + "hived.login_api", -1 ], [ - "steemd.network_broadcast_api", + "hived.network_broadcast_api", -1 ], [ - "steemd.follow_api", + "hived.follow_api", 10 ], [ - "steemd.market_history_api", + "hived.market_history_api", 1 ], [ - "steemd.database_api", + "hived.database_api", 3 ], [ - "steemd.database_api.get_block", + "hived.database_api.get_block", -2 ], [ - "steemd.database_api.get_block_header", + "hived.database_api.get_block_header", -2 ], [ - "steemd.database_api.get_content", + "hived.database_api.get_content", 1 ], [ - "steemd.database_api.get_state", + "hived.database_api.get_state", 1 ], [ - "steemd.database_api.get_state.params=['/trending']", + "hived.database_api.get_state.params=['/trending']", 30 ], [ - "steemd.database_api.get_state.params=['trending']", + "hived.database_api.get_state.params=['trending']", 30 ], [ - "steemd.database_api.get_state.params=['/hot']", + "hived.database_api.get_state.params=['/hot']", 30 ], [ - "steemd.database_api.get_state.params=['/welcome']", + "hived.database_api.get_state.params=['/welcome']", 30 ], [ - "steemd.database_api.get_state.params=['/promoted']", + "hived.database_api.get_state.params=['/promoted']", 30 ], [ - "steemd.database_api.get_state.params=['/created']", + "hived.database_api.get_state.params=['/created']", 10 ], [ - "steemd.database_api.get_dynamic_global_properties", + "hived.database_api.get_dynamic_global_properties", 1 ] ], "timeouts": [ [ - "steemd", + "hived", 5 ], [ - "steemd.network_broadcast_api", + "hived.network_broadcast_api", 0 ] ] @@ -100,7 +100,7 @@ "urls": [ [ "appbase", - "https://api.steemit.com" + "https://api.hive.blog" ] ], "ttls": [ diff --git a/Dockerfile b/Dockerfile index 168639e445590bd6b2c60ce21a20440585790370..46d4677a3e45531aa7fb03aaf9444564cecbf7b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -92,7 +92,7 @@ RUN \ WORKDIR /app -RUN pipenv install --dev +RUN pipenv install --dev # && pipenv graph # for debugging RUN chown -R www-data . && \ apt-get remove -y \ diff --git a/EXAMPLE_hivemind_upstream_config.json b/EXAMPLE_hivemind_upstream_config.json index fa82760175bce127d27c6d2d14a4dfdcd639c4d3..368cacf0a8fc1633c27d78bde72277cf62a449af 100644 --- a/EXAMPLE_hivemind_upstream_config.json +++ b/EXAMPLE_hivemind_upstream_config.json @@ -6,23 +6,23 @@ }, "upstreams": [ { - "name": "steemd", + "name": "hived", "translate_to_appbase": true, "urls": [ [ - "steemd", - "https://your.steemd.url" + "hived", + "https://your.hived.url" ] ], "ttls": [ [ - "steemd", + "hived", 3 ] ], "timeouts": [ [ - "steemd", + "hived", 3 ] ] @@ -32,19 +32,19 @@ "urls": [ [ "appbase", - "https://your.steemd.url" + "https://your.hived.url" ], [ "appbase.account_history_api", - "https://your.account.history.steemd.url" + "https://your.account.history.hived.url" ], [ "appbase.condenser_api.get_account_history", - "https://your.account.history.steemd.url" + "https://your.account.history.hived.url" ], [ "appbase.condenser_api.get_ops_in_block", - "https://your.account.history.steemd.url" + "https://your.account.history.hived.url" ], [ "appbase.condenser_api.get_followers", @@ -124,19 +124,19 @@ ], [ "appbase.condenser_api.get_state.params=['witnesses']", - "https://your.account.history.steemd.url" + "https://your.account.history.hived.url" ], [ "appbase.condenser_api.get_state.params=['/witnesses']", - "https://your.account.history.steemd.url" + "https://your.account.history.hived.url" ], [ "appbase.condenser_api.get_state.params=['/~witnesses']", - "https://your.account.history.steemd.url" + "https://your.account.history.hived.url" ], [ "appbase.condenser_api.get_state.params=['~witnesses']", - "https://your.account.history.steemd.url" + "https://your.account.history.hived.url" ], [ "appbase.follow_api", diff --git a/Makefile b/Makefile index d3c2ea8244ffd1472621903c0073a0fed1c6c19a..44a0b1680ac377ec35522bd0047d9dd162a8185e 100644 --- a/Makefile +++ b/Makefile @@ -132,8 +132,8 @@ mypy: ## run mypy type checking on python files http --json :9000/ id:=1 jsonrpc=2.0 method=get_block params:='[1000]' -.PHONY: test-local-steemd-calls -test-local-steemd-calls: +.PHONY: test-local-hived-calls +test-local-hived-calls: pipenv run pytest -vv tests/test_responses.py::test_steemd_responses --jussiurl http://localhost:9000 .PHONY: test-local-appbase-calls diff --git a/Pipfile b/Pipfile index ad580175866db1894519091fc7fa0126d9ea5f8b..09c16a520bb133b8b0b757cef6c42d1796bd3507 100644 --- a/Pipfile +++ b/Pipfile @@ -1,5 +1,5 @@ [[source]] -url = "https://pypi.python.org/simple" +url = "https://pypi.org/simple" verify_ssl = true [dev-packages] @@ -31,7 +31,7 @@ pytest-cov = "==2.6.0" pytest-docker = "==0.6.1" pytest-mock = "==1.10.0" pytest-profiling = "*" -pytest-pylint = "*" +pytest-pylint = "==0.14.1" pytest-sanic = "==0.1.13" pytest-timeout = "*" python-rapidjson = "*" diff --git a/README.md b/README.md index aec7f3e20c387d60b0f1d44dae60f3e288167c93..50ae8dba13f4a362cc29c956f48ae603d8932d3b 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Content-Type: application/json ``` ### Default Namespace -Any json-rpc method with no period in the method name is presumed to be in the "steemd" namespace and will be forwarded to a steemd endpoint: +Any json-rpc method with no period in the method name is presumed to be in the "hived" namespace and will be forwarded to a hived endpoint: ``` POST / HTTP/1.1 @@ -147,4 +147,4 @@ Certain features of jussi can be configured using environment variables. If you ## Additional documentation -For more indepth documentation on jussi including examples, check out the section on it in the steem dev portal: https://developers.hive.io/services/#services-jussi +For more indepth documentation on jussi including examples, check out the section on it in the Hive dev portal: https://developers.hive.io/services/#services-jussi diff --git a/build.sh b/build.sh index db17a15ba32d5825b55a8c2ff49ddfe38a2ea9a6..776f4923812fc01a15e50452ae283d857d7f3241 100755 --- a/build.sh +++ b/build.sh @@ -1,9 +1,62 @@ -echo Build started on `date` -export IMAGE_TAG=`git ls-remote --heads origin | grep $(git rev-parse HEAD) | cut -d / -f 3` +#!/usr/bin/env bash +############################################################################################## +# Quick Docker build script for Jussi. Builds Jussi as a docker container. +# +# By default, the image will be tagged as 'hive/jussi:TAG' - where 'TAG' is the current +# Git branch / tag. +# If 'master' is checked out, then TAG will be changed to 'latest'. +# +# You can override the Docker image tag like so: +# +# # These will both simply tag the image as 'jussi' - no user/org, and no version tag +# # (the version tag would default to :latest) +# ./build.sh jussi +# DK_TAG_FULL=jussi ./build.sh +# +# # This will tag the image as 'someguy123/jussi:v1.2.3' +# IMAGE_USER="someguy123" IMAGE_TAG="v1.2.3" ./build.sh +# +# # This will tag the image as 'example/my-jussi:TAG' - where TAG will be +# # automatically determined from the git branch/tag. +# REPO_NAME="my-jussi" IMAGE_USER="example" ./build.sh +# +# # You can override the entire USER/REPO portion of the tag by setting IMAGE_REPO_NAME +# # This would tag the image as 'jollypirate/custom-jussi:TAG' (TAG from git branch/tag) +# IMAGE_REPO_NAME="jollypirate/custom-jussi" ./build.sh +# +############################################################################################## + +# This variable detects the folder containing this script, allowing us to reference the containing folder, +# making it possible to run build.sh from any other folder, without causing path issues. +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo "Build started on $(date)" + +# Enter the folder containing this script +cd "$DIR" + +: ${IMAGE_USER="hive"} + +[ -z ${IMAGE_TAG+x} ] && IMAGE_TAG=`git ls-remote --heads origin | grep $(git rev-parse HEAD) | cut -d / -f 3` if [ "$IMAGE_TAG" = "master" ] ; then export IMAGE_TAG=latest ; fi -export REPO_PATH=`git rev-parse --show-toplevel` -export REPO_NAME=`basename $REPO_PATH` -export IMAGE_REPO_NAME="steemit/$REPO_NAME" -export SOURCE_COMMIT=`git rev-parse HEAD` -echo Building branch $IMAGE_TAG from $IMAGE_REPO_NAME -docker build . -t $IMAGE_REPO_NAME:$IMAGE_TAG --build-arg SOURCE_COMMIT="${SOURCE_COMMIT}" --build-arg DOCKER_TAG="${IMAGE_TAG}" +[ -z ${REPO_PATH+x} ] && REPO_PATH=`git rev-parse --show-toplevel` +[ -z ${REPO_NAME+x} ] && REPO_NAME=`basename $REPO_PATH` +: ${IMAGE_REPO_NAME="${IMAGE_USER}/${REPO_NAME}"} +SOURCE_COMMIT=`git rev-parse HEAD` + + +if (( $# > 0 )); then + echo -e "\nUsing docker tag specified as first argument: $1 \n" + DK_TAG_FULL="$1" +fi + +: ${DK_TAG_FULL="${IMAGE_REPO_NAME}:${IMAGE_TAG}"} + +export IMAGE_USER IMAGE_TAG REPO_PATH REPO_NAME IMAGE_REPO_NAME SOURCE_COMMIT DK_TAG_FULL + +echo "Building branch $IMAGE_TAG as docker image $DK_TAG_FULL" +docker build . -t "$DK_TAG_FULL" --build-arg SOURCE_COMMIT="${SOURCE_COMMIT}" --build-arg DOCKER_TAG="${IMAGE_TAG}" + +# Return to the CWD the user was in prior to running this script. +cd - &> /dev/null + diff --git a/contrib/async_http_client.py b/contrib/async_http_client.py index 372d2376b545181ba0002a3b05e9ebc09cdab4c9..288c8affcd7766e225ae7dd784f3589450604022 100644 --- a/contrib/async_http_client.py +++ b/contrib/async_http_client.py @@ -234,7 +234,7 @@ class AsyncClient(object): @property def concurrent_connections(self): - """number of tcp connections to steemd""" + """number of tcp connections to hived""" return self.connector.limit @property diff --git a/jussi/cache/ttl.py b/jussi/cache/ttl.py index b78a1af34fbd5cfc5e0816a8883b191cc404a479..1ed38698461e271cce84dd1207cfeaec5d5679fe 100644 --- a/jussi/cache/ttl.py +++ b/jussi/cache/ttl.py @@ -3,7 +3,7 @@ Method Settings --------------- - Each tuple in the METHOD_SETTING's list of tuples is a setting -- Each setting is a two-tuple of `prefix` and `ttl`, eg, ('steemd.database_api.get_block',1) +- Each setting is a two-tuple of `prefix` and `ttl`, eg, ('hived.database_api.get_block',1) - Settings are stored in a trie structure, the longest matching prefix for a method is it's setting - TTL is an integer value in seconds. Integers <= 0 have special meaning - A TTL of `0` won't expire diff --git a/jussi/cache/utils.py b/jussi/cache/utils.py index 6a3bfe2aae356cccaed6947b6f501ed0aaf7c664..2725b8edd8cbe98feae656bf2d33efa3c79517db 100644 --- a/jussi/cache/utils.py +++ b/jussi/cache/utils.py @@ -54,12 +54,12 @@ def block_num_from_jsonrpc_response( if previous: return int(str(previous)[:8], base=16) + 1 - # for steemd get_block + # for hived get_block block_id = get_in(['result', 'block_id'], jsonrpc_response) if block_id: return int(str(block_id)[:8], base=16) - # for steemd get_block_header + # for hived get_block_header previous = get_in(['result', 'previous'], jsonrpc_response) if previous: diff --git a/jussi/upstream.py b/jussi/upstream.py index e25ff584e84ec03aee2a5a01dcad6806c4aa297d..4f3a3d2a23b3c40aa69eb770ab0f24e2f0beff67 100644 --- a/jussi/upstream.py +++ b/jussi/upstream.py @@ -88,7 +88,7 @@ class _Upstreams(object): @functools.lru_cache(8192) def url(self, request_urn) -> str: - # certain steemd.get_state paths must be routed differently + # certain hived.get_state paths must be routed differently if (request_urn.api in ['database_api', 'condenser_api'] and request_urn.method == 'get_state' and isinstance(request_urn.params, list) diff --git a/jussi/urn.py b/jussi/urn.py index 3a303416e6deb0fbaba6bedddf8e6d6a45d87711..241153078d90259f185129f237a8d2b29debff94 100644 --- a/jussi/urn.py +++ b/jussi/urn.py @@ -117,7 +117,7 @@ def _parse_jrpc(single_jsonrpc_request) -> dict: if method != 'call': return { - 'namespace': 'steemd', + 'namespace': 'hived', 'api': 'database_api', 'method': method, 'params': params @@ -132,12 +132,12 @@ def _parse_jrpc(single_jsonrpc_request) -> dict: if api == 'condenser_api' or isinstance(_params, dict) or api == 'jsonrpc': namespace = 'appbase' else: - namespace = 'steemd' + namespace = 'hived' if isinstance(api, int): try: api = STEEMD_NUMERIC_API_MAPPING[api] except IndexError: - raise InvalidNamespaceAPIError(namespace='steemd', + raise InvalidNamespaceAPIError(namespace='hived', api=api) return { diff --git a/jussi/validators.py b/jussi/validators.py index 9e5c08691ae5f89f80d98aad46a1543474dc5754..13421f8652d70f597afe14d810b96ffe6928a182 100644 --- a/jussi/validators.py +++ b/jussi/validators.py @@ -112,17 +112,17 @@ def is_valid_non_error_jussi_response( def is_get_block_request(request: JSONRPCRequest) -> bool: - return request.urn.namespace in ('steemd', 'appbase') and request.urn.method == 'get_block' + return request.urn.namespace in ('hived', 'appbase') and request.urn.method == 'get_block' def is_get_block_header_request(request: JSONRPCRequest) -> bool: return request.urn.namespace in ( - 'steemd', 'appbase') and request.urn.method == 'get_block_header' + 'hived', 'appbase') and request.urn.method == 'get_block_header' def is_get_dynamic_global_properties_request(request: JSONRPCRequest) -> bool: return request.urn.namespace in ( - 'steemd', 'appbase') and request.urn.method == 'get_dynamic_global_properties' + 'hived', 'appbase') and request.urn.method == 'get_dynamic_global_properties' def is_valid_get_block_response( @@ -184,18 +184,22 @@ def limit_broadcast_transaction_request(request: JSONRPCRequest, limits=None) -> else: raise ValueError( f'Unknown request params type: {type(request.urn.params)} urn:{request.urn}') - ops = [op for op in request_params['operations'] if op[0] == 'custom_json'] - if not ops: - return - blacklist_accounts = set() - try: - blacklist_accounts = limits['accounts_blacklist'] - except Exception as e: - logger.warning('using empty accounts_blacklist', e=e, - jid=request.jussi_request_id, ) - - limit_custom_json_op_length(ops, size_limit=CUSTOM_JSON_SIZE_LIMIT) - limit_custom_json_account(ops, blacklist_accounts=blacklist_accounts) + ops = [] + for op in request_params['operations']: + if isinstance(op, list) and op[0] == 'custom_json': + ops.append(op) + if isinstance(op, dict) and op['type'] == 'custom_json': + ops.append(op) + if ops: + blacklist_accounts = set() + try: + blacklist_accounts = limits['accounts_blacklist'] + except Exception as e: + logger.warning('using empty accounts_blacklist', e=e, + jid=request.jussi_request_id, ) + + limit_custom_json_op_length(ops, size_limit=CUSTOM_JSON_SIZE_LIMIT) + limit_custom_json_account(ops, blacklist_accounts=blacklist_accounts) def limit_custom_json_op_length(ops: list, size_limit=None): diff --git a/tests/conftest.py b/tests/conftest.py index 0b8a66e7a9f3cb0a66e5be1b408cd932439f01be..46a0d9116e4c9c037606aa4b41cb0536cf4d1c0d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -103,7 +103,7 @@ def jrpc_response_schema(): @pytest.fixture def steemd_response_schema(): - with open(os.path.join(SCHEMA_DIR, 'steemd-response-schema.json')) as f: + with open(os.path.join(SCHEMA_DIR, 'hived-response-schema.json')) as f: return ujson.load(f) @@ -116,7 +116,7 @@ with open(os.path.join(CONFIGS_DIR, 'TEST_UPSTREAM_CONFIG.json')) as f: # ------------------------ def steemd_requests_and_responses(): - with open(os.path.join(REQS_AND_RESPS_DIR, 'steemd.json')) as f: + with open(os.path.join(REQS_AND_RESPS_DIR, 'hived.json')) as f: return ujson.load(f) @@ -1125,25 +1125,25 @@ URN_TEST_REQUEST_DICTS = [ 3 ), - # -------- STEEMD BARE METHOD ---------------- - # steemd, bare method, no params + # -------- HIVED BARE METHOD ---------------- + # hived, bare method, no params ({ 'id': 5020, 'jsonrpc': '2.0', 'method': 'get_dynamic_global_properties' }, { - 'namespace': 'steemd', + 'namespace': 'hived', 'api': 'database_api', 'method': 'get_dynamic_global_properties', 'params': _empty }, - 'steemd.database_api.get_dynamic_global_properties', + 'hived.database_api.get_dynamic_global_properties', 'wss://steemd.steemitdev.com', 1, 3 ), - # steemd, bare method, empty params list + # hived, bare method, empty params list ({ 'id': 5021, 'jsonrpc': '2.0', @@ -1151,17 +1151,17 @@ URN_TEST_REQUEST_DICTS = [ 'params': [] }, { - 'namespace': 'steemd', + 'namespace': 'hived', 'api': 'database_api', 'method': 'get_dynamic_global_properties', 'params': [] }, - 'steemd.database_api.get_dynamic_global_properties.params=[]', + 'hived.database_api.get_dynamic_global_properties.params=[]', 'wss://steemd.steemitdev.com', 1, 3 ), - # steemd, bare method, params list + # hived, bare method, params list ({ 'id': 5022, 'jsonrpc': '2.0', @@ -1169,18 +1169,18 @@ URN_TEST_REQUEST_DICTS = [ 'params': [1] }, { - 'namespace': 'steemd', + 'namespace': 'hived', 'api': 'database_api', 'method': 'get_block', 'params': [1] }, - 'steemd.database_api.get_block.params=[1]', + 'hived.database_api.get_block.params=[1]', 'wss://steemd.steemitdev.com', -2, 3 ), - # steemd, bare_method, account transfer url + # hived, bare_method, account transfer url ({ "id": 5023, "jsonrpc": "2.0", @@ -1188,22 +1188,22 @@ URN_TEST_REQUEST_DICTS = [ "params": ["/@justinw/transfers"] }, { - 'namespace': 'steemd', + 'namespace': 'hived', 'api': 'database_api', 'method': 'get_state', 'params': ["/@justinw/transfers"] }, - 'steemd.database_api.get_state.params=["\/@justinw\/transfers"]', + 'hived.database_api.get_state.params=["\/@justinw\/transfers"]', 'account_transfer_url', 1, 3 ), - # -------- STEEMD METHOD=CALL ---------------- + # -------- HIVED METHOD=CALL ---------------- - # steemd, method=call, empty params list + # hived, method=call, empty params list ({ 'id': 5024, 'jsonrpc': '2.0', @@ -1211,17 +1211,17 @@ URN_TEST_REQUEST_DICTS = [ 'params': ['database_api', 'get_account_count', []] }, { - 'namespace': 'steemd', + 'namespace': 'hived', 'api': 'database_api', 'method': 'get_account_count', 'params': [] }, - 'steemd.database_api.get_account_count.params=[]', + 'hived.database_api.get_account_count.params=[]', 'wss://steemd.steemitdev.com', 3, 3 ), - # steemd numeric apis + # hived numeric apis ({ 'id': 5025, 'jsonrpc': '2.0', @@ -1229,12 +1229,12 @@ URN_TEST_REQUEST_DICTS = [ 'params': [1, "login", ["", ""]] }, { - 'namespace': 'steemd', + 'namespace': 'hived', 'api': 'login_api', 'method': 'login', 'params': ["", ""] }, - 'steemd.login_api.login.params=["",""]', + 'hived.login_api.login.params=["",""]', 'wss://steemd.steemitdev.com', -1, 3 @@ -1246,17 +1246,17 @@ URN_TEST_REQUEST_DICTS = [ 'params': [0, "find_accounts", []] }, { - 'namespace': 'steemd', + 'namespace': 'hived', 'api': 'database_api', 'method': 'find_accounts', 'params': [] }, - 'steemd.database_api.find_accounts.params=[]', + 'hived.database_api.find_accounts.params=[]', 'wss://steemd.steemitdev.com', 3, 3 ), - # steemd, method=call, account transfer url + # hived, method=call, account transfer url ({ "id": 5027, "jsonrpc": "2.0", @@ -1264,12 +1264,12 @@ URN_TEST_REQUEST_DICTS = [ "params": ["database_api", "get_state", [r"/@justinw/transfers"]] }, { - 'namespace': 'steemd', + 'namespace': 'hived', 'api': 'database_api', 'method': 'get_state', 'params': ["/@justinw/transfers"] }, - 'steemd.database_api.get_state.params=["\/@justinw\/transfers"]', + 'hived.database_api.get_state.params=["\/@justinw\/transfers"]', 'account_transfer_url', 1, 3 diff --git a/tests/data/configs/TEST_UPSTREAM_CONFIG.json b/tests/data/configs/TEST_UPSTREAM_CONFIG.json index 556fb07925aea537ec3bac5c1068b63906c0d54a..3aca04dda292a292f0509c5912fe54613fe63ece 100644 --- a/tests/data/configs/TEST_UPSTREAM_CONFIG.json +++ b/tests/data/configs/TEST_UPSTREAM_CONFIG.json @@ -4,90 +4,90 @@ }, "upstreams": [ { - "name": "steemd", + "name": "hived", "urls": [ [ - "steemd", + "hived", "wss://steemd.steemitdev.com" ] ], "ttls": [ [ - "steemd", + "hived", 3 ], [ - "steemd.login_api", + "hived.login_api", -1 ], [ - "steemd.network_broadcast_api", + "hived.network_broadcast_api", -1 ], [ - "steemd.follow_api", + "hived.follow_api", 10 ], [ - "steemd.market_history_api", + "hived.market_history_api", 1 ], [ - "steemd.database_api", + "hived.database_api", 3 ], [ - "steemd.database_api.get_block", + "hived.database_api.get_block", -2 ], [ - "steemd.database_api.get_block_header", + "hived.database_api.get_block_header", -2 ], [ - "steemd.database_api.get_content", + "hived.database_api.get_content", 1 ], [ - "steemd.database_api.get_state", + "hived.database_api.get_state", 1 ], [ - "steemd.database_api.get_state.params=['/trending']", + "hived.database_api.get_state.params=['/trending']", 30 ], [ - "steemd.database_api.get_state.params=['trending']", + "hived.database_api.get_state.params=['trending']", 30 ], [ - "steemd.database_api.get_state.params=['/hot']", + "hived.database_api.get_state.params=['/hot']", 30 ], [ - "steemd.database_api.get_state.params=['/welcome']", + "hived.database_api.get_state.params=['/welcome']", 30 ], [ - "steemd.database_api.get_state.params=['/promoted']", + "hived.database_api.get_state.params=['/promoted']", 30 ], [ - "steemd.database_api.get_state.params=['/created']", + "hived.database_api.get_state.params=['/created']", 10 ], [ - "steemd.database_api.get_dynamic_global_properties", + "hived.database_api.get_dynamic_global_properties", 1 ] ], "timeouts": [ [ - "steemd", + "hived", 3 ], [ - "steemd.network_broadcast_api", + "hived.network_broadcast_api", 0 ] ] diff --git a/tests/data/jsonrpc/steemd.json b/tests/data/jsonrpc/hived.json similarity index 100% rename from tests/data/jsonrpc/steemd.json rename to tests/data/jsonrpc/hived.json diff --git a/tests/data/schema/steemd-response-schema.json b/tests/data/schema/hived-response-schema.json similarity index 100% rename from tests/data/schema/steemd-response-schema.json rename to tests/data/schema/hived-response-schema.json diff --git a/tests/data/schema/steemd_schema.json b/tests/data/schema/hived_schema.json similarity index 99% rename from tests/data/schema/steemd_schema.json rename to tests/data/schema/hived_schema.json index d24252c51b0a4367faf5a14a99e1152a715b71e3..8d96873fd830c5936d5ff44cbb97d5d18211c0a3 100644 --- a/tests/data/schema/steemd_schema.json +++ b/tests/data/schema/hived_schema.json @@ -1,7 +1,7 @@ { "id": "https://schema.steemitdev/blockchain/block.json", "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Steem Blockchain Schema", + "title": "Hive Blockchain Schema", "type": "object", "properties": { "transaction_merkle_root": { diff --git a/tests/test_cache_middleware.py b/tests/test_cache_middleware.py index a8158f90f59884c6d18e3b069ad25de1ed0727ee..a57a56491ba0c49af1f391206ee9a5fa236d3b4c 100644 --- a/tests/test_cache_middleware.py +++ b/tests/test_cache_middleware.py @@ -85,7 +85,7 @@ async def test_cache_response_middleware(test_cli): response = await test_cli.post('/', json=req) assert await response.json() == expected_steemd_response response = await test_cli.post('/', json=req) - assert response.headers['x-jussi-cache-hit'] == 'steemd.database_api.get_dynamic_global_properties' + assert response.headers['x-jussi-cache-hit'] == 'hived.database_api.get_dynamic_global_properties' async def test_mocked_cache_response_middleware(mocked_app_test_cli): @@ -96,5 +96,5 @@ async def test_mocked_cache_response_middleware(mocked_app_test_cli): assert await response.json() == expected_response response = await test_cli.post('/', json=req, headers={'x-jussi-request-id': '1'}) - assert response.headers['x-jussi-cache-hit'] == 'steemd.database_api.get_dynamic_global_properties' + assert response.headers['x-jussi-cache-hit'] == 'hived.database_api.get_dynamic_global_properties' assert await response.json() == expected_response diff --git a/tests/test_jsonrpc_request_and_responses.py b/tests/test_jsonrpc_request_and_responses.py index 52e655ab95df1534a22655015206780fe5f743bb..58f78f6108a47950e63f14b17630aab041204e1a 100644 --- a/tests/test_jsonrpc_request_and_responses.py +++ b/tests/test_jsonrpc_request_and_responses.py @@ -22,11 +22,11 @@ correct_get_block_1000_response = { 'jsonrpc_request, expected', [ ( - # single jsonrpc steemd request + # single jsonrpc hived request dict(id=1, jsonrpc='2.0', method='get_block', params=[1000]), correct_get_block_1000_response ), - # batch jsronrpc steemd request + # batch jsronrpc hived request ( [ dict(id=1, jsonrpc='2.0', method='get_block', params=[1000]), @@ -35,7 +35,7 @@ correct_get_block_1000_response = { [correct_get_block_1000_response, correct_get_block_1000_response] ), ( - # single jsonrpc old-style steemd requests + # single jsonrpc old-style hived requests dict( id=1, jsonrpc='2.0', @@ -44,7 +44,7 @@ correct_get_block_1000_response = { correct_get_block_1000_response ), ( - # batch jsonrpc old-style steemd request + # batch jsonrpc old-style hived request [ dict( id=1, @@ -60,7 +60,7 @@ correct_get_block_1000_response = { [correct_get_block_1000_response, correct_get_block_1000_response] ), ( - # batch jsonrpc mixed-style steemd request + # batch jsonrpc mixed-style hived request [ dict(id=1, jsonrpc='2.0', method='get_block', params=[1000]), dict(id=1, jsonrpc='2.0', method='call', params=[ diff --git a/tests/test_jussi_handlers.py b/tests/test_jussi_handlers.py index 9171eef2bf9b29fb036e5a3c5344c836fcaece15..2fffb9d5f516af1cdcfa5474caee9b365b74054c 100644 --- a/tests/test_jussi_handlers.py +++ b/tests/test_jussi_handlers.py @@ -21,7 +21,7 @@ correct_get_block_1000_response = { test_request = { 'id': 1, 'jsonrpc': '2.0', - 'method': 'steemd.fake_method' + 'method': 'hived.fake_method' } error_response1 = {'id': 1, 'jsonrpc': '2.0', 'error': { diff --git a/tests/test_jussi_request_response_middleware.py b/tests/test_jussi_request_response_middleware.py index 2221f23077da290ed77dba1116af2922b80045ce..55bce2ae9a3e28a5d9195cdbfe234db1b4a5eb59 100644 --- a/tests/test_jussi_request_response_middleware.py +++ b/tests/test_jussi_request_response_middleware.py @@ -158,7 +158,7 @@ def test_urn_parts_in_post_response_headers(): _, response = app.test_client.post('/post', json=req) assert 'x-jussi-request-id' in response.headers - assert response.headers['x-jussi-namespace'] == 'steemd', f'{response.headers}' + assert response.headers['x-jussi-namespace'] == 'hived', f'{response.headers}' assert response.headers['x-jussi-api'] == 'database_api', f'{response.headers}' assert response.headers['x-jussi-method'] == 'get_block', f'{response.headers}' assert response.headers['x-jussi-params'] == '[1000]', f'{response.headers}' diff --git a/tests/test_urn.py b/tests/test_urn.py index 203b927b98e3227229063321dee7a0540cd83d54..979fb956622d2c1382a5f2fb29ee2721b19c3051 100644 --- a/tests/test_urn.py +++ b/tests/test_urn.py @@ -45,7 +45,7 @@ def test_parse_jrpc_errors(jsonrpc_request, expected): def test_parse_jrpc_namespace_is_steemd(steemd_request_and_response): req, resp = steemd_request_and_response result = _parse_jrpc(req) - assert result['namespace'] == 'steemd' + assert result['namespace'] == 'hived' def test_parse_jrpc_namespace_is_appbase(appbase_request_and_response): diff --git a/tests/test_utils_namespaces.py b/tests/test_utils_namespaces.py index 6530c254d2c37d339843a28fb6a46b4e0d8aa2ae..8e66a35f0ba8b784a0adcb6b94ef99e2dba4ac03 100644 --- a/tests/test_utils_namespaces.py +++ b/tests/test_utils_namespaces.py @@ -17,30 +17,30 @@ def test_urns(urn_test_request_dict): @pytest.mark.parametrize("jsonrpc_request,expected", [ - # steemd, bare_method + # hived, bare_method ({'id': 1, 'jsonrpc': '2.0', 'method': 'get_account_count', 'params': []}, - 'steemd.database_api.get_account_count.params=[]' + 'hived.database_api.get_account_count.params=[]' ), - # steemd, method=call + # hived, method=call ({ 'id': 1, 'jsonrpc': '2.0', 'method': 'call', 'params': ['database_api', 'get_account_count', []] }, - 'steemd.database_api.get_account_count.params=[]' + 'hived.database_api.get_account_count.params=[]' ), - # steemd, method=call, numeric api + # hived, method=call, numeric api ({ 'id': 1, 'jsonrpc': '2.0', 'method': 'call', 'params': [0, 'get_account_count', []] }, - 'steemd.database_api.get_account_count.params=[]' + 'hived.database_api.get_account_count.params=[]' ), # appbase, dotted method, condenser api ({ @@ -50,7 +50,7 @@ def test_urns(urn_test_request_dict): }, 'appbase.condenser_api.appbase_method.params=[]' ), - # steemd, condenser api, method=call + # hived, condenser api, method=call ({ 'id': 1, 'jsonrpc': '2.0', @@ -107,9 +107,9 @@ def test_urn_params_empty_dict(jsonrpc_request, expected): @pytest.mark.parametrize("jsonrpc_request,expected", [ - # steemd, bare_method + # hived, bare_method ({'id': 1, 'jsonrpc': '2.0', 'method': 'get_dynamic_global_properties'}, - 'steemd.database_api.get_dynamic_global_properties' + 'hived.database_api.get_dynamic_global_properties' ), # appbase, dotted method, non-condenser api ({'id': 1, 'jsonrpc': '2.0', 'method': 'non_condenser_api.appbase_method'}, @@ -148,4 +148,4 @@ def test_urn_pairs(steemd_method_pairs): old_urn = str(from_request(old)) new_urn = str(from_request(new)) assert old_urn == new_urn - assert old_urn.startswith('steemd.database_api') + assert old_urn.startswith('hived.database_api')