github.com/status-im/status-go@v1.1.0/integration-tests/tests/test_wallet_rpc.py (about)

     1  import random
     2  import pytest
     3  import jsonschema
     4  import json
     5  from conftest import option, user_1, user_2
     6  from test_cases import RpcTestCase, TransactionTestCase
     7  
     8  
     9  @pytest.mark.wallet
    10  @pytest.mark.tx
    11  @pytest.mark.rpc
    12  class TestTransactionRpc(TransactionTestCase):
    13  
    14      @pytest.mark.parametrize(
    15          "method, params",
    16          [
    17              (
    18                      "wallet_checkRecentHistoryForChainIDs",
    19                      [[31337], ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"]],
    20              ),
    21              (
    22                      "wallet_getPendingTransactionsForIdentities",
    23                      [[{"chainId": None, "hash": None}]],
    24              ),
    25          ],
    26      )
    27      def test_tx_(self, method, params):
    28          _id = str(random.randint(1, 9999))
    29  
    30          if method in ["wallet_getPendingTransactionsForIdentities"]:
    31              params[0][0]["chainId"] = self.network_id
    32              params[0][0]["hash"] = self.tx_hash
    33  
    34          response = self.rpc_request(method, params, _id)
    35          self.verify_is_valid_json_rpc_response(response)
    36          with open(f"{option.base_dir}/schemas/{method}", "r") as schema:
    37              jsonschema.validate(instance=response.json(), schema=json.load(schema))
    38  
    39      def test_create_multi_transaction(self):
    40          response = self.wallet_create_multi_transaction()
    41  
    42          # how to create schema:
    43          # from schema_builder import CustomSchemaBuilder
    44          # CustomSchemaBuilder(method).create_schema(response.json())
    45  
    46          with open(f"{option.base_dir}/schemas/wallet_createMultiTransaction", "r") as schema:
    47              jsonschema.validate(instance=response.json(), schema=json.load(schema))
    48  
    49  
    50  @pytest.mark.wallet
    51  @pytest.mark.rpc
    52  class TestRpc(RpcTestCase):
    53  
    54      @pytest.mark.parametrize(
    55          "method, params",
    56          [
    57              ("wallet_startWallet", []),
    58              ("wallet_getEthereumChains", []),
    59              ("wallet_getTokenList", []),
    60              ("wallet_getCryptoOnRamps", []),
    61              ("wallet_getCachedCurrencyFormats", []),
    62              ("wallet_fetchAllCurrencyFormats", [])
    63          ],
    64      )
    65      def test_(self, method, params):
    66          _id = str(random.randint(1, 8888))
    67  
    68          response = self.rpc_request(method, params, _id)
    69          self.verify_is_valid_json_rpc_response(response)
    70          with open(f"{option.base_dir}/schemas/{method}", "r") as schema:
    71              jsonschema.validate(instance=response.json(), schema=json.load(schema))