/docs/standalone/building-on-electrumsv/functional-tests.rst

https://github.com/electrumsv/electrumsv · ReStructuredText · 78 lines · 57 code · 21 blank · 0 comment · 0 complexity · 3edd51a750febeef7ea9b5146a399229 MD5 · raw file

  1. Functional tests
  2. ===================
  3. The functional tests are a set of tests that use the REST API to manipulate the state of a
  4. 'live' RegTest wallet and check that the state changes are matching what is expected.
  5. Eventually, the REST API should mature to cover all functionality available through the GUI,
  6. allowing automation of any wallet tasks as well as full end-to-end integration testing
  7. coverage.
  8. The functional tests are run as part of the Azure pipeline for any commits to any new
  9. feature branch or pull requests but can also be run locally (and offline) provided a few
  10. dependencies are installed.
  11. A few examples of functional tests are:
  12. - A simulated reorg test (via the RegTest SDK) in which wallet transactions are affected and move to a new block height with a new merkle branch. The database and general wallet state is checked for consistency before and after the reorg.
  13. - Loading the wallet on the daemon.
  14. - Getting the account details.
  15. - Getting utxos before and after topping up the wallet with new coins.
  16. - Getting utxos before and after splitting a coin into smaller outputs.
  17. - Concurrent transaction broadcasting to check the broadcast pathway and as a basic check for data races.
  18. These tests give a broad-brush coverage of many different code paths and as the
  19. REST API grows to cover all GUI interactions will give assurances about:
  20. - Correctness of wallet state.
  21. - Regressions at the wallet server level that could in turn affect the user experience.
  22. Installation of dependencies
  23. -------------------------------
  24. 1. Install pytest pre-requisites::
  25. python3 -m pip install pytest pytest-cov pytest-asyncio pytest-timeout electrumsv_node openpyxl
  26. 2. Install the ElectrumSV-SDK (follow instructions here: https://electrumsv-sdk.readthedocs.io/ ) and then do::
  27. electrumsv-sdk install node
  28. electrumsv-sdk install electrumx
  29. electrumsv-sdk install --repo=$PWD electrumsv
  30. This will install the repositories and dependencies for these components.
  31. Run the functional tests
  32. --------------------------
  33. **The SDK components should be stopped before running the tests as the tests automate
  34. resetting and starting these services - it will fail if they are already running**.
  35. Run the functional tests with pytest like this::
  36. python3 -m pytest -v -v -v contrib/functional_tests/functional
  37. Which should output something like (but with verbose logging output)::
  38. contrib\functional_tests\functional\test_reorg.py::TestReorg::test_reorg PASSED
  39. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_get_all_wallets PASSED [ 25%]
  40. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_load_wallet PASSED [ 33%]
  41. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_websocket_wait_for_mempool PASSED [ 41%]
  42. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_websocket_wait_for_confirmation PASSED [ 50%]
  43. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_get_parent_wallet PASSED [ 58%]
  44. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_get_account PASSED [ 66%]
  45. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_get_utxos_and_top_up PASSED [ 75%]
  46. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_get_balance PASSED [ 83%]
  47. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_concurrent_tx_creation_and_broadcast PASSED [ 91%]
  48. contrib\functional_tests\functional\test_restapi.py::TestRestAPI::test_create_and_broadcast_exception_handling PASSED
  49. ============================================================= 11 passed, 1 skipped, 0 failed in 49.53s ==========================================================
  50. Logging
  51. ---------------
  52. There is a ``pytest.ini`` file in ``contrib/functional_tests/pytest.ini`` with these settings::
  53. [pytest]
  54. log_cli=true
  55. log_level=INFO
  56. If you are finding the logging details distracting or you want more verbose logging you can refer
  57. to the pytest documentation and change the ``pytest.ini`` settings as needed.