tests: assert which API paths each command requests
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Read the named tests in tests/test_verify.py, tests/test_fees.py, tests/test_block.py, and tests/test_new_commands.py for existing path assertions; then inspect the relevant command tests and patch targets named in the issue. Add mock call assertions for each listed command and verify paths are checked in order, including across get_json and get_text for verify. Done when each test fails on an unexpected or changed path and no files under btc_toolkit/ have changed.
Written by the indexing model from the issue text.
Description
What
Many tests mock the API without checking which path is requested: _api() in tests/test_verify.py (L27-L38) routes only by the end of the path, and most other tests patch get_json with a fixed answer. So a command that requested the wrong endpoint (a typo such as /adress/<address> or /txs/<txid>) would still pass for balance, address, utxo, tx, opreturn, inscription, decode --txid, verify, and the second request of block latest.
fees, block by height and by hash, the tip request of block latest and the /outspends request of tx --outputs are already checked (tests/test_fees.py, tests/test_block.py, tests/test_new_commands.py); use them as examples.
What to do
Add tests that check the exact paths, in order, that each of these commands requests for a typical call:
balanceandaddress:/address/<address>utxo:/address/<address>/utxotx,opreturnandinscription:/tx/<txid>block latest:/blocks/tip/height, then/block-height/<tip>, then/block/<hash>decode --txid:/tx/<txid>/hexverify:/tx/<txid>/status,/tx/<txid>/hex,/tx/<txid>/merkle-proof,/block/<hash>/header
Patch get_json / get_text where the command looks them up, with a Mock, and use assert_has_calls (or make the mock raise on any path it does not know). tx, opreturn and inscription fetch /tx/<txid> through fetch_transaction in btc_toolkit/opreturn.py, so patch btc_toolkit.opreturn.get_json; address goes through btc_toolkit.balance; decode --txid uses btc_toolkit.cli.get_text. For verify, the order spans two mocks (get_json and get_text): record the paths in one list, or use attach_mock, to check the full order.
Acceptance
- Each test fails if the path its command requests changes.
- No change under
btc_toolkit/.
See CONTRIBUTING.md for the test, lint and type-check commands. Comment below before starting, so two people don't take the same issue.
- Dominant language
- Python
- Stars
- 2
- Forks
- 1
- Avg merge
- 1h 45m
- Merged PRs (30d)
- 23
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from devdavidejesus/btc-toolkit
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
devdavidejesus/btc-toolkit#104 ·
Maintainers usually reply within 1 day
-
test(verify): cover invalid bits, the mainnet and testnet limits, and the strong thresholdPossibly taken @omarelshamy25x claimed this 1 day ago. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
devdavidejesus/btc-toolkit#99 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement help wanted
Difficulty 3/5 1-2 days Newbie friendliness 71/100
devdavidejesus/btc-toolkit#105 ·
Maintainers usually reply within 1 day
-
api: reject a /tx response that has no txid fieldPossibly taken @pkray2012 claimed this 1 day ago. Openenhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
devdavidejesus/btc-toolkit#103 ·
Maintainers usually reply within 1 day
-
cli: Ctrl+C should stop btc-toolkit without a tracebackPossibly taken @jay23606 claimed this 1 day ago. Openbug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 25/100
devdavidejesus/btc-toolkit#102 ·
Maintainers usually reply within 1 day
All issues in devdavidejesus/btc-toolkit
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day