Commit e4d615c
committed
Merge #253: primitives: fix min/max size hint in HrpFe32Iter
ca024f9 primitives: fix min/max size hint in HrpFe32Iter (Renato Britto)
Pull request description:
While running mutation tests, I noticed a defect.
`HrpFe32Iter` models the BIP 173 HRP expansion used for checksum input.
In [BIP 173](https://en.bitcoin.it/wiki/BIP_0173), HRP expansion is: `[ord(x) >> 5 for x in hrp] + [0] + [ord(x) & 31 for x in hrp]`
In `size_hint()`, the high branch already includes that single inserted separator element. Adding another +1 in the final sum overcounts the remaining length by one.
This patch removes the extra +1 from the final min and max calculations and adds a test asserting that `size_hint()` matches the exact remaining length as the iterator is drained.
This change only corrects iterator length accounting. It does not change the yielded sequence of field elements or checksum semantics.
ACKs for top commit:
apoelstra:
ACK ca024f9; successfully ran local tests
clarkmoody:
utACK ca024f9
tcharding:
ACK ca024f9
Tree-SHA512: 6542bf50f693f32a33fad62421702b2eefa486618106ad2b33260f7c3558e9aee261b06dff50d9457cb282aef05b70dadd0577c82a157f4c587519c5b82c0e4b1 file changed
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
505 | | - | |
506 | | - | |
| 505 | + | |
| 506 | + | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
602 | 615 | | |
603 | 616 | | |
604 | 617 | | |
| |||
0 commit comments