vacp2p / nim-libp2p

libp2p implementation in Nim
https://vacp2p.github.io/nim-libp2p/docs/
MIT License
242 stars 52 forks source link

fix: valueOr and withValue utilities #1079

Closed lchenut closed 2 months ago

lchenut commented 3 months ago

This PR fixes a double call when using the valueOr, withValue and toOpt templates.

The issue was found by @chaitanyaprem with a double call of a custom protocol here: https://github.com/waku-org/nwaku/blob/feat--nwaku-sync/waku/waku_sync/protocol.nim#L125-L126

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 88.88889% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 84.56%. Comparing base (03f67d3) to head (5081127).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1079/graphs/tree.svg?width=650&height=150&src=pr&token=M88zHaQffJ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p)](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1079?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p) ```diff @@ Coverage Diff @@ ## unstable #1079 +/- ## ============================================ - Coverage 84.82% 84.56% -0.26% ============================================ Files 91 91 Lines 15428 15487 +59 ============================================ + Hits 13087 13097 +10 - Misses 2341 2390 +49 ``` | [Files](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1079?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p) | Coverage Δ | | |---|---|---| | [libp2p/utility.nim](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1079?src=pr&el=tree&filepath=libp2p%2Futility.nim&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p#diff-bGlicDJwL3V0aWxpdHkubmlt) | `30.00% <88.88%> (-14.00%)` | :arrow_down: | ... and [9 files with indirect coverage changes](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1079/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p)