From 28c25c3a67b5be95816866aded6fb3c5ff8ebd26 Mon Sep 17 00:00:00 2001 From: drcpu Date: Thu, 14 Mar 2024 19:46:00 +0100 Subject: [PATCH 1/6] [api] Add missing version header to the mempool endpoint when returning a cached response --- api/blueprints/transaction/mempool_blueprint.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/blueprints/transaction/mempool_blueprint.py b/api/blueprints/transaction/mempool_blueprint.py index 77d9273d..e5898688 100644 --- a/api/blueprints/transaction/mempool_blueprint.py +++ b/api/blueprints/transaction/mempool_blueprint.py @@ -54,7 +54,11 @@ def get(self, args): mempool = cache.get("transaction_mempool") if mempool: logger.info("Found the live mempool in our memcached instance") - return build_return_value(args["type"], mempool) + return ( + build_return_value(args["type"], mempool), + 200, + {"X-Version": "v1.0.0"}, + ) mempool = witnet_node.get_mempool() if "result" in mempool: From 450004d89f83c009c560806dcc6e805690b1e0e6 Mon Sep 17 00:00:00 2001 From: drcpu Date: Thu, 14 Mar 2024 19:46:47 +0100 Subject: [PATCH 2/6] [api] Update API version header from v1.0.0 to 1.0.0 --- api/__init__.py | 2 +- api/blueprints/address/blocks_blueprint.py | 4 +-- .../data_requests_created_blueprint.py | 4 +-- .../address/data_requests_solved_blueprint.py | 4 +-- api/blueprints/address/details_blueprint.py | 2 +- api/blueprints/address/info_blueprint.py | 4 +-- api/blueprints/address/labels_blueprint.py | 4 +-- api/blueprints/address/mints_blueprint.py | 4 +-- api/blueprints/address/utxos_blueprint.py | 2 +- .../address/value_transfers_blueprint.py | 4 +-- api/blueprints/misc/home_blueprint.py | 6 ++--- api/blueprints/misc/ping_blueprint.py | 2 +- api/blueprints/misc/status_blueprint.py | 2 +- api/blueprints/network/balances_blueprint.py | 2 +- .../network/blockchain_blueprint.py | 4 +-- api/blueprints/network/mempool_blueprint.py | 2 +- .../network/reputation_blueprint.py | 2 +- .../network/statistics_blueprint.py | 4 +-- api/blueprints/network/supply_blueprint.py | 4 +-- api/blueprints/network/tapi_blueprint.py | 2 +- api/blueprints/search/epoch_blueprint.py | 4 +-- api/blueprints/search/hash_blueprint.py | 26 +++++++++---------- .../transaction/mempool_blueprint.py | 4 +-- .../transaction/priority_blueprint.py | 4 +-- api/blueprints/transaction/send_blueprint.py | 4 +-- 25 files changed, 53 insertions(+), 53 deletions(-) diff --git a/api/__init__.py b/api/__init__.py index 660ce88d..cfbea8e5 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -50,7 +50,7 @@ def create_app(mock=False): # Configure app app.config["API_TITLE"] = "Witnet explorer REST API" - app.config["API_VERSION"] = "v1.0.0" + app.config["API_VERSION"] = "1.0.0" # Set configurations for OpenAPI documentation app.config["OPENAPI_VERSION"] = "3.0.3" diff --git a/api/blueprints/address/blocks_blueprint.py b/api/blueprints/address/blocks_blueprint.py index 462698a5..1bd4736a 100644 --- a/api/blueprints/address/blocks_blueprint.py +++ b/api/blueprints/address/blocks_blueprint.py @@ -65,7 +65,7 @@ def get(self, args, pagination_parameters): if cached_blocks: logger.info(f"Found {len(cached_blocks)} blocks for {arg_address} in cache") pagination_parameters.item_count = len(cached_blocks) - return cached_blocks[start:stop], 200, {"X-Version": "v1.0.0"} + return cached_blocks[start:stop], 200, {"X-Version": "1.0.0"} # Query the database and build the requested view (slow) else: logger.info( @@ -90,4 +90,4 @@ def get(self, args, pagination_parameters): message=f"Incorrect message format for block data for {arg_address}.", ) pagination_parameters.item_count = len(blocks) - return blocks[start:stop], 200, {"X-Version": "v1.0.0"} + return blocks[start:stop], 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/address/data_requests_created_blueprint.py b/api/blueprints/address/data_requests_created_blueprint.py index 3448f9cd..9af59ef6 100644 --- a/api/blueprints/address/data_requests_created_blueprint.py +++ b/api/blueprints/address/data_requests_created_blueprint.py @@ -70,7 +70,7 @@ def get(self, args, pagination_parameters): return ( cached_data_requests_created[start:stop], 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) # Query the database and build the requested view (slow) else: @@ -98,4 +98,4 @@ def get(self, args, pagination_parameters): message=f"Incorrect message format for data requests created data for {arg_address}.", ) pagination_parameters.item_count = len(data_requests_created) - return data_requests_created[start:stop], 200, {"X-Version": "v1.0.0"} + return data_requests_created[start:stop], 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/address/data_requests_solved_blueprint.py b/api/blueprints/address/data_requests_solved_blueprint.py index caec3f32..dd079354 100644 --- a/api/blueprints/address/data_requests_solved_blueprint.py +++ b/api/blueprints/address/data_requests_solved_blueprint.py @@ -67,7 +67,7 @@ def get(self, args, pagination_parameters): f"Found {len(cached_data_requests_solved)} data requests solved for {arg_address} in cache" ) pagination_parameters.item_count = len(cached_data_requests_solved) - return cached_data_requests_solved[start:stop], 200, {"X-Version": "v1.0.0"} + return cached_data_requests_solved[start:stop], 200, {"X-Version": "1.0.0"} # Query the database and build the requested view (slow) else: logger.info( @@ -92,4 +92,4 @@ def get(self, args, pagination_parameters): message=f"Incorrect message format for data requests solved data for {arg_address}.", ) pagination_parameters.item_count = len(data_requests_solved) - return data_requests_solved[start:stop], 200, {"X-Version": "v1.0.0"} + return data_requests_solved[start:stop], 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/address/details_blueprint.py b/api/blueprints/address/details_blueprint.py index dbc078c1..65f7e3b2 100644 --- a/api/blueprints/address/details_blueprint.py +++ b/api/blueprints/address/details_blueprint.py @@ -72,4 +72,4 @@ def get(self, args): 404, message=f"Incorrect message format for details data for {arg_address}.", ) - return details, 200, {"X-Version": "v1.0.0"} + return details, 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/address/info_blueprint.py b/api/blueprints/address/info_blueprint.py index a6ebab25..0e1edeb4 100644 --- a/api/blueprints/address/info_blueprint.py +++ b/api/blueprints/address/info_blueprint.py @@ -87,7 +87,7 @@ def get(self, args): ] ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError as err_info: logger.error( @@ -98,4 +98,4 @@ def get(self, args): message=f"Incorrect message format for address info for {addresses}.", ) else: - return [], 200, {"X-Version": "v1.0.0"} + return [], 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/address/labels_blueprint.py b/api/blueprints/address/labels_blueprint.py index eb6d8d50..ddcb5b0b 100644 --- a/api/blueprints/address/labels_blueprint.py +++ b/api/blueprints/address/labels_blueprint.py @@ -68,7 +68,7 @@ def get(self): ] ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError as err_info: logger.error( @@ -79,4 +79,4 @@ def get(self): message=f"Incorrect message format for address labels for {addresses}.", ) else: - return [], 200, {"X-Version": "v1.0.0"} + return [], 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/address/mints_blueprint.py b/api/blueprints/address/mints_blueprint.py index 60ac98bb..a979f320 100644 --- a/api/blueprints/address/mints_blueprint.py +++ b/api/blueprints/address/mints_blueprint.py @@ -67,7 +67,7 @@ def get(self, args, pagination_parameters): f"Found {len(cached_mints)} mint transactions for {arg_address} in cache" ) pagination_parameters.item_count = len(cached_mints) - return cached_mints[start:stop], 200, {"X-Version": "v1.0.0"} + return cached_mints[start:stop], 200, {"X-Version": "1.0.0"} # Query the database and build the requested view (slow) else: logger.info( @@ -92,4 +92,4 @@ def get(self, args, pagination_parameters): message=f"Incorrect message format for mint data for {arg_address}.", ) pagination_parameters.item_count = len(mints) - return mints[start:stop], 200, {"X-Version": "v1.0.0"} + return mints[start:stop], 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/address/utxos_blueprint.py b/api/blueprints/address/utxos_blueprint.py index 6763a57e..97205905 100644 --- a/api/blueprints/address/utxos_blueprint.py +++ b/api/blueprints/address/utxos_blueprint.py @@ -98,4 +98,4 @@ def get(self, args): ) abort(404, message=f"Incorrect message format for UTXO data for {address}.") - return address_utxos, 200, {"X-Version": "v1.0.0"} + return address_utxos, 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/address/value_transfers_blueprint.py b/api/blueprints/address/value_transfers_blueprint.py index f032b7b3..8b40c4e3 100644 --- a/api/blueprints/address/value_transfers_blueprint.py +++ b/api/blueprints/address/value_transfers_blueprint.py @@ -67,7 +67,7 @@ def get(self, args, pagination_parameters): f"Found {len(cached_value_transfers)} value transfers for {arg_address} in cache" ) pagination_parameters.item_count = len(cached_value_transfers) - return cached_value_transfers[start:stop], 200, {"X-Version": "v1.0.0"} + return cached_value_transfers[start:stop], 200, {"X-Version": "1.0.0"} # Query the database and build the requested view (slow) else: logger.info( @@ -92,4 +92,4 @@ def get(self, args, pagination_parameters): message=f"Incorrect message format for value transfer data for {arg_address}.", ) pagination_parameters.item_count = len(value_transfers) - return value_transfers[start:stop], 200, {"X-Version": "v1.0.0"} + return value_transfers[start:stop], 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/misc/home_blueprint.py b/api/blueprints/misc/home_blueprint.py index b5a87993..4f9095af 100644 --- a/api/blueprints/misc/home_blueprint.py +++ b/api/blueprints/misc/home_blueprint.py @@ -52,12 +52,12 @@ def get(self, args): logger.info("Found home in memcached cache") if key == "full": - return home, 200, {"X-Version": "v1.0.0"} + return home, 200, {"X-Version": "1.0.0"} elif key in ("network_stats", "supply_info"): - return {key: home[key]}, 200, {"X-Version": "v1.0.0"} + return {key: home[key]}, 200, {"X-Version": "1.0.0"} elif key in ("blocks", "data_requests", "value_transfers"): return ( {f"latest_{key}": home[f"latest_{key}"]}, 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) diff --git a/api/blueprints/misc/ping_blueprint.py b/api/blueprints/misc/ping_blueprint.py index 92d5d486..053be9ff 100644 --- a/api/blueprints/misc/ping_blueprint.py +++ b/api/blueprints/misc/ping_blueprint.py @@ -44,7 +44,7 @@ def get(self): return ( PingResponse().load({"response": "pong"}), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError as err_info: logger.error(f"Incorrect message format for ping response: {err_info}") diff --git a/api/blueprints/misc/status_blueprint.py b/api/blueprints/misc/status_blueprint.py index f124468d..6d227934 100644 --- a/api/blueprints/misc/status_blueprint.py +++ b/api/blueprints/misc/status_blueprint.py @@ -144,4 +144,4 @@ def get(self): else: logger.info("Found status in memcached cache") - return status, 200, {"X-Version": "v1.0.0"} + return status, 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/network/balances_blueprint.py b/api/blueprints/network/balances_blueprint.py index 04d30a19..62b41ac7 100644 --- a/api/blueprints/network/balances_blueprint.py +++ b/api/blueprints/network/balances_blueprint.py @@ -87,5 +87,5 @@ def get(self, pagination_parameters): } ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) diff --git a/api/blueprints/network/blockchain_blueprint.py b/api/blueprints/network/blockchain_blueprint.py index fb71da47..b4305136 100644 --- a/api/blueprints/network/blockchain_blueprint.py +++ b/api/blueprints/network/blockchain_blueprint.py @@ -61,7 +61,7 @@ def get(self, pagination_parameters): if blockchain: logger.info(f"Found {cache_key} in memcached cache") pagination_parameters.item_count = blockchain["total_epochs"] - return blockchain, 200, {"X-Version": "v1.0.0"} + return blockchain, 200, {"X-Version": "1.0.0"} logger.info(f"Could not find {cache_key} in memcached cache") @@ -113,7 +113,7 @@ def get(self, pagination_parameters): ) abort(404, message="Incorrect message format for blockchain response.") - return blockchain, 200, {"X-Version": "v1.0.0"} + return blockchain, 200, {"X-Version": "1.0.0"} def get_blockchain_details(database, last_epoch, start, stop, consensus_constants): diff --git a/api/blueprints/network/mempool_blueprint.py b/api/blueprints/network/mempool_blueprint.py index 9dec04d7..aa9036dd 100644 --- a/api/blueprints/network/mempool_blueprint.py +++ b/api/blueprints/network/mempool_blueprint.py @@ -106,7 +106,7 @@ def get(self, args): else: logger.info(f"Found {key} in memcached cache") - return mempool, 200, {"X-Version": "v1.0.0"} + return mempool, 200, {"X-Version": "1.0.0"} def get_historical_mempool( diff --git a/api/blueprints/network/reputation_blueprint.py b/api/blueprints/network/reputation_blueprint.py index 73b142a3..a9724b4a 100644 --- a/api/blueprints/network/reputation_blueprint.py +++ b/api/blueprints/network/reputation_blueprint.py @@ -96,4 +96,4 @@ def get(self): else: logger.info("Found reputation in our memcached instance.") - return reputation, 200, {"X-Version": "v1.0.0"} + return reputation, 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/network/statistics_blueprint.py b/api/blueprints/network/statistics_blueprint.py index 9c415f66..e6e818bc 100644 --- a/api/blueprints/network/statistics_blueprint.py +++ b/api/blueprints/network/statistics_blueprint.py @@ -120,7 +120,7 @@ def get(self, args): response = cache.get(cache_key) if response: logger.info(f"Found response for {cache_key} in cache") - return response, 200, {"X-Version": "v1.0.0"} + return response, 200, {"X-Version": "1.0.0"} # Rollbacks are saved as a list in the database, so even if epochs are specified, retrieve the complete list if args["key"] == "list-rollbacks": @@ -337,7 +337,7 @@ def get(self, args): f"Could not save {cache_key} in the memcached instance because its size exceeded 1MB" ) - return response, 200, {"X-Version": "v1.0.0"} + return response, 200, {"X-Version": "1.0.0"} def calculate_network_start_stop_epoch( diff --git a/api/blueprints/network/supply_blueprint.py b/api/blueprints/network/supply_blueprint.py index 3bda593e..3fb44c6b 100644 --- a/api/blueprints/network/supply_blueprint.py +++ b/api/blueprints/network/supply_blueprint.py @@ -57,10 +57,10 @@ def get(self, args): "epoch", "in_flight_requests", ): - return str(int(home["supply_info"][key])), 200, {"X-Version": "v1.0.0"} + return str(int(home["supply_info"][key])), 200, {"X-Version": "1.0.0"} else: return ( str(int(home["supply_info"][key] / 1e9)), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) diff --git a/api/blueprints/network/tapi_blueprint.py b/api/blueprints/network/tapi_blueprint.py index a481782d..95e08341 100644 --- a/api/blueprints/network/tapi_blueprint.py +++ b/api/blueprints/network/tapi_blueprint.py @@ -125,4 +125,4 @@ def get(self, args): f"Returning TAPI's {', '.join(str(tapi['tapi_id']) for tapi in all_tapis)}" ) - return all_tapis, 200, {"X-Version": "v1.0.0"} + return all_tapis, 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/search/epoch_blueprint.py b/api/blueprints/search/epoch_blueprint.py index 67656797..c8b4b6be 100644 --- a/api/blueprints/search/epoch_blueprint.py +++ b/api/blueprints/search/epoch_blueprint.py @@ -61,7 +61,7 @@ def get(self, args): logger.info( f"Found block {epoch} with hash {cached_block_hash} in memcached cache" ) - return cached_block, 200, {"X-Version": "v1.0.0"} + return cached_block, 200, {"X-Version": "1.0.0"} # Create consensus constants consensus_constants = ConsensusConstants( @@ -147,7 +147,7 @@ def get(self, args): } ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError as err_info: logger.error(f"Incorrect message format for block {epoch}: {err_info}") diff --git a/api/blueprints/search/hash_blueprint.py b/api/blueprints/search/hash_blueprint.py index b4671930..dd2a73b2 100644 --- a/api/blueprints/search/hash_blueprint.py +++ b/api/blueprints/search/hash_blueprint.py @@ -97,7 +97,7 @@ def get(self, args, pagination_parameters): ): found = True else: - return hashed_item, 200, {"X-Version": "v1.0.0"} + return hashed_item, 200, {"X-Version": "1.0.0"} sql = """ SELECT @@ -132,7 +132,7 @@ def get(self, args, pagination_parameters): } ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) elif hash_value in transactions_pool["value_transfer"]: return ( @@ -143,7 +143,7 @@ def get(self, args, pagination_parameters): } ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) else: logger.warning(f"Could not find transaction hash {hash_value}") @@ -228,7 +228,7 @@ def get(self, args, pagination_parameters): } ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError as err_info: logger.error(f"Incorrect message format for block: {err_info}") @@ -283,7 +283,7 @@ def get(self, args, pagination_parameters): {"response_type": "mint", "mint": mint_txn} ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError as err_info: logger.error( @@ -349,7 +349,7 @@ def get(self, args, pagination_parameters): } ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError as err_info: logger.error( @@ -393,7 +393,7 @@ def get(self, args, pagination_parameters): } ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError: abort( @@ -431,7 +431,7 @@ def get(self, args, pagination_parameters): return ( {"response_type": "commit", "commit": transaction}, 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError: abort( @@ -469,7 +469,7 @@ def get(self, args, pagination_parameters): return ( {"response_type": "reveal", "reveal": transaction}, 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError: abort( @@ -507,7 +507,7 @@ def get(self, args, pagination_parameters): return ( {"response_type": "tally", "tally": transaction}, 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError: abort( @@ -540,7 +540,7 @@ def get(self, args, pagination_parameters): logger.info( f"Found a data request report {data_request_hash} for a {hash_type.replace('_', ' ')} in our memcached instance" ) - return cached_data_request_report, 200, {"X-Version": "v1.0.0"} + return cached_data_request_report, 200, {"X-Version": "1.0.0"} try: data_request_report_json = data_request_report.get_report() @@ -602,7 +602,7 @@ def get(self, args, pagination_parameters): } ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError as err_info: logger.error( @@ -640,7 +640,7 @@ def get(self, args, pagination_parameters): } ), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) except ValidationError as err_info: logger.error( diff --git a/api/blueprints/transaction/mempool_blueprint.py b/api/blueprints/transaction/mempool_blueprint.py index e5898688..c9d90c94 100644 --- a/api/blueprints/transaction/mempool_blueprint.py +++ b/api/blueprints/transaction/mempool_blueprint.py @@ -57,7 +57,7 @@ def get(self, args): return ( build_return_value(args["type"], mempool), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) mempool = witnet_node.get_mempool() @@ -85,7 +85,7 @@ def get(self, args): return ( build_return_value(args["type"], mempool), 200, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) else: logger.error(f"Could not fetch the live mempool: {mempool['error']}") diff --git a/api/blueprints/transaction/priority_blueprint.py b/api/blueprints/transaction/priority_blueprint.py index 91fc722e..a4f772c4 100644 --- a/api/blueprints/transaction/priority_blueprint.py +++ b/api/blueprints/transaction/priority_blueprint.py @@ -78,11 +78,11 @@ def get(self, args): logger.info("Found 'priority' in memcached cache") if priority_key == "all": - return priority, 200, {"X-Version": "v1.0.0"} + return priority, 200, {"X-Version": "1.0.0"} else: filtered_priority = { key: priority[key] for key in priority.keys() if key.startswith(priority_key) } - return filtered_priority, 200, {"X-Version": "v1.0.0"} + return filtered_priority, 200, {"X-Version": "1.0.0"} diff --git a/api/blueprints/transaction/send_blueprint.py b/api/blueprints/transaction/send_blueprint.py index c302f9ea..d23e8cfd 100644 --- a/api/blueprints/transaction/send_blueprint.py +++ b/api/blueprints/transaction/send_blueprint.py @@ -111,7 +111,7 @@ def post(self, args): return ( ValueTransferResponse().load({"result": "Value transfer is valid."}), 201, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) else: response = witnet_node.send_vtt({"transaction": transaction}) @@ -130,7 +130,7 @@ def post(self, args): {"result": "Succesfully sent value transfer."} ), 201, - {"X-Version": "v1.0.0"}, + {"X-Version": "1.0.0"}, ) else: logger.error( From cf2c80eebfbcaaf1cd476903a0ca933a3c48beb1 Mon Sep 17 00:00:00 2001 From: drcpu Date: Thu, 14 Mar 2024 19:52:58 +0100 Subject: [PATCH 3/6] [tests] Add version assert to API tests --- tests/api/address/test_blocks.py | 4 ++ .../api/address/test_data_requests_created.py | 4 ++ .../api/address/test_data_requests_solved.py | 4 ++ tests/api/address/test_details.py | 1 + tests/api/address/test_info.py | 2 + tests/api/address/test_labels.py | 1 + tests/api/address/test_mints.py | 4 ++ tests/api/address/test_utxos.py | 2 + tests/api/address/test_value_transfers.py | 4 ++ tests/api/misc/test_home.py | 6 ++ tests/api/misc/test_ping.py | 1 + tests/api/misc/test_status.py | 2 + tests/api/network/test_balances.py | 3 + tests/api/network/test_blockchain.py | 5 ++ tests/api/network/test_mempool.py | 4 ++ tests/api/network/test_reputation.py | 2 + tests/api/network/test_statistics.py | 55 +++++++++++++++++++ tests/api/network/test_supply.py | 14 +++++ tests/api/network/test_tapi.py | 4 ++ tests/api/search/test_epoch.py | 3 + tests/api/search/test_hash.py | 29 ++++++++++ tests/api/transaction/test_mempool.py | 4 ++ tests/api/transaction/test_priority.py | 4 ++ tests/api/transaction/test_send.py | 2 + 24 files changed, 164 insertions(+) diff --git a/tests/api/address/test_blocks.py b/tests/api/address/test_blocks.py index de48597d..b16ce82d 100644 --- a/tests/api/address/test_blocks.py +++ b/tests/api/address/test_blocks.py @@ -6,6 +6,7 @@ def test_blocks_cached_page_1(client, address_data): assert client.application.extensions["cache"].get(f"{address}_blocks") is not None response = client.get(f"/api/address/blocks?address={address}&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, @@ -22,6 +23,7 @@ def test_blocks_cached_page_2(client, address_data): assert client.application.extensions["cache"].get(f"{address}_blocks") is not None response = client.get(f"/api/address/blocks?address={address}&page=2&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, @@ -39,6 +41,7 @@ def test_blocks_not_cached_page_1(client, address_data): assert client.application.extensions["cache"].get(f"{address}_blocks") is None response = client.get(f"/api/address/blocks?address={address}&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, @@ -56,6 +59,7 @@ def test_blocks_not_cached_page_2(client, address_data): assert client.application.extensions["cache"].get(f"{address}_blocks") is None response = client.get(f"/api/address/blocks?address={address}&page=2&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, diff --git a/tests/api/address/test_data_requests_created.py b/tests/api/address/test_data_requests_created.py index 29e1d916..1f5b3f12 100644 --- a/tests/api/address/test_data_requests_created.py +++ b/tests/api/address/test_data_requests_created.py @@ -9,6 +9,7 @@ def test_data_requests_created_cached_page_1(client, address_data): f"/api/address/data-requests-created?address={address}&page_size=5" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, @@ -30,6 +31,7 @@ def test_data_requests_created_cached_page_2(client, address_data): f"/api/address/data-requests-created?address={address}&page=2&page_size=5" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, @@ -52,6 +54,7 @@ def test_data_requests_created_not_cached_page_1(client, address_data): f"/api/address/data-requests-created?address={address}&page_size=5" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, @@ -74,6 +77,7 @@ def test_data_requests_created_not_cached_page_2(client, address_data): f"/api/address/data-requests-created?address={address}&page=2&page_size=5" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, diff --git a/tests/api/address/test_data_requests_solved.py b/tests/api/address/test_data_requests_solved.py index 71b1e88b..519df84a 100644 --- a/tests/api/address/test_data_requests_solved.py +++ b/tests/api/address/test_data_requests_solved.py @@ -9,6 +9,7 @@ def test_data_requests_solved_cached_page_1(client, address_data): f"/api/address/data-requests-solved?address={address}&page_size=5" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 6, "total_pages": 2, @@ -30,6 +31,7 @@ def test_data_requests_solved_cached_page_2(client, address_data): f"/api/address/data-requests-solved?address={address}&page=2&page_size=5" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 6, "total_pages": 2, @@ -52,6 +54,7 @@ def test_data_requests_solved_not_cached_page_1(client, address_data): f"/api/address/data-requests-solved?address={address}&page_size=5" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 6, "total_pages": 2, @@ -74,6 +77,7 @@ def test_data_requests_solved_not_cached_page_2(client, address_data): f"/api/address/data-requests-solved?address={address}&page=2&page_size=5" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 6, "total_pages": 2, diff --git a/tests/api/address/test_details.py b/tests/api/address/test_details.py index 55232b71..c232069e 100644 --- a/tests/api/address/test_details.py +++ b/tests/api/address/test_details.py @@ -5,4 +5,5 @@ def test_details(client, address_data): address = "wit10a4ynl3v39jpps9v2wlddg638xz55jzgr5algm" response = client.get(f"/api/address/details?address={address}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == address_data[address]["details"] diff --git a/tests/api/address/test_info.py b/tests/api/address/test_info.py index 6b0f0593..dcf75509 100644 --- a/tests/api/address/test_info.py +++ b/tests/api/address/test_info.py @@ -6,6 +6,7 @@ def test_info_existing_addresses(client): address_2 = "wit1drcpu2gf386tm29mh62cce0seun76rrvk5nca6" response = client.get(f"/api/address/info?addresses={address_1},{address_2}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == [ { "address": "wit1drcpu0xc2akfcqn8r69vw70pj8fzjhjypdcfsq", @@ -39,4 +40,5 @@ def test_info_non_existing_addresses(client): address_2 = "wit1drcpu2gf386tm29mh62cce0seun76rrvk5nca7" response = client.get(f"/api/address/info?addresses={address_1},{address_2}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == [] diff --git a/tests/api/address/test_labels.py b/tests/api/address/test_labels.py index bc89e3a2..4214d234 100644 --- a/tests/api/address/test_labels.py +++ b/tests/api/address/test_labels.py @@ -4,6 +4,7 @@ def test_info_existing_addresses(client): response = client.get("/api/address/labels") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == [ { "address": "wit1drcpu0xc2akfcqn8r69vw70pj8fzjhjypdcfsq", diff --git a/tests/api/address/test_mints.py b/tests/api/address/test_mints.py index 8997f189..a3ae5ddc 100644 --- a/tests/api/address/test_mints.py +++ b/tests/api/address/test_mints.py @@ -6,6 +6,7 @@ def test_mints_cached_page_1(client, address_data): assert client.application.extensions["cache"].get(f"{address}_mints") is not None response = client.get(f"/api/address/mints?address={address}&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, @@ -22,6 +23,7 @@ def test_mints_cached_page_2(client, address_data): assert client.application.extensions["cache"].get(f"{address}_mints") is not None response = client.get(f"/api/address/mints?address={address}&page=2&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, @@ -39,6 +41,7 @@ def test_mints_not_cached_page_1(client, address_data): assert client.application.extensions["cache"].get(f"{address}_mints") is None response = client.get(f"/api/address/mints?address={address}&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, @@ -56,6 +59,7 @@ def test_mints_not_cached_page_2(client, address_data): assert client.application.extensions["cache"].get(f"{address}_mints") is None response = client.get(f"/api/address/mints?address={address}&page=2&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 7, "total_pages": 2, diff --git a/tests/api/address/test_utxos.py b/tests/api/address/test_utxos.py index 551a2ae0..1d760336 100644 --- a/tests/api/address/test_utxos.py +++ b/tests/api/address/test_utxos.py @@ -8,6 +8,7 @@ def test_utxos_cached(client, address_data): assert client.application.extensions["cache"].get(f"{address_2}_utxos") is not None response = client.get(f"/api/address/utxos?addresses={address_1},{address_2}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data)[0] == { "address": address_1, "utxos": address_data[address_1]["utxos"], @@ -27,6 +28,7 @@ def test_utxos_not_cached(client, address_data): assert client.application.extensions["cache"].get(f"{address_2}_utxos") is None response = client.get(f"/api/address/utxos?addresses={address_1},{address_2}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data)[0] == { "address": address_1, "utxos": address_data[address_1]["utxos"], diff --git a/tests/api/address/test_value_transfers.py b/tests/api/address/test_value_transfers.py index a571f797..43494f7b 100644 --- a/tests/api/address/test_value_transfers.py +++ b/tests/api/address/test_value_transfers.py @@ -7,6 +7,7 @@ def test_value_transfers_cached_page_1(client, address_data): assert cache.get(f"{address}_value-transfers") is not None response = client.get(f"/api/address/value-transfers?address={address}&page_size=3") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 5, "total_pages": 2, @@ -26,6 +27,7 @@ def test_value_transfers_cached_page_2(client, address_data): f"/api/address/value-transfers?address={address}&page=2&page_size=3" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 5, "total_pages": 2, @@ -44,6 +46,7 @@ def test_value_transfers_not_cached_page_1(client, address_data): assert cache.get(f"{address}_value-transfers") is None response = client.get(f"/api/address/value-transfers?address={address}&page_size=3") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 5, "total_pages": 2, @@ -64,6 +67,7 @@ def test_value_transfers_not_cached_page_2(client, address_data): f"/api/address/value-transfers?address={address}&page=2&page_size=3" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 5, "total_pages": 2, diff --git a/tests/api/misc/test_home.py b/tests/api/misc/test_home.py index 99f14219..53d12de7 100644 --- a/tests/api/misc/test_home.py +++ b/tests/api/misc/test_home.py @@ -5,6 +5,7 @@ def test_home_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/home") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == home @@ -12,6 +13,7 @@ def test_home_cached_network_stats(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/home?key=network_stats") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == {"network_stats": home["network_stats"]} @@ -19,6 +21,7 @@ def test_home_cached_supply_info(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/home?key=supply_info") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == {"supply_info": home["supply_info"]} @@ -26,6 +29,7 @@ def test_home_cached_blocks(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/home?key=blocks") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == {"latest_blocks": home["latest_blocks"]} @@ -33,6 +37,7 @@ def test_home_cached_data_requests(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/home?key=data_requests") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == { "latest_data_requests": home["latest_data_requests"] } @@ -42,6 +47,7 @@ def test_home_cached_value_transfers(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/home?key=value_transfers") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == { "latest_value_transfers": home["latest_value_transfers"] } diff --git a/tests/api/misc/test_ping.py b/tests/api/misc/test_ping.py index 30a42805..ca6ce344 100644 --- a/tests/api/misc/test_ping.py +++ b/tests/api/misc/test_ping.py @@ -4,4 +4,5 @@ def test_ping(client): response = client.get("/api/ping") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == {"response": "pong"} diff --git a/tests/api/misc/test_status.py b/tests/api/misc/test_status.py index d27b98d8..cda2a21d 100644 --- a/tests/api/misc/test_status.py +++ b/tests/api/misc/test_status.py @@ -5,6 +5,7 @@ def test_status_cached(client, status): assert client.application.extensions["cache"].get("status") is not None response = client.get("/api/status") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == status @@ -13,6 +14,7 @@ def test_status_not_cached(client, status): assert client.application.extensions["cache"].get("status") is None response = client.get("/api/status") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" json_data = json.loads(response.data) assert json_data["database_confirmed"] == status["database_confirmed"] assert json_data["database_unconfirmed"] == status["database_unconfirmed"] diff --git a/tests/api/network/test_balances.py b/tests/api/network/test_balances.py index 46f6482c..0e175d26 100644 --- a/tests/api/network/test_balances.py +++ b/tests/api/network/test_balances.py @@ -4,6 +4,7 @@ def test_balances_page_1(client, balances): response = client.get("/api/network/balances?page=1&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 16, "total_pages": 4, @@ -23,6 +24,7 @@ def test_balances_page_1(client, balances): def test_balances_page_2(client, balances): response = client.get("/api/network/balances?page=2&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 16, "total_pages": 4, @@ -43,6 +45,7 @@ def test_balances_page_2(client, balances): def test_balances_page_201(client, balances): response = client.get("/api/network/balances?page=201&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 16, "total_pages": 4, diff --git a/tests/api/network/test_blockchain.py b/tests/api/network/test_blockchain.py index 450ab965..d51f68ee 100644 --- a/tests/api/network/test_blockchain.py +++ b/tests/api/network/test_blockchain.py @@ -6,6 +6,7 @@ def test_blockchain_page_1_cached(client, blockchain): assert cache.get("blockchain_page-1_page-size-50") is not None response = client.get("/api/network/blockchain?page=1") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 2024100, "total_pages": 40482, @@ -22,6 +23,7 @@ def test_blockchain_page_246_cached(client, blockchain): assert cache.get("blockchain_page-246_page-size-50") is not None response = client.get("/api/network/blockchain?page=246") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 2024100, "total_pages": 40482, @@ -40,6 +42,7 @@ def test_blockchain_page_1_not_cached(client, blockchain): assert cache.get("blockchain_page-1_page-size-50") is None response = client.get("/api/network/blockchain?page=1") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 2024100, "total_pages": 40482, @@ -58,6 +61,7 @@ def test_blockchain_page_246_not_cached(client, blockchain): assert cache.get("blockchain_page-246_page-size-50") is None response = client.get("/api/network/blockchain?page=246") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 2024100, "total_pages": 40482, @@ -76,6 +80,7 @@ def test_blockchain_page_2_not_cached_all_reverted(client): assert cache.get("blockchain_page-2_page-size-50") is None response = client.get("/api/network/blockchain?page=2") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 2024100, "total_pages": 40482, diff --git a/tests/api/network/test_mempool.py b/tests/api/network/test_mempool.py index 55a24a3e..d861b70f 100644 --- a/tests/api/network/test_mempool.py +++ b/tests/api/network/test_mempool.py @@ -14,6 +14,7 @@ def test_mempool_data_requests_cached(client, network_mempool): "/api/network/mempool?transaction_type=data_requests&start_epoch=2074446&stop_epoch=2074466" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == network_mempool[cache_key] @@ -26,6 +27,7 @@ def test_mempool_data_requests_not_cached(client, network_mempool): "/api/network/mempool?transaction_type=data_requests&start_epoch=2074446&stop_epoch=2074466" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == network_mempool[cache_key] assert cache.get(cache_key) is not None @@ -38,6 +40,7 @@ def test_mempool_value_transfers_cached(client, network_mempool): "/api/network/mempool?transaction_type=value_transfers&start_epoch=2074446&stop_epoch=2074466" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == network_mempool[cache_key] @@ -50,6 +53,7 @@ def test_mempool_value_transfers_not_cached(client, network_mempool): "/api/network/mempool?transaction_type=value_transfers&start_epoch=2074446&stop_epoch=2074466" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == network_mempool[cache_key] assert cache.get(cache_key) is not None diff --git a/tests/api/network/test_reputation.py b/tests/api/network/test_reputation.py index 3fd6c5f4..59c97e0f 100644 --- a/tests/api/network/test_reputation.py +++ b/tests/api/network/test_reputation.py @@ -4,6 +4,7 @@ def test_reputation_cached(client, reputation): response = client.get("/api/network/reputation") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == reputation @@ -12,6 +13,7 @@ def test_reputation_not_cached(client, reputation): assert client.application.extensions["cache"].get("reputation") is None response = client.get("/api/network/reputation") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data)["reputation"] == reputation["reputation"] assert ( json.loads(response.data)["total_reputation"] == reputation["total_reputation"] diff --git a/tests/api/network/test_statistics.py b/tests/api/network/test_statistics.py index 1a90a4d2..afeba4d9 100644 --- a/tests/api/network/test_statistics.py +++ b/tests/api/network/test_statistics.py @@ -6,6 +6,7 @@ def test_list_rollbacks_all_cached(client, network_statistics): assert cache.get("list-rollbacks_None_None") is not None response = client.get("/api/network/statistics?key=list-rollbacks") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == network_statistics["list-rollbacks_None_None"] @@ -15,6 +16,7 @@ def test_list_rollbacks_all_not_cached(client, network_statistics): assert cache.get("list-rollbacks_None_None") is None response = client.get("/api/network/statistics?key=list-rollbacks") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == network_statistics["list-rollbacks_None_None"] assert cache.get("list-rollbacks_None_None") is not None @@ -24,6 +26,7 @@ def test_list_rollbacks_first_part(client, network_statistics): "/api/network/statistics?key=list-rollbacks&start_epoch=1443900&stop_epoch=1445000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == { "start_epoch": 1443000, "stop_epoch": 1445000, @@ -39,6 +42,7 @@ def test_list_rollbacks_mid_part(client, network_statistics): "/api/network/statistics?key=list-rollbacks&start_epoch=1442500&stop_epoch=1443000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == { "start_epoch": 1442000, "stop_epoch": 1443000, @@ -54,6 +58,7 @@ def test_list_rollbacks_last_part(client, network_statistics): "/api/network/statistics?key=list-rollbacks&start_epoch=1430000&stop_epoch=1439999" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == { "start_epoch": 1430000, "stop_epoch": 1440000, @@ -68,6 +73,7 @@ def test_miners_top_100_all_cached(client, network_statistics): assert cache.get("top-100-miners_None_None") is not None response = client.get("/api/network/statistics?key=top-100-miners") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == network_statistics["top-100-miners_None_None"] @@ -77,6 +83,7 @@ def test_miners_top_100_all_not_cached(client, network_statistics): assert cache.get("top-100-miners_None_None") is None response = client.get("/api/network/statistics?key=top-100-miners") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == network_statistics["top-100-miners_None_None"] assert cache.get("top-100-miners_None_None") is not None @@ -86,6 +93,7 @@ def test_data_request_solvers_top_100_all_cached(client, network_statistics): assert cache.get("top-100-data-request-solvers_None_None") is not None response = client.get("/api/network/statistics?key=top-100-data-request-solvers") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["top-100-data-request-solvers_None_None"] @@ -98,6 +106,7 @@ def test_data_request_solvers_top_100_all_not_cached(client, network_statistics) assert cache.get("top-100-data-request-solvers_None_None") is None response = client.get("/api/network/statistics?key=top-100-data-request-solvers") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["top-100-data-request-solvers_None_None"] @@ -110,6 +119,7 @@ def test_num_unique_miners_all_cached(client, network_statistics): assert cache.get("num-unique-miners_None_None") is not None response = client.get("/api/network/statistics?key=num-unique-miners") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["num-unique-miners_None_None"] ) @@ -121,6 +131,7 @@ def test_num_unique_miners_all_not_cached(client, network_statistics): assert cache.get("num-unique-miners_None_None") is None response = client.get("/api/network/statistics?key=num-unique-miners") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["num-unique-miners_None_None"] ) @@ -132,6 +143,7 @@ def test_num_unique_data_request_solvers_top_100_all_cached(client, network_stat assert cache.get("num-unique-data-request-solvers_None_None") is not None response = client.get("/api/network/statistics?key=num-unique-data-request-solvers") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["num-unique-data-request-solvers_None_None"] @@ -146,6 +158,7 @@ def test_num_unique_data_request_solvers_top_100_all_not_cached( assert cache.get("num-unique-data-request-solvers_None_None") is None response = client.get("/api/network/statistics?key=num-unique-data-request-solvers") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["num-unique-data-request-solvers_None_None"] @@ -160,6 +173,7 @@ def test_miners_top_100_period_cached(client, network_statistics): "/api/network/statistics?key=top-100-miners&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["top-100-miners_1000000_1002000"] @@ -174,6 +188,7 @@ def test_miners_top_100_period_not_cached(client, network_statistics): "/api/network/statistics?key=top-100-miners&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["top-100-miners_1000000_1002000"] @@ -188,6 +203,7 @@ def test_data_request_solvers_top_100_period_cached(client, network_statistics): "/api/network/statistics?key=top-100-data-request-solvers&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["top-100-data-request-solvers_1000000_1002000"] @@ -202,6 +218,7 @@ def test_data_request_solvers_top_100_period_not_cached(client, network_statisti "/api/network/statistics?key=top-100-data-request-solvers&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["top-100-data-request-solvers_1000000_1002000"] @@ -216,6 +233,7 @@ def test_num_unique_miners_period_cached(client, network_statistics): "/api/network/statistics?key=num-unique-miners&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["num-unique-miners_1000000_1002000"] @@ -230,6 +248,7 @@ def test_num_unique_miners_period_not_cached(client, network_statistics): "/api/network/statistics?key=num-unique-miners&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["num-unique-miners_1000000_1002000"] @@ -246,6 +265,7 @@ def test_num_unique_data_request_solvers_top_100_period_cached( "/api/network/statistics?key=num-unique-data-request-solvers&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["num-unique-data-request-solvers_1000000_1002000"] @@ -262,6 +282,7 @@ def test_num_unique_data_request_solvers_top_100_period_not_cached( "/api/network/statistics?key=num-unique-data-request-solvers&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["num-unique-data-request-solvers_1000000_1002000"] @@ -274,6 +295,7 @@ def test_staking_cached(client, network_statistics): assert cache.get("percentile-staking-balances_None_None") is not None response = client.get("/api/network/statistics?key=percentile-staking-balances") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["percentile-staking-balances_None_None"] @@ -286,6 +308,7 @@ def test_staking_not_cached(client, network_statistics): assert cache.get("percentile-staking-balances_None_None") is None response = client.get("/api/network/statistics?key=percentile-staking-balances") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["percentile-staking-balances_None_None"] @@ -300,6 +323,7 @@ def test_histogram_data_requests_period_cached(client, network_statistics): "/api/network/statistics?key=histogram-data-requests&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-requests_1000000_1002000"] @@ -314,6 +338,7 @@ def test_histogram_data_requests_period_not_cached(client, network_statistics): "/api/network/statistics?key=histogram-data-requests&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-requests_1000000_1002000"] @@ -326,6 +351,7 @@ def test_histogram_data_requests_most_recent_cached(client, network_statistics): assert cache.get("histogram-data-requests_1965000_2025000") is not None response = client.get("/api/network/statistics?key=histogram-data-requests") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-requests_1965000_2025000"] @@ -338,6 +364,7 @@ def test_histogram_data_requests_most_recent_not_cached(client, network_statisti assert cache.get("histogram-data-requests_1965000_2025000") is None response = client.get("/api/network/statistics?key=histogram-data-requests") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-requests_1965000_2025000"] @@ -352,6 +379,7 @@ def test_histogram_data_request_composition_period_cached(client, network_statis "/api/network/statistics?key=histogram-data-request-composition&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-composition_1000000_1002000"] @@ -368,6 +396,7 @@ def test_histogram_data_request_composition_period_not_cached( "/api/network/statistics?key=histogram-data-request-composition&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-composition_1000000_1002000"] @@ -384,6 +413,7 @@ def test_histogram_data_request_composition_most_recent_cached( "/api/network/statistics?key=histogram-data-request-composition" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-composition_1965000_2025000"] @@ -400,6 +430,7 @@ def test_histogram_data_request_composition_most_recent_not_cached( "/api/network/statistics?key=histogram-data-request-composition" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-composition_1965000_2025000"] @@ -414,6 +445,7 @@ def test_histogram_data_request_witness_period_cached(client, network_statistics "/api/network/statistics?key=histogram-data-request-witness&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-witness_1000000_1002000"] @@ -428,6 +460,7 @@ def test_histogram_data_request_witness_period_not_cached(client, network_statis "/api/network/statistics?key=histogram-data-request-witness&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-witness_1000000_1002000"] @@ -440,6 +473,7 @@ def test_histogram_data_request_witness_most_recent_cached(client, network_stati assert cache.get("histogram-data-request-witness_1965000_2025000") is not None response = client.get("/api/network/statistics?key=histogram-data-request-witness") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-witness_1965000_2025000"] @@ -454,6 +488,7 @@ def test_histogram_data_request_witness_most_recent_not_cached( assert cache.get("histogram-data-request-witness_1965000_2025000") is None response = client.get("/api/network/statistics?key=histogram-data-request-witness") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-witness_1965000_2025000"] @@ -468,6 +503,7 @@ def test_histogram_data_request_collateral_period_cached(client, network_statist "/api/network/statistics?key=histogram-data-request-collateral&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-collateral_1000000_1002000"] @@ -484,6 +520,7 @@ def test_histogram_data_request_collateral_period_not_cached( "/api/network/statistics?key=histogram-data-request-collateral&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-collateral_1000000_1002000"] @@ -500,6 +537,7 @@ def test_histogram_data_request_collateral_most_recent_cached( "/api/network/statistics?key=histogram-data-request-collateral" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-collateral_1965000_2025000"] @@ -516,6 +554,7 @@ def test_histogram_data_request_collateral_most_recent_not_cached( "/api/network/statistics?key=histogram-data-request-collateral" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-collateral_1965000_2025000"] @@ -530,6 +569,7 @@ def test_histogram_data_request_reward_period_cached(client, network_statistics) "/api/network/statistics?key=histogram-data-request-reward&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-reward_1000000_1002000"] @@ -544,6 +584,7 @@ def test_histogram_data_request_reward_period_not_cached(client, network_statist "/api/network/statistics?key=histogram-data-request-reward&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-reward_1000000_1002000"] @@ -556,6 +597,7 @@ def test_histogram_data_request_reward_most_recent_cached(client, network_statis assert cache.get("histogram-data-request-reward_1965000_2025000") is not None response = client.get("/api/network/statistics?key=histogram-data-request-reward") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-reward_1965000_2025000"] @@ -570,6 +612,7 @@ def test_histogram_data_request_reward_most_recent_not_cached( assert cache.get("histogram-data-request-reward_1965000_2025000") is None response = client.get("/api/network/statistics?key=histogram-data-request-reward") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-reward_1965000_2025000"] @@ -584,6 +627,7 @@ def test_histogram_data_request_lie_rate_period_cached(client, network_statistic "/api/network/statistics?key=histogram-data-request-lie-rate&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-lie-rate_1000000_1002000"] @@ -598,6 +642,7 @@ def test_histogram_data_request_lie_rate_period_not_cached(client, network_stati "/api/network/statistics?key=histogram-data-request-lie-rate&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-lie-rate_1000000_1002000"] @@ -610,6 +655,7 @@ def test_histogram_data_request_lie_rate_most_recent_cached(client, network_stat assert cache.get("histogram-data-request-lie-rate_1965000_2025000") is not None response = client.get("/api/network/statistics?key=histogram-data-request-lie-rate") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-lie-rate_1965000_2025000"] @@ -624,6 +670,7 @@ def test_histogram_data_request_lie_rate_most_recent_not_cached( assert cache.get("histogram-data-request-lie-rate_1965000_2025000") is None response = client.get("/api/network/statistics?key=histogram-data-request-lie-rate") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-data-request-lie-rate_1965000_2025000"] @@ -638,6 +685,7 @@ def test_histogram_burn_rate_rate_period_cached(client, network_statistics): "/api/network/statistics?key=histogram-burn-rate&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-burn-rate_1000000_1002000"] @@ -652,6 +700,7 @@ def test_histogram_burn_rate_rate_period_not_cached(client, network_statistics): "/api/network/statistics?key=histogram-burn-rate&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-burn-rate_1000000_1002000"] @@ -664,6 +713,7 @@ def test_histogram_burn_rate_rate_most_recent_cached(client, network_statistics) assert cache.get("histogram-burn-rate_1965000_2025000") is not None response = client.get("/api/network/statistics?key=histogram-burn-rate") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-burn-rate_1965000_2025000"] @@ -676,6 +726,7 @@ def test_histogram_burn_rate_rate_most_recent_not_cached(client, network_statist assert cache.get("histogram-burn-rate_1965000_2025000") is None response = client.get("/api/network/statistics?key=histogram-burn-rate") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-burn-rate_1965000_2025000"] @@ -690,6 +741,7 @@ def test_histogram_value_transfers_period_cached(client, network_statistics): "/api/network/statistics?key=histogram-value-transfers&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-value-transfers_1000000_1002000"] @@ -704,6 +756,7 @@ def test_histogram_value_transfers_period_not_cached(client, network_statistics) "/api/network/statistics?key=histogram-value-transfers&start_epoch=1000000&stop_epoch=1002000" ) assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-value-transfers_1000000_1002000"] @@ -716,6 +769,7 @@ def test_histogram_value_transfers_most_recent_cached(client, network_statistics assert cache.get("histogram-value-transfers_1965000_2025000") is not None response = client.get("/api/network/statistics?key=histogram-value-transfers") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-value-transfers_1965000_2025000"] @@ -728,6 +782,7 @@ def test_histogram_value_transfers_most_recent_not_cached(client, network_statis assert cache.get("histogram-value-transfers_1965000_2025000") is None response = client.get("/api/network/statistics?key=histogram-value-transfers") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert ( json.loads(response.data) == network_statistics["histogram-value-transfers_1965000_2025000"] diff --git a/tests/api/network/test_supply.py b/tests/api/network/test_supply.py index 48ba6e9b..b7788d82 100644 --- a/tests/api/network/test_supply.py +++ b/tests/api/network/test_supply.py @@ -6,6 +6,7 @@ def test_supply_info_blocks_minted_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=blocks_minted") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str(int(supply_info["blocks_minted"])) @@ -14,6 +15,7 @@ def test_supply_info_blocks_minted_reward_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=blocks_minted_reward") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str( int(supply_info["blocks_minted_reward"] / 1e9) ) @@ -24,6 +26,7 @@ def test_supply_info_blocks_missing_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=blocks_missing") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str(int(supply_info["blocks_missing"])) @@ -32,6 +35,7 @@ def test_supply_info_blocks_missing_reward_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=blocks_missing_reward") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str( int(supply_info["blocks_missing_reward"] / 1e9) ) @@ -42,6 +46,7 @@ def test_supply_info_current_locked_supply_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=current_locked_supply") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str( int(supply_info["current_locked_supply"] / 1e9) ) @@ -52,6 +57,7 @@ def test_supply_info_current_time_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=current_time") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str(int(supply_info["current_time"])) @@ -60,6 +66,7 @@ def test_supply_info_current_unlocked_supply_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=current_unlocked_supply") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str( int(supply_info["current_unlocked_supply"] / 1e9) ) @@ -70,6 +77,7 @@ def test_supply_info_epoch_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=epoch") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str(int(supply_info["epoch"])) @@ -78,6 +86,7 @@ def test_supply_info_in_flight_requests_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=in_flight_requests") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str(int(supply_info["in_flight_requests"])) @@ -86,6 +95,7 @@ def test_supply_info_locked_wits_by_requests_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=locked_wits_by_requests") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str( int(supply_info["locked_wits_by_requests"] / 1e9) ) @@ -96,6 +106,7 @@ def test_supply_info_maximum_supply_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=maximum_supply") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str(int(supply_info["maximum_supply"] / 1e9)) @@ -104,6 +115,7 @@ def test_supply_info_current_supply_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=current_supply") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str(int(supply_info["current_supply"] / 1e9)) @@ -112,6 +124,7 @@ def test_supply_info_total_supply_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=total_supply") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str(int(supply_info["total_supply"] / 1e9)) @@ -120,6 +133,7 @@ def test_supply_info_supply_burned_lies_cached(client, home): assert client.application.extensions["cache"].get("home") is not None response = client.get("/api/network/supply?key=supply_burned_lies") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == str( int(supply_info["supply_burned_lies"] / 1e9) ) diff --git a/tests/api/network/test_tapi.py b/tests/api/network/test_tapi.py index b41706c9..6c692c05 100644 --- a/tests/api/network/test_tapi.py +++ b/tests/api/network/test_tapi.py @@ -6,6 +6,7 @@ def test_tapi_cached(client, tapi): assert cache.get("tapi-13") is not None response = client.get("/api/network/tapi") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == [tapi["tapi-13"]] @@ -15,6 +16,7 @@ def test_tapi_not_cached(client, tapi): assert cache.get("tapi-13") is None response = client.get("/api/network/tapi") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == [tapi["tapi-13"]] @@ -23,6 +25,7 @@ def test_tapi_all_cached(client, tapi): assert cache.get("tapi-13") is not None response = client.get("/api/network/tapi?return_all=true") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == [tapi["tapi-7"], tapi["tapi-13"]] @@ -32,4 +35,5 @@ def test_tapi_all_not_cached(client, tapi): assert cache.get("tapi-13") is None response = client.get("/api/network/tapi?return_all=true") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == [tapi["tapi-7"], tapi["tapi-13"]] diff --git a/tests/api/search/test_epoch.py b/tests/api/search/test_epoch.py index 20a39967..ac9ed9da 100644 --- a/tests/api/search/test_epoch.py +++ b/tests/api/search/test_epoch.py @@ -8,6 +8,7 @@ def test_search_epoch_all_cached(client, blocks): assert cache.get(hash_value) is not None response = client.get("/api/search/epoch?value=2002561") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == blocks[hash_value]["cache"] @@ -19,6 +20,7 @@ def test_search_epoch_only_epoch_cached(client, blocks): assert cache.get(hash_value) is None response = client.get("/api/search/epoch?value=2002561") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == blocks[hash_value]["cache"] @@ -32,6 +34,7 @@ def test_search_epoch_not_cached(client, blocks): assert cache.get(hash_value) is None response = client.get("/api/search/epoch?value=2002561") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == blocks[hash_value]["cache"] assert cache.get(hash_value) is not None assert cache.get(epoch) is not None diff --git a/tests/api/search/test_hash.py b/tests/api/search/test_hash.py index de7b2789..c01f9604 100644 --- a/tests/api/search/test_hash.py +++ b/tests/api/search/test_hash.py @@ -5,6 +5,7 @@ def test_search_hash_data_request_pending(client): hash_value = "1bcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == { "response_type": "pending", "pending": "Data request is pending.", @@ -15,6 +16,7 @@ def test_search_hash_value_transfer_pending(client): hash_value = "2bcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == { "response_type": "pending", "pending": "Value transfer is pending.", @@ -27,6 +29,7 @@ def test_search_block_cached(client, blocks): assert cache.get(hash_value) is not None response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == blocks[hash_value]["cache"] @@ -37,6 +40,7 @@ def test_search_block_not_cached(client, blocks): assert cache.get(hash_value) is None response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == blocks[hash_value]["cache"] @@ -46,6 +50,7 @@ def test_search_mint_cached(client, mints): assert cache.get(hash_value) is not None response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == mints[hash_value] @@ -56,6 +61,7 @@ def test_search_mint_not_cached(client, mints): assert cache.get(hash_value) is None response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == mints[hash_value] @@ -65,6 +71,7 @@ def test_search_value_transfer_cached(client, value_transfers): assert cache.get(hash_value) is not None response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == value_transfers[hash_value] @@ -75,6 +82,7 @@ def test_search_value_transfer_not_cached(client, value_transfers): assert cache.get(hash_value) is None response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == value_transfers[hash_value] @@ -85,6 +93,7 @@ def test_search_data_request_simple_not_cached(client, data_requests): assert cache.get(hash_value) is None response = client.get(f"/api/search/hash?value={hash_value}&simple=true") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == data_requests[hash_value]["api"] @@ -94,6 +103,7 @@ def test_search_commit_simple_cached(client, commits): assert cache.get(hash_value) is not None response = client.get(f"/api/search/hash?value={hash_value}&simple=true") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == commits[hash_value] @@ -104,6 +114,7 @@ def test_search_commit_simple_not_cached(client, commits): assert cache.get(hash_value) is None response = client.get(f"/api/search/hash?value={hash_value}&simple=true") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == commits[hash_value] assert cache.get(hash_value) is not None @@ -114,6 +125,7 @@ def test_search_reveal_simple_cached(client, reveals): assert cache.get(hash_value) is not None response = client.get(f"/api/search/hash?value={hash_value}&simple=true") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == reveals[hash_value] @@ -124,6 +136,7 @@ def test_search_reveal_simple_not_cached(client, reveals): assert cache.get(hash_value) is None response = client.get(f"/api/search/hash?value={hash_value}&simple=true") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == reveals[hash_value] assert cache.get(hash_value) is not None @@ -134,6 +147,7 @@ def test_search_tally_simple_cached(client, tallies): assert cache.get(hash_value) is not None response = client.get(f"/api/search/hash?value={hash_value}&simple=true") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == tallies[hash_value] @@ -144,6 +158,7 @@ def test_search_tally_simple_not_cached(client, tallies): assert cache.get(hash_value) is None response = client.get(f"/api/search/hash?value={hash_value}&simple=true") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == tallies[hash_value] assert cache.get(hash_value) is not None @@ -154,6 +169,7 @@ def test_search_data_request_report_cached(client, data_request_reports): assert cache.get(hash_value) is not None response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == data_request_reports[hash_value] @@ -164,6 +180,7 @@ def test_search_data_request_report_not_cached(client, data_request_reports): assert cache.get(hash_value) is None response = client.get(f"/api/search/hash?value={hash_value}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == data_request_reports[hash_value] assert cache.get(hash_value) is not None @@ -175,6 +192,7 @@ def test_search_data_request_report_from_commit_cached(client, data_request_repo commit_hash = "563eba0199a23283c0764bd8690522666ba56a5024eef7cc6f253be53efacb6a" response = client.get(f"/api/search/hash?value={commit_hash}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" # Need to replace the transaction type when building the data request report from the database response_data = data_request_reports[dr_hash] response_data["data_request_report"]["transaction_type"] = "commit" @@ -191,6 +209,7 @@ def test_search_data_request_report_from_commit_not_cached( commit_hash = "563eba0199a23283c0764bd8690522666ba56a5024eef7cc6f253be53efacb6a" response = client.get(f"/api/search/hash?value={commit_hash}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" # Need to replace the transaction type when building the data request report from the database response_data = data_request_reports[dr_hash] response_data["data_request_report"]["transaction_type"] = "commit" @@ -207,6 +226,7 @@ def test_search_data_request_report_from_cached_commit_cached( assert cache.get(commit_hash) is not None response = client.get(f"/api/search/hash?value={commit_hash}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" # Need to replace the transaction type when building the data request report from the database response_data = data_request_reports[dr_hash] response_data["data_request_report"]["transaction_type"] = "commit" @@ -220,6 +240,7 @@ def test_search_data_request_report_from_reveal_cached(client, data_request_repo reveal_hash = "0e7ea734b1ad24e69406f2059888041e353cb9fabe1b4f1345fe230c3dbbc9ac" response = client.get(f"/api/search/hash?value={reveal_hash}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" # Need to replace the transaction type when building the data request report from the database response_data = data_request_reports[dr_hash] response_data["data_request_report"]["transaction_type"] = "reveal" @@ -236,6 +257,7 @@ def test_search_data_request_report_from_reveal_not_cached( reveal_hash = "0e7ea734b1ad24e69406f2059888041e353cb9fabe1b4f1345fe230c3dbbc9ac" response = client.get(f"/api/search/hash?value={reveal_hash}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" # Need to replace the transaction type when building the data request report from the database response_data = data_request_reports[dr_hash] response_data["data_request_report"]["transaction_type"] = "reveal" @@ -252,6 +274,7 @@ def test_search_data_request_report_from_cached_reveal_cached( assert cache.get(reveal_hash) is not None response = client.get(f"/api/search/hash?value={reveal_hash}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" # Need to replace the transaction type when building the data request report from the database response_data = data_request_reports[dr_hash] response_data["data_request_report"]["transaction_type"] = "reveal" @@ -265,6 +288,7 @@ def test_search_data_request_report_from_tally_cached(client, data_request_repor tally_hash = "dcb4f1ebde98b4ba0c819fca0cc339993322e67900ba53d9b5534afba844af11" response = client.get(f"/api/search/hash?value={tally_hash}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" # Need to replace the transaction type when building the data request report from the database response_data = data_request_reports[dr_hash] response_data["data_request_report"]["transaction_type"] = "tally" @@ -279,6 +303,7 @@ def test_search_data_request_report_from_tally_not_cached(client, data_request_r tally_hash = "dcb4f1ebde98b4ba0c819fca0cc339993322e67900ba53d9b5534afba844af11" response = client.get(f"/api/search/hash?value={tally_hash}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" # Need to replace the transaction type when building the data request report from the database response_data = data_request_reports[dr_hash] response_data["data_request_report"]["transaction_type"] = "tally" @@ -295,6 +320,7 @@ def test_search_data_request_report_from_cached_tally_cached( assert cache.get(tally_hash) is not None response = client.get(f"/api/search/hash?value={tally_hash}") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" # Need to replace the transaction type when building the data request report from the database response_data = data_request_reports[dr_hash] response_data["data_request_report"]["transaction_type"] = "tally" @@ -305,6 +331,7 @@ def test_search_data_request_history_DRO_page_1(client, data_request_history_dro hash_value = "0332cb684de3bb0e9b2b0d8b43524eed7fc51b00fefa038ee3bf6f6ac9c7cc82" response = client.get(f"/api/search/hash?value={hash_value}&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 4, "total_pages": 1, @@ -319,6 +346,7 @@ def test_search_data_request_history_RAD_page_1(client, data_request_history_rad hash_value = "1a643dcd0299ee7982ede4387580ff406207930a6b11fd14d2e9ec5dccab476a" response = client.get(f"/api/search/hash?value={hash_value}&page_size=5") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 8, "total_pages": 2, @@ -337,6 +365,7 @@ def test_search_data_request_history_RAD_page_2(client, data_request_history_rad hash_value = "1a643dcd0299ee7982ede4387580ff406207930a6b11fd14d2e9ec5dccab476a" response = client.get(f"/api/search/hash?value={hash_value}&page_size=5&page=2") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.headers["X-Pagination"]) == { "total": 8, "total_pages": 2, diff --git a/tests/api/transaction/test_mempool.py b/tests/api/transaction/test_mempool.py index 3188ea22..951e3ec2 100644 --- a/tests/api/transaction/test_mempool.py +++ b/tests/api/transaction/test_mempool.py @@ -5,6 +5,7 @@ def test_mempool_cached_all(client, mempool): assert client.application.extensions["cache"].get("transaction_mempool") is not None response = client.get("/api/transaction/mempool?type=all") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == mempool @@ -12,6 +13,7 @@ def test_mempool_cached_drt(client, mempool): assert client.application.extensions["cache"].get("transaction_mempool") is not None response = client.get("/api/transaction/mempool?type=data_requests") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == {"data_request": mempool["data_request"]} @@ -19,6 +21,7 @@ def test_mempool_cached_vtt(client, mempool): assert client.application.extensions["cache"].get("transaction_mempool") is not None response = client.get("/api/transaction/mempool?type=value_transfers") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == {"value_transfer": mempool["value_transfer"]} @@ -27,5 +30,6 @@ def test_mempool_not_cached(client, mempool): assert client.application.extensions["cache"].get("transaction_mempool") is None response = client.get("/api/transaction/mempool?type=all") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == mempool assert client.application.extensions["cache"].get("transaction_mempool") is not None diff --git a/tests/api/transaction/test_priority.py b/tests/api/transaction/test_priority.py index d5146981..0e49d66c 100644 --- a/tests/api/transaction/test_priority.py +++ b/tests/api/transaction/test_priority.py @@ -5,6 +5,7 @@ def test_priority_cached_all(client, priority): assert client.application.extensions["cache"].get("priority") is not None response = client.get("/api/transaction/priority?key=all") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == priority @@ -12,6 +13,7 @@ def test_priority_cached_drt(client, priority): assert client.application.extensions["cache"].get("priority") is not None response = client.get("/api/transaction/priority?key=drt") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == { "drt_high": priority["drt_high"], "drt_low": priority["drt_low"], @@ -25,6 +27,7 @@ def test_priority_cached_vtt(client, priority): assert client.application.extensions["cache"].get("priority") is not None response = client.get("/api/transaction/priority?key=vtt") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == { "vtt_high": priority["vtt_high"], "vtt_low": priority["vtt_low"], @@ -39,5 +42,6 @@ def test_priority_not_cached(client, priority): assert client.application.extensions["cache"].get("priority") is None response = client.get("/api/transaction/priority?key=all") assert response.status_code == 200 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == priority assert client.application.extensions["cache"].get("priority") is not None diff --git a/tests/api/transaction/test_send.py b/tests/api/transaction/test_send.py index c3ed664a..277ff7f4 100644 --- a/tests/api/transaction/test_send.py +++ b/tests/api/transaction/test_send.py @@ -12,6 +12,7 @@ def test_send_test(client, value_transfer): }, ) assert response.status_code == 201 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == {"result": "Value transfer is valid."} @@ -25,4 +26,5 @@ def test_send(client, value_transfer): }, ) assert response.status_code == 201 + assert response.headers["x-version"] == "1.0.0" assert json.loads(response.data) == {"result": "Succesfully sent value transfer."} From ff34313ea1a5641db7631ac7f181bf5212b0b7ec Mon Sep 17 00:00:00 2001 From: drcpu Date: Thu, 14 Mar 2024 21:56:52 +0100 Subject: [PATCH 4/6] [requirements] Use a hierarchical requirements structure for the Python dependencies --- .github/workflows/format.yaml | 2 +- .github/workflows/tests.yaml | 4 +++- README.md | 4 ++-- requirements.txt | 22 ---------------------- requirements/all.txt | 8 ++++++++ requirements/api.txt | 11 +++++++++++ requirements/formatting.txt | 6 ++++++ requirements/tests.txt | 1 + 8 files changed, 32 insertions(+), 26 deletions(-) delete mode 100644 requirements.txt create mode 100644 requirements/all.txt create mode 100644 requirements/api.txt create mode 100644 requirements/formatting.txt create mode 100644 requirements/tests.txt diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml index d725c288..17399195 100644 --- a/.github/workflows/format.yaml +++ b/.github/workflows/format.yaml @@ -10,7 +10,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install black flake8 flake8-bugbear flake8-implicit-str-concat isort + pip install -r requirements/formatting.txt - name: Run code checks run: | make lint-check diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4e344d8a..b909e921 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -9,8 +9,10 @@ jobs: - uses: actions/checkout@v3 - name: Install dependencies run: | + sudo apt-get install libmemcached-dev python -m pip install --upgrade pip - pip install cbor flask==2.3.2 flask_smorest==0.42.0 marshmallow Pillow psycopg[pool] pylibmc pytest toml + pip install -r requirements/api.txt + pip install -r requirements/tests.txt - name: Run pytest run: | python -m pytest diff --git a/README.md b/README.md index dadec368..5254c194 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,11 @@ sudo make install ## Python3 dependencies - virtual environment -It is advised to start the explorer from within a virtual environment. You can install all dependencies using the `requirements.txt` file: +It is advised to start the explorer from within a virtual environment. You can install all dependencies using the `requirements/all.txt` file: ``` virtualenv env source env/bin/activate -pip install -r requirements.txt +pip install -r requirements/all.txt ``` ## Install and configure memcached diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index ee40eefe..00000000 --- a/requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -black==23.7.0 -cbor==1.0.0 -flake8==6.0.0 -flake8-bugbear==23.9.16 -flake8-implicit-str-concat==0.4.0 -Flask==2.3.2 -flask_smorest==0.42.0 -gevent==23.7.0 -gunicorn==21.2.0 -isort==5.10.1 -marshmallow==3.20.1 -matplotlib==3.5.3 -numpy==1.24.4 -Pillow==10.0.0 -pre-commit==3.3.3 -prometheus_client==0.15.0 -psutil==5.8.0 -psycopg==3.1.12 -psycopg-pool==3.1.8 -pylibmc==1.6.1 -pytest==7.4.0 -toml==0.10.2 diff --git a/requirements/all.txt b/requirements/all.txt new file mode 100644 index 00000000..e6453244 --- /dev/null +++ b/requirements/all.txt @@ -0,0 +1,8 @@ +matplotlib==3.5.3 +numpy==1.24.4 +prometheus_client==0.15.0 +psutil==5.8.0 + +-r requirements/api.txt +-r requirements/formatting.txt +-r requirements/tests.txt diff --git a/requirements/api.txt b/requirements/api.txt new file mode 100644 index 00000000..c184f95e --- /dev/null +++ b/requirements/api.txt @@ -0,0 +1,11 @@ +cbor==1.0.0 +Flask==2.3.2 +flask_smorest==0.42.0 +gevent==23.7.0 +gunicorn==21.2.0 +marshmallow==3.20.1 +Pillow==10.0.0 +psycopg==3.1.12 +psycopg-pool==3.1.8 +pylibmc==1.6.1 +toml==0.10.2 diff --git a/requirements/formatting.txt b/requirements/formatting.txt new file mode 100644 index 00000000..c75f02a0 --- /dev/null +++ b/requirements/formatting.txt @@ -0,0 +1,6 @@ +black==23.7.0 +flake8==6.0.0 +flake8-bugbear==23.9.16 +flake8-implicit-str-concat==0.4.0 +isort==5.10.1 +pre-commit==3.3.3 diff --git a/requirements/tests.txt b/requirements/tests.txt new file mode 100644 index 00000000..70613be0 --- /dev/null +++ b/requirements/tests.txt @@ -0,0 +1 @@ +pytest==7.4.0 From 999ad71bdad2b3f3d78f7f1dba921b4471f42f23 Mon Sep 17 00:00:00 2001 From: drcpu Date: Thu, 14 Mar 2024 22:03:46 +0100 Subject: [PATCH 5/6] [requirements] Update formatting packages --- .pre-commit-config.yaml | 6 +++--- requirements/formatting.txt | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff4cf3dc..c2127837 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,17 @@ files: api/|blockchain/|mockups/|schemas/|scripts/|tests/ repos: - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort args: ["-c"] - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 24.2.0 hooks: - id: black args: ["--check"] - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + rev: 7.0.0 hooks: - id: flake8 args: ["--extend-ignore=E203,E501"] diff --git a/requirements/formatting.txt b/requirements/formatting.txt index c75f02a0..a38827a2 100644 --- a/requirements/formatting.txt +++ b/requirements/formatting.txt @@ -1,6 +1,6 @@ -black==23.7.0 -flake8==6.0.0 -flake8-bugbear==23.9.16 +black==24.2.0 +flake8==7.0.0 +flake8-bugbear==24.2.6 flake8-implicit-str-concat==0.4.0 -isort==5.10.1 +isort==5.13.2 pre-commit==3.3.3 From cb3db272b43d58afa6773976323b815855847aa0 Mon Sep 17 00:00:00 2001 From: drcpu Date: Thu, 14 Mar 2024 22:05:38 +0100 Subject: [PATCH 6/6] [format] Rerun linting tools with the updated formatting packages --- api/__init__.py | 6 +++--- schemas/component/commit_schema.py | 6 +++--- schemas/component/mint_schema.py | 6 +++--- schemas/component/tally_schema.py | 6 +++--- tests/api/search/test_hash.py | 12 ++++++------ tests/schemas/component/test_block_schema.py | 6 +++--- tests/schemas/component/test_commit_schema.py | 6 +++--- .../component/test_data_request_schema.py | 18 +++++++++--------- tests/schemas/component/test_reveal_schema.py | 12 ++++++------ tests/schemas/component/test_tally_schema.py | 12 ++++++------ .../schemas/include/test_input_utxo_schema.py | 6 +++--- .../search/test_data_request_history_schema.py | 18 +++++++++--------- 12 files changed, 57 insertions(+), 57 deletions(-) diff --git a/api/__init__.py b/api/__init__.py index cfbea8e5..66da97eb 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -56,9 +56,9 @@ def create_app(mock=False): app.config["OPENAPI_VERSION"] = "3.0.3" app.config["OPENAPI_URL_PREFIX"] = "/api" app.config["OPENAPI_RAPIDOC_PATH"] = "/documentation" - app.config[ - "OPENAPI_RAPIDOC_URL" - ] = "https://cdn.jsdelivr.net/npm/rapidoc/dist/rapidoc-min.js" + app.config["OPENAPI_RAPIDOC_URL"] = ( + "https://cdn.jsdelivr.net/npm/rapidoc/dist/rapidoc-min.js" + ) app.config["OPENAPI_RAPIDOC_CONFIG"] = { "allow-authentication": "false", "allow-spec-file-download": "true", diff --git a/schemas/component/commit_schema.py b/schemas/component/commit_schema.py index ba6c2eda..d1924c54 100644 --- a/schemas/component/commit_schema.py +++ b/schemas/component/commit_schema.py @@ -34,8 +34,8 @@ def validate_inputs(self, args, **kwargs): if len(args["input_values"]) < 1: errors["input_values"] = "Need at least one input value." if len(args["input_utxos"]) != len(args["input_values"]): - errors[ - "input_utxos" - ] = "Number of input UTXO's and input values is different." + errors["input_utxos"] = ( + "Number of input UTXO's and input values is different." + ) if len(errors) > 0: raise ValidationError(errors) diff --git a/schemas/component/mint_schema.py b/schemas/component/mint_schema.py index e33bc6c4..599d4bd0 100644 --- a/schemas/component/mint_schema.py +++ b/schemas/component/mint_schema.py @@ -17,9 +17,9 @@ def validate_inputs(self, args, **kwargs): if len(args["output_addresses"]) < 1: errors["output_addresses"] = "Need at least one output address." if len(args["output_addresses"]) != len(args["output_values"]): - errors[ - "output_values" - ] = "Number of output addresses and values is different." + errors["output_values"] = ( + "Number of output addresses and values is different." + ) if len(errors): raise ValidationError(errors) diff --git a/schemas/component/tally_schema.py b/schemas/component/tally_schema.py index ebe75e83..3c133076 100644 --- a/schemas/component/tally_schema.py +++ b/schemas/component/tally_schema.py @@ -17,9 +17,9 @@ def validate_sizes(self, args, **kwargs): if len(args["output_addresses"]) < 1: errors["output_addresses"] = "Need at least one output address." if len(args["output_addresses"]) != len(args["output_values"]): - errors[ - "output_values" - ] = "Size of output addresses and output values does not match." + errors["output_values"] = ( + "Size of output addresses and output values does not match." + ) if len(errors): raise ValidationError(errors) diff --git a/tests/api/search/test_hash.py b/tests/api/search/test_hash.py index c01f9604..e8b22731 100644 --- a/tests/api/search/test_hash.py +++ b/tests/api/search/test_hash.py @@ -355,9 +355,9 @@ def test_search_data_request_history_RAD_page_1(client, data_request_history_rad "page": 1, "next_page": 2, } - data_request_history_rad["data_request_history"][ - "history" - ] = data_request_history_rad["data_request_history"]["history"][:5] + data_request_history_rad["data_request_history"]["history"] = ( + data_request_history_rad["data_request_history"]["history"][:5] + ) assert json.loads(response.data) == data_request_history_rad @@ -374,7 +374,7 @@ def test_search_data_request_history_RAD_page_2(client, data_request_history_rad "page": 2, "previous_page": 1, } - data_request_history_rad["data_request_history"][ - "history" - ] = data_request_history_rad["data_request_history"]["history"][5:] + data_request_history_rad["data_request_history"]["history"] = ( + data_request_history_rad["data_request_history"]["history"][5:] + ) assert json.loads(response.data) == data_request_history_rad diff --git a/tests/schemas/component/test_block_schema.py b/tests/schemas/component/test_block_schema.py index 7e65ebc1..017567af 100644 --- a/tests/schemas/component/test_block_schema.py +++ b/tests/schemas/component/test_block_schema.py @@ -29,9 +29,9 @@ def test_block_details_success(block_details): def test_block_details_failure_hash(block_details): - block_details[ - "hash" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + block_details["hash"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) with pytest.raises(ValidationError) as err_info: BlockDetails().load(block_details) assert err_info.value.messages["hash"][0] == "Hash is not a hexadecimal value." diff --git a/tests/schemas/component/test_commit_schema.py b/tests/schemas/component/test_commit_schema.py index 6b59bc4a..9a5c41ac 100644 --- a/tests/schemas/component/test_commit_schema.py +++ b/tests/schemas/component/test_commit_schema.py @@ -70,9 +70,9 @@ def test_commit_transaction_for_block_success(commit_transaction_for_block): def test_commit_transaction_for_block_failure_hash(commit_transaction_for_block): - commit_transaction_for_block[ - "data_request" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + commit_transaction_for_block["data_request"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) with pytest.raises(ValidationError) as err_info: CommitTransactionForBlock().load(commit_transaction_for_block) assert ( diff --git a/tests/schemas/component/test_data_request_schema.py b/tests/schemas/component/test_data_request_schema.py index 8a6854a2..c523907e 100644 --- a/tests/schemas/component/test_data_request_schema.py +++ b/tests/schemas/component/test_data_request_schema.py @@ -47,12 +47,12 @@ def test_data_request_failure_address(data_request): def test_data_request_failure_hash(data_request): - data_request[ - "RAD_bytes_hash" - ] = "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef012345678" - data_request[ - "DRO_bytes_hash" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + data_request["RAD_bytes_hash"] = ( + "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef012345678" + ) + data_request["DRO_bytes_hash"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) with pytest.raises(ValidationError) as err_info: DataRequest().load(data_request) assert len(err_info.value.messages) == 2 @@ -380,9 +380,9 @@ def test_data_request_transaction_for_explorer_success_none( def test_data_request_transaction_for_explorer_failure_address( data_request_transaction_for_explorer, ): - data_request_transaction_for_explorer[ - "output_address" - ] = "wit100000000000000000000000000000000r0v4g" + data_request_transaction_for_explorer["output_address"] = ( + "wit100000000000000000000000000000000r0v4g" + ) with pytest.raises(ValidationError) as err_info: DataRequestTransactionForExplorer().load(data_request_transaction_for_explorer) assert ( diff --git a/tests/schemas/component/test_reveal_schema.py b/tests/schemas/component/test_reveal_schema.py index 7da8e82b..9e1cd1c2 100644 --- a/tests/schemas/component/test_reveal_schema.py +++ b/tests/schemas/component/test_reveal_schema.py @@ -61,9 +61,9 @@ def test_reveal_transaction_for_block_success(reveal_transaction_for_block): def test_reveal_transaction_for_block_failure_hash(reveal_transaction_for_block): - reveal_transaction_for_block[ - "data_request" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + reveal_transaction_for_block["data_request"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) with pytest.raises(ValidationError) as err_info: RevealTransactionForBlock().load(reveal_transaction_for_block) assert ( @@ -152,9 +152,9 @@ def test_reveal_transaction_for_explorer_success(reveal_transaction_for_explorer def test_reveal_transaction_for_explorer_failure_hash(reveal_transaction_for_explorer): - reveal_transaction_for_explorer[ - "data_request" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + reveal_transaction_for_explorer["data_request"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) with pytest.raises(ValidationError) as err_info: RevealTransactionForExplorer().load(reveal_transaction_for_explorer) assert ( diff --git a/tests/schemas/component/test_tally_schema.py b/tests/schemas/component/test_tally_schema.py index 955e914d..f5c5a3e5 100644 --- a/tests/schemas/component/test_tally_schema.py +++ b/tests/schemas/component/test_tally_schema.py @@ -215,9 +215,9 @@ def test_tally_transaction_for_block_success(tally_transaction_for_block): def test_tally_transaction_for_block_failure_hash(tally_transaction_for_block): - tally_transaction_for_block[ - "data_request" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + tally_transaction_for_block["data_request"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) with pytest.raises(ValidationError) as err_info: TallyTransactionForBlock().load(tally_transaction_for_block) assert ( @@ -324,9 +324,9 @@ def test_tally_transaction_for_explorer_success(tally_transaction_for_explorer): def test_tally_transaction_for_explorer_failure_hash(tally_transaction_for_explorer): - tally_transaction_for_explorer[ - "data_request" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + tally_transaction_for_explorer["data_request"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) with pytest.raises(ValidationError) as err_info: TallyTransactionForExplorer().load(tally_transaction_for_explorer) assert ( diff --git a/tests/schemas/include/test_input_utxo_schema.py b/tests/schemas/include/test_input_utxo_schema.py index a3b55bc3..585624db 100644 --- a/tests/schemas/include/test_input_utxo_schema.py +++ b/tests/schemas/include/test_input_utxo_schema.py @@ -56,9 +56,9 @@ def test_input_utxo_pointer_success(input_utxo_pointer): def test_input_utxo_pointer_failure_pointer(input_utxo_pointer): - input_utxo_pointer[ - "input_utxo" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789:0" + input_utxo_pointer["input_utxo"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789:0" + ) with pytest.raises(ValidationError) as err_info: InputUtxoPointer().load(input_utxo_pointer) assert ( diff --git a/tests/schemas/search/test_data_request_history_schema.py b/tests/schemas/search/test_data_request_history_schema.py index f96dd670..aa544338 100644 --- a/tests/schemas/search/test_data_request_history_schema.py +++ b/tests/schemas/search/test_data_request_history_schema.py @@ -41,9 +41,9 @@ def test_data_request_history_entry_success_minimal(data_request_history_entry): def test_data_request_history_entry_failure_hash(data_request_history_entry): - data_request_history_entry[ - "data_request" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + data_request_history_entry["data_request"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) with pytest.raises(ValidationError) as err_info: DataRequestHistoryEntry().load(data_request_history_entry) assert ( @@ -164,12 +164,12 @@ def test_data_request_history_failure_type(data_request_history): def test_data_request_history_failure_hash(data_request_history): - data_request_history[ - "hash" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" - data_request_history[ - "RAD_bytes_hash" - ] = "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + data_request_history["hash"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) + data_request_history["RAD_bytes_hash"] = ( + "zbcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef0123456789" + ) with pytest.raises(ValidationError) as err_info: DataRequestHistory().load(data_request_history) assert len(err_info.value.messages) == 2