test_: added a couple of new schemas and methods (#5843)
This commit is contained in:
parent
596d75ab79
commit
d036f208bb
|
@ -0,0 +1,150 @@
|
||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/schema#",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"jsonrpc": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"items": {
|
||||||
|
"properties": {
|
||||||
|
"accounts": {
|
||||||
|
"items": {
|
||||||
|
"properties": {
|
||||||
|
"address": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"chat": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"clock": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"colorId": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"createdAt": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"emoji": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"hidden": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"key-uid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"mixedcase-address": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"operable": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"position": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"prodPreferredChainIds": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"public-key": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"removed": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"testPreferredChainIds": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"wallet": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"address",
|
||||||
|
"chat",
|
||||||
|
"clock",
|
||||||
|
"colorId",
|
||||||
|
"createdAt",
|
||||||
|
"emoji",
|
||||||
|
"hidden",
|
||||||
|
"key-uid",
|
||||||
|
"mixedcase-address",
|
||||||
|
"name",
|
||||||
|
"operable",
|
||||||
|
"path",
|
||||||
|
"position",
|
||||||
|
"prodPreferredChainIds",
|
||||||
|
"public-key",
|
||||||
|
"removed",
|
||||||
|
"testPreferredChainIds",
|
||||||
|
"type",
|
||||||
|
"wallet"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
"clock": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"derived-from": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"key-uid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"keycards": {
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
"last-used-derivation-index": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"removed": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"synced-from": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"accounts",
|
||||||
|
"clock",
|
||||||
|
"derived-from",
|
||||||
|
"key-uid",
|
||||||
|
"keycards",
|
||||||
|
"last-used-derivation-index",
|
||||||
|
"name",
|
||||||
|
"removed",
|
||||||
|
"synced-from",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"jsonrpc",
|
||||||
|
"result"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/schema#",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"jsonrpc": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"jsonrpc",
|
||||||
|
"result"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/schema#",
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"jsonrpc": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"jsonrpc",
|
||||||
|
"result"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,28 @@
|
||||||
|
import random
|
||||||
|
import pytest
|
||||||
|
import jsonschema
|
||||||
|
import json
|
||||||
|
from conftest import option
|
||||||
|
from test_cases import RpcTestCase
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.accounts
|
||||||
|
@pytest.mark.rpc
|
||||||
|
class TestAccounts(RpcTestCase):
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"method, params",
|
||||||
|
[
|
||||||
|
("accounts_getKeypairs", []),
|
||||||
|
("accounts_hasPairedDevices", []),
|
||||||
|
("accounts_remainingAccountCapacity", [])
|
||||||
|
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_(self, method, params):
|
||||||
|
_id = str(random.randint(1, 8888))
|
||||||
|
|
||||||
|
response = self.rpc_request(method, params, _id)
|
||||||
|
self.verify_is_valid_json_rpc_response(response)
|
||||||
|
with open(f"{option.base_dir}/schemas/{method}", "r") as schema:
|
||||||
|
jsonschema.validate(instance=response.json(), schema=json.load(schema))
|
|
@ -15,17 +15,16 @@ class TestTransactionRpc(TransactionTestCase):
|
||||||
"method, params",
|
"method, params",
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"wallet_checkRecentHistoryForChainIDs",
|
"wallet_checkRecentHistoryForChainIDs",
|
||||||
[[31337], ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"]],
|
[[31337], ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"]],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"wallet_getPendingTransactionsForIdentities",
|
"wallet_getPendingTransactionsForIdentities",
|
||||||
[[{"chainId": None, "hash": None}]],
|
[[{"chainId": None, "hash": None}]],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_tx_(self, method, params):
|
def test_tx_(self, method, params):
|
||||||
|
|
||||||
_id = str(random.randint(1, 9999))
|
_id = str(random.randint(1, 9999))
|
||||||
|
|
||||||
if method in ["wallet_getPendingTransactionsForIdentities"]:
|
if method in ["wallet_getPendingTransactionsForIdentities"]:
|
||||||
|
@ -39,11 +38,11 @@ class TestTransactionRpc(TransactionTestCase):
|
||||||
|
|
||||||
def test_create_multi_transaction(self):
|
def test_create_multi_transaction(self):
|
||||||
response = self.wallet_create_multi_transaction()
|
response = self.wallet_create_multi_transaction()
|
||||||
|
|
||||||
# how to create schema:
|
# how to create schema:
|
||||||
# from schema_builder import CustomSchemaBuilder
|
# from schema_builder import CustomSchemaBuilder
|
||||||
# CustomSchemaBuilder(method).create_schema(response.json())
|
# CustomSchemaBuilder(method).create_schema(response.json())
|
||||||
|
|
||||||
with open(f"{option.base_dir}/schemas/wallet_createMultiTransaction", "r") as schema:
|
with open(f"{option.base_dir}/schemas/wallet_createMultiTransaction", "r") as schema:
|
||||||
jsonschema.validate(instance=response.json(), schema=json.load(schema))
|
jsonschema.validate(instance=response.json(), schema=json.load(schema))
|
||||||
|
|
||||||
|
@ -54,12 +53,13 @@ class TestRpc(RpcTestCase):
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"method, params",
|
"method, params",
|
||||||
[
|
[
|
||||||
("wallet_startWallet", []),
|
("wallet_startWallet", []),
|
||||||
("wallet_getEthereumChains", []),
|
("wallet_getEthereumChains", []),
|
||||||
("wallet_startWallet", []),
|
|
||||||
("wallet_getTokenList", []),
|
("wallet_getTokenList", []),
|
||||||
("wallet_getCryptoOnRamps", []),
|
("wallet_getCryptoOnRamps", []),
|
||||||
|
("wallet_getCachedCurrencyFormats", []),
|
||||||
|
("wallet_fetchAllCurrencyFormats", [])
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_(self, method, params):
|
def test_(self, method, params):
|
||||||
|
|
Loading…
Reference in New Issue