test_: verify schema of signals during init; fix schema verification warnings (#5947)
This commit is contained in:
parent
807397faca
commit
eea527a9cf
|
@ -68,7 +68,7 @@ class RpcClient:
|
|||
|
||||
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))
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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"]
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"error": {
|
||||
"properties": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/schema#",
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue