test(verify): cover a confirmed status without a block hash or height

Aperta
#101 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@iyazici00 ci sta già lavorando.

Dal 3/12/2026.

  • #117 di @iyazici00 — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

Read tests/test_verify.py and inspect _api(status=...) to see how status responses are mocked. Add cases for confirmed statuses missing block_hash and block_height, asserting MempoolAPIError with the specified messages and ensuring neither case raises VerificationError. Run the test suite using the commands in CONTRIBUTING.md; done means both cases pass without changing files under btc_toolkit/.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

good first issue

What

The API is untrusted, and verify_tx checks its answers. A /tx/<txid>/status that says the transaction is confirmed must also give the block hash and the block height (verify.py L214-L219). Neither case has a test.

What to do

Add tests to tests/test_verify.py for a confirmed status without block_hash, and for one without block_height. Both must raise MempoolAPIError (an API error, exit code 1), never a VerificationError and never a traceback. All API calls are mocked; the suite runs offline.

Acceptance

  • The block_height test fails if the check at L218-L219 is removed (without it, the missing height ends in a VerificationError about a different block height). A missing block_hash is already refused earlier, by field_hash at L216 ("'block_hash' is missing"); its test locks that in.
  • No change under btc_toolkit/.

Hints

  • _api(status=...) in tests/test_verify.py lets you choose the status response.
  • VerificationError is a subclass of MempoolAPIError, so assertRaises(MempoolAPIError) alone also passes on a VerificationError. Match the message (assertRaisesRegex(MempoolAPIError, "confirmed without"), "'block_hash' is missing") or assert that the exception is not a VerificationError.

See CONTRIBUTING.md for the test, lint and type-check commands. Comment below before starting, so two people don't take the same issue.

Lingua principale
Python
Stelle
2
Fork
1
Merge medio
1h 45m
PR unite (30g)
23

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di devdavidejesus/btc-toolkit

Tutte le issue di devdavidejesus/btc-toolkit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.