-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: valueOr and withValue utilities #1079
Conversation
tests/testutility.nim
Outdated
check false | ||
else: | ||
counter.inc() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can probably extract it to a proc inside the test and avoid the repetition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean something like that?
proc testProc[T](val: Opt[T] | Option[T], counter: var int) =
val.withValue(v):
fail()
else:
counter.inc()
testProc(Opt.none(TestObj), counter)
testProc(none(TestObj), counter)
If there were more than two occurrences of this test I would do it, but I don't think it really brings something in this specific case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the benefit is avoiding code duplication, which I believe is never desirable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thanks a lot for taking care of it and addressing the comments!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ 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
|
* feat: draft changes to use a storage manager for sync * chore: address comments and resolve compilation issues * chore: fixing test in progress * chore: in progress time based storage creation * fix: handle server not having storage * chore: remove unused methods * fix: import for trace logging * fix: sync exports * fix: duplicate invocation of dial due to a bug in valueOr vacp2p/nim-libp2p#1079 * chore: refactor and introduce sync session
This PR fixes a double call when using the
valueOr
,withValue
andtoOpt
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