diff --git a/tests-functional/clients/status_backend.py b/tests-functional/clients/status_backend.py index 71e9e06bb..aa2f6a530 100644 --- a/tests-functional/clients/status_backend.py +++ b/tests-functional/clients/status_backend.py @@ -65,10 +65,10 @@ class RpcClient: response = self.rpc_request(method, params, _id, url) self.verify_is_valid_json_rpc_response(response, _id) return response - + def verify_json_schema(self, response, method): with open(f"{option.base_dir}/schemas/{method}", "r") as schema: - jsonschema.validate(instance=response.json(), + jsonschema.validate(instance=response, schema=json.load(schema)) diff --git a/tests-functional/schemas/accounts_getKeypairs b/tests-functional/schemas/accounts_getKeypairs index 28b25ed39..1a4aa5623 100644 --- a/tests-functional/schemas/accounts_getKeypairs +++ b/tests-functional/schemas/accounts_getKeypairs @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/accounts_hasPairedDevices b/tests-functional/schemas/accounts_hasPairedDevices index a0a3e5dbe..25947679e 100644 --- a/tests-functional/schemas/accounts_hasPairedDevices +++ b/tests-functional/schemas/accounts_hasPairedDevices @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/accounts_remainingAccountCapacity b/tests-functional/schemas/accounts_remainingAccountCapacity index a34c43a23..d7d0c480d 100644 --- a/tests-functional/schemas/accounts_remainingAccountCapacity +++ b/tests-functional/schemas/accounts_remainingAccountCapacity @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/signal_mediaserver_started b/tests-functional/schemas/signal_mediaserver_started new file mode 100644 index 000000000..f9a5c5a5d --- /dev/null +++ b/tests-functional/schemas/signal_mediaserver_started @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "mediaserver.started" + }, + "event": { + "type": "object", + "properties": { + "port": { + "type": "integer", + "minimum": 1, + "maximum": 65535 + } + }, + "required": ["port"], + "additionalProperties": false + } + }, + "required": ["type", "event"], + "additionalProperties": false +} \ No newline at end of file diff --git a/tests-functional/schemas/signal_node_login b/tests-functional/schemas/signal_node_login new file mode 100644 index 000000000..f22ddccc7 --- /dev/null +++ b/tests-functional/schemas/signal_node_login @@ -0,0 +1,116 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "node.login" + }, + "event": { + "type": "object", + "properties": { + "settings": { + "type": "object", + "properties": { + "address": { "type": "string" }, + "currency": { "type": "string" }, + "networks/current-network": { "type": "string" }, + "dapps-address": { "type": "string" }, + "device-name": { "type": "string" }, + "display-name": { "type": "string" }, + "eip1581-address": { "type": "string" }, + "installation-id": { "type": "string" }, + "key-uid": { "type": "string" }, + "latest-derived-path": { "type": "integer" }, + "link-preview-request-enabled": { "type": "boolean" }, + "messages-from-contacts-only": { "type": "boolean" }, + "mnemonic": { "type": "string" }, + "mutual-contact-enabled?": { "type": "boolean" }, + "name": { "type": "string" }, + "networks/networks": { "type": "array" }, + "photo-path": { "type": "string" }, + "preview-privacy?": { "type": "boolean" }, + "public-key": { "type": "string" }, + "signing-phrase": { "type": "string" }, + "default-sync-period": { "type": "integer" }, + "send-push-notifications?": { "type": "boolean" }, + "appearance": { "type": "integer" }, + "profile-pictures-show-to": { "type": "integer" }, + "profile-pictures-visibility": { "type": "integer" }, + "use-mailservers?": { "type": "boolean" }, + "wallet-root-address": { "type": "string" }, + "send-status-updates?": { "type": "boolean" }, + "current-user-status": { + "type": "object", + "properties": { + "publicKey": { "type": "string" }, + "statusType": { "type": "integer" }, + "clock": { "type": "integer" }, + "text": { "type": "string" } + }, + "required": ["publicKey", "statusType", "clock", "text"] + }, + "gifs/recent-gifs": { "type": ["null", "array"] }, + "gifs/favorite-gifs": { "type": ["null", "array"] }, + "last-backup": { "type": "integer" }, + "backup-enabled?": { "type": "boolean" }, + "gifs/api-key": { "type": "string" }, + "show-community-asset-when-sending-tokens?": { "type": "boolean" }, + "display-assets-below-balance-threshold": { "type": "integer" }, + "url-unfurling-mode": { "type": "integer" }, + "compressedKey": { "type": "string" }, + "emojiHash": { + "type": "array", + "items": { "type": "string" } + } + }, + "required": [ + "address", "currency", "networks/current-network", "dapps-address", + "device-name", "display-name", "eip1581-address", "installation-id", + "key-uid", "latest-derived-path", "link-preview-request-enabled", + "messages-from-contacts-only", "mutual-contact-enabled?", + "name", "networks/networks", "photo-path", "preview-privacy?", + "public-key", "signing-phrase", "default-sync-period", + "send-push-notifications?", "appearance", "profile-pictures-show-to", + "profile-pictures-visibility", "use-mailservers?", "wallet-root-address", + "send-status-updates?", "current-user-status", "gifs/recent-gifs", + "gifs/favorite-gifs", "last-backup", "backup-enabled?", "gifs/api-key", + "show-community-asset-when-sending-tokens?", + "display-assets-below-balance-threshold", "url-unfurling-mode", + "compressedKey", "emojiHash" + ] + }, + "account": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "timestamp": { "type": "integer" }, + "identicon": { "type": "string" }, + "colorHash": { + "type": "array", + "items": { + "type": "array", + "items": { "type": "integer" }, + "minItems": 2, + "maxItems": 2 + } + }, + "colorId": { "type": "integer" }, + "customizationColor": { "type": "string" }, + "keycard-pairing": { "type": "string" }, + "key-uid": { "type": "string" }, + "images": { "type": ["null", "array"] }, + "kdfIterations": { "type": "integer" } + }, + "required": [ + "name", "timestamp", "identicon", "colorHash", "colorId", + "customizationColor", "keycard-pairing", "key-uid", "images", + "kdfIterations" + ] + } + }, + "required": ["settings", "account"] + } + }, + "required": ["type", "event"] +} \ No newline at end of file diff --git a/tests-functional/schemas/signal_node_ready b/tests-functional/schemas/signal_node_ready new file mode 100644 index 000000000..cba554d56 --- /dev/null +++ b/tests-functional/schemas/signal_node_ready @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "node.ready" + }, + "event": { + "type": "null" + } + }, + "required": ["type", "event"], + "additionalProperties": false +} \ No newline at end of file diff --git a/tests-functional/schemas/signal_node_started b/tests-functional/schemas/signal_node_started new file mode 100644 index 000000000..7c6e6ed5c --- /dev/null +++ b/tests-functional/schemas/signal_node_started @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "node.started" + }, + "event": { + "type": "null" + } + }, + "required": ["type", "event"], + "additionalProperties": false +} \ No newline at end of file diff --git a/tests-functional/schemas/wakuext_peers b/tests-functional/schemas/wakuext_peers index c64fd868b..69b3348dd 100644 --- a/tests-functional/schemas/wakuext_peers +++ b/tests-functional/schemas/wakuext_peers @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "properties": { "id": { diff --git a/tests-functional/schemas/wallet_checkRecentHistoryForChainIDs b/tests-functional/schemas/wallet_checkRecentHistoryForChainIDs index 242060c35..813520451 100644 --- a/tests-functional/schemas/wallet_checkRecentHistoryForChainIDs +++ b/tests-functional/schemas/wallet_checkRecentHistoryForChainIDs @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/wallet_createMultiTransaction/transferTx_error b/tests-functional/schemas/wallet_createMultiTransaction/transferTx_error index e2e78a1f7..631c21c47 100644 --- a/tests-functional/schemas/wallet_createMultiTransaction/transferTx_error +++ b/tests-functional/schemas/wallet_createMultiTransaction/transferTx_error @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "error": { "properties": { diff --git a/tests-functional/schemas/wallet_createMultiTransaction/transferTx_positive b/tests-functional/schemas/wallet_createMultiTransaction/transferTx_positive index 6052e4b98..a261cdb4a 100644 --- a/tests-functional/schemas/wallet_createMultiTransaction/transferTx_positive +++ b/tests-functional/schemas/wallet_createMultiTransaction/transferTx_positive @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "integer" diff --git a/tests-functional/schemas/wallet_fetchAllCurrencyFormats b/tests-functional/schemas/wallet_fetchAllCurrencyFormats index ce737e53f..db80607f4 100644 --- a/tests-functional/schemas/wallet_fetchAllCurrencyFormats +++ b/tests-functional/schemas/wallet_fetchAllCurrencyFormats @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/wallet_getCachedCurrencyFormats b/tests-functional/schemas/wallet_getCachedCurrencyFormats index 8ce520bc1..7e316f04e 100644 --- a/tests-functional/schemas/wallet_getCachedCurrencyFormats +++ b/tests-functional/schemas/wallet_getCachedCurrencyFormats @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/wallet_getCryptoOnRamps b/tests-functional/schemas/wallet_getCryptoOnRamps index 9168aabc7..17aff0f40 100644 --- a/tests-functional/schemas/wallet_getCryptoOnRamps +++ b/tests-functional/schemas/wallet_getCryptoOnRamps @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/wallet_getEthereumChains b/tests-functional/schemas/wallet_getEthereumChains index 422137825..9206c30f4 100644 --- a/tests-functional/schemas/wallet_getEthereumChains +++ b/tests-functional/schemas/wallet_getEthereumChains @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/wallet_getPendingTransactions b/tests-functional/schemas/wallet_getPendingTransactions index 64a3d80d5..ec94250f3 100644 --- a/tests-functional/schemas/wallet_getPendingTransactions +++ b/tests-functional/schemas/wallet_getPendingTransactions @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/wallet_getPendingTransactionsForIdentities b/tests-functional/schemas/wallet_getPendingTransactionsForIdentities index 64a3d80d5..ec94250f3 100644 --- a/tests-functional/schemas/wallet_getPendingTransactionsForIdentities +++ b/tests-functional/schemas/wallet_getPendingTransactionsForIdentities @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/wallet_getTokenList b/tests-functional/schemas/wallet_getTokenList index 2a8a7dbba..8c430c8c1 100644 --- a/tests-functional/schemas/wallet_getTokenList +++ b/tests-functional/schemas/wallet_getTokenList @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/schemas/wallet_startWallet b/tests-functional/schemas/wallet_startWallet index 242060c35..3be76fedf 100644 --- a/tests-functional/schemas/wallet_startWallet +++ b/tests-functional/schemas/wallet_startWallet @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/schema#", + "$schema": "http://json-schema.org/draft-07/schema", "properties": { "id": { "type": "string" diff --git a/tests-functional/tests/test_accounts.py b/tests-functional/tests/test_accounts.py index 5e43c27aa..0b3c35030 100644 --- a/tests-functional/tests/test_accounts.py +++ b/tests-functional/tests/test_accounts.py @@ -22,4 +22,4 @@ class TestAccounts(StatusBackendTestCase): _id = str(random.randint(1, 8888)) response = self.rpc_client.rpc_valid_request(method, params, _id) - self.rpc_client.verify_json_schema(response, method) + self.rpc_client.verify_json_schema(response.json(), method) diff --git a/tests-functional/tests/test_init_status_app.py b/tests-functional/tests/test_init_status_app.py index f35666926..4001dabb5 100644 --- a/tests-functional/tests/test_init_status_app.py +++ b/tests-functional/tests/test_init_status_app.py @@ -11,12 +11,12 @@ class TestInitialiseApp: backend_client = init_status_backend assert backend_client is not None - mediaserver_started = backend_client.wait_for_signal( - "mediaserver.started") - - port = mediaserver_started['event']['port'] - assert type(port) is int, f"Port is not an integer, found {type(port)}" - - backend_client.wait_for_signal("node.started") - backend_client.wait_for_signal("node.ready") - backend_client.wait_for_signal("node.login") + + backend_client.verify_json_schema( + backend_client.wait_for_signal("mediaserver.started"), "signal_mediaserver_started") + backend_client.verify_json_schema( + backend_client.wait_for_signal("node.started"), "signal_node_started") + backend_client.verify_json_schema( + backend_client.wait_for_signal("node.ready"), "signal_node_ready") + backend_client.verify_json_schema( + backend_client.wait_for_signal("node.login"), "signal_node_login") diff --git a/tests-functional/tests/test_waku_rpc.py b/tests-functional/tests/test_waku_rpc.py index e3d7ae3c6..cde29a041 100644 --- a/tests-functional/tests/test_waku_rpc.py +++ b/tests-functional/tests/test_waku_rpc.py @@ -21,7 +21,7 @@ class TestRpc(StatusBackendTestCase): _id = str(random.randint(1, 8888)) response = self.rpc_client.rpc_valid_request(method, params, _id) - self.rpc_client.verify_json_schema(response, method) + self.rpc_client.verify_json_schema(response.json(), method) @pytest.mark.skip("to be reworked via status-backend") diff --git a/tests-functional/tests/test_wallet_rpc.py b/tests-functional/tests/test_wallet_rpc.py index 04144b83a..968e599b9 100644 --- a/tests-functional/tests/test_wallet_rpc.py +++ b/tests-functional/tests/test_wallet_rpc.py @@ -34,7 +34,7 @@ class TestTransactionRpc(TransactionTestCase): params[0][0]["hash"] = self.tx_hash response = self.rpc_client.rpc_valid_request(method, params, _id) - self.rpc_client.verify_json_schema(response, method) + self.rpc_client.verify_json_schema(response.json(), method) def test_create_multi_transaction(self): response = self.wallet_create_multi_transaction() @@ -71,7 +71,7 @@ class TestTransactionRpc(TransactionTestCase): assert expected_error_text in actual_error_text, \ f"got error: {actual_error_text} that does not include: {expected_error_text}" - self.rpc_client.verify_json_schema(response, "wallet_createMultiTransaction/transferTx_error") + self.rpc_client.verify_json_schema(response.json(), "wallet_createMultiTransaction/transferTx_error") @pytest.mark.wallet @@ -92,4 +92,4 @@ class TestRpc(StatusBackendTestCase): _id = str(random.randint(1, 8888)) response = self.rpc_client.rpc_valid_request(method, params, _id) - self.rpc_client.verify_json_schema(response, method) + self.rpc_client.verify_json_schema(response.json(), method)