Changeset View
Changeset View
Standalone View
Standalone View
doc/functional-tests.md
Show First 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | |||||
don't have test cases for. | don't have test cases for. | ||||
#### Style guidelines | #### Style guidelines | ||||
- Where possible, try to adhere to | - Where possible, try to adhere to | ||||
[PEP-8 guidelines](https://www.python.org/dev/peps/pep-0008/) | [PEP-8 guidelines](https://www.python.org/dev/peps/pep-0008/) | ||||
- Use a python linter like flake8 before submitting PRs to catch common style | - Use a python linter like flake8 before submitting PRs to catch common style | ||||
nits (eg trailing whitespace, unused imports, etc) | nits (eg trailing whitespace, unused imports, etc) | ||||
- Use [type hints](https://docs.python.org/3/library/typing.html) in your code to improve code readability | |||||
and to detect possible bugs earlier. | |||||
- Avoid wildcard imports where possible | - Avoid wildcard imports where possible | ||||
- Use a module-level docstring to describe what the test is testing, and how it | - Use a module-level docstring to describe what the test is testing, and how it | ||||
is testing it. | is testing it. | ||||
- When subclassing the BitcoinTestFramwork, place overrides for the | - When subclassing the BitcoinTestFramework, place overrides for the | ||||
`set_test_params()`, `add_options()` and `setup_xxxx()` methods at the top of | `set_test_params()`, `add_options()` and `setup_xxxx()` methods at the top of | ||||
the subclass, then locally-defined helper methods, then the `run_test()` method. | the subclass, then locally-defined helper methods, then the `run_test()` method. | ||||
#### Naming guidelines | #### Naming guidelines | ||||
- Name the test `<area>_test.py`, where area can be one of the following: | - Name the test `<area>_test.py`, where area can be one of the following: | ||||
- `feature` for tests for full features that aren't wallet/mining/mempool, eg `feature_rbf.py` | - `feature` for tests for full features that aren't wallet/mining/mempool, eg `feature_rbf.py` | ||||
- `interface` for tests for other interfaces (REST, ZMQ, etc), eg `interface_rest.py` | - `interface` for tests for other interfaces (REST, ZMQ, etc), eg `interface_rest.py` | ||||
- `mempool` for tests for mempool behaviour, eg `mempool_reorg.py` | - `mempool` for tests for mempool behaviour, eg `mempool_reorg.py` | ||||
- `mining` for tests for mining features, eg `mining_prioritisetransaction.py` | - `mining` for tests for mining features, eg `mining_prioritisetransaction.py` | ||||
- `p2p` for tests that explicitly test the p2p interface, eg `p2p_disconnect_ban.py` | - `p2p` for tests that explicitly test the p2p interface, eg `p2p_disconnect_ban.py` | ||||
- `rpc` for tests for individual RPC methods or features, eg `rpc_listtransactions.py` | - `rpc` for tests for individual RPC methods or features, eg `rpc_listtransactions.py` | ||||
- `tool` for tests for tools, eg `tool_wallet.py` | - `tool` for tests for tools, eg `tool_wallet.py` | ||||
- `wallet` for tests for wallet features, eg `wallet_keypool.py` | - `wallet` for tests for wallet features, eg `wallet_keypool.py` | ||||
- use an underscore to separate words | - Use an underscore to separate words | ||||
- exception: for tests for specific RPCs or command line options which don't include underscores, name the test after the exact RPC or argument name, eg `rpc_decodescript.py`, not `rpc_decode_script.py` | - exception: for tests for specific RPCs or command line options which don't include underscores, name the test after the exact RPC or argument name, eg `rpc_decodescript.py`, not `rpc_decode_script.py` | ||||
- Don't use the redundant word `test` in the name, eg `interface_zmq.py`, not `interface_zmq_test.py` | - Don't use the redundant word `test` in the name, eg `interface_zmq.py`, not `interface_zmq_test.py` | ||||
#### General test-writing advice | #### General test-writing advice | ||||
- Set `self.num_nodes` to the minimum number of nodes necessary for the test. | - Set `self.num_nodes` to the minimum number of nodes necessary for the test. | ||||
Having additional unrequired nodes adds to the execution time of the test as | Having additional unrequired nodes adds to the execution time of the test as | ||||
well as memory/CPU/disk requirements (which is important when running tests in | well as memory/CPU/disk requirements (which is important when running tests in | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |