Replace SystemTime with bitcoin::absolute::Time#1047
Replace SystemTime with bitcoin::absolute::Time#1047spacebear21 merged 1 commit intopayjoin:masterfrom
Conversation
Pull Request Test Coverage Report for Build 17830680632Details
💛 - Coveralls |
b8f6b01 to
93ee2c5
Compare
7d50d52 to
5fc4d39
Compare
|
@benalleng FYI this change should allow us to test boundaries with exact timestamps and remove the |
spacebear21
left a comment
There was a problem hiding this comment.
Concept ACK
High-level bikeshed: I just noticed we mix the usage of "expiry" and "expiration" throughout our code. IMO we should just stick to "expiration" since that's the terminology used in BIP77.
3d89977 to
42ec635
Compare
there's many instances throughout so i am going to do this in a followup PR across the entire codebase |
42ec635 to
13b8fac
Compare
13b8fac to
90928d4
Compare
90928d4 to
b80776e
Compare
b80776e to
dc53e84
Compare
dc53e84 to
f994b3c
Compare
DanGould
left a comment
There was a problem hiding this comment.
My main concern is that this exposes Time to the public API when @nothingmuch you seem to prefer Duration (from_secs + Time::from_now specifically). In the public interface. Is this indeed the case?
i think both are fine and we can support both with an IntoTime trait as previously discussed so that Duration can be specified wherever Time is currently required having Time as the "lowest common denominator" for lack of a better term is simpler IMO since there's no implicit dependency on the system clock |
|
oh, one downside i forgot to mention, if we stick with |
f994b3c to
8a7150d
Compare
5ec17e2 to
a293f5c
Compare
|
The success in diff mutations after removing the exclusions are a bit deceiving as I don't think they are necessarily going to test the code blocks unless their source code was explicitly changed in this PR, I am manually running the weekly cargo mutants on these to see what we can do about them now if any still fail. |
|
The mutants that are no longer excluded seem to no longer exist or have been correctly caught though we still do have the default expiry const mutant to address or ignore. After running this again I did not get the same consistent mutation failures, I need to remember to take a closer look at why this might be the case |
b72e736 to
da1248a
Compare
DanGould
left a comment
There was a problem hiding this comment.
I find it odd that Duration is re-exported as part of payjoin::receive::v2 namespace.
V1PjParam, V2PjParam were re-introduced unnecessarily and should probably be removed.
| @@ -309,7 +311,11 @@ impl ReceiverBuilder { | |||
| } | |||
|
|
|||
| pub fn with_expiry(self, expiry: Duration) -> Self { | |||
There was a problem hiding this comment.
I figured this would be renamed to from_now but it's not a critical todo. Can be cleaned up when expiry/expiration is made to be consistent.
There was a problem hiding this comment.
hmm, why? isn't with_expiration consistent with builder pattern and bip77 terminology? i have that lined up after this one
There was a problem hiding this comment.
FWIW this was renamed to with_expiration in #1087
7e48764 to
1fb6a09
Compare
1fb6a09 to
5e045ba
Compare
Internally, introduce a newtype wrapping bitcoin::absolute::Time (which is what BIP 77 specifies) instead of using std::time::SystemTime. A fallible constructor `Time::from_now(std::time::Duration)` is used to construct these values from a `Duration`, which is indirectly called by `with_expiry`. No `IntoTime` trait analogous to `IntoUrl` is included in this commit, but this could be added there as long as both the re-exported and the new `Time` type implement it. Introducing a newtype lets us add additional conversion and arithmetic functionality later without breaking the API or relying on extension traits on the bitcoin Time type. Since it is now only `pub(crate)`, the newtype wrapper's existence is now not entirely justified, as this no longer re-exports a foreign type in our pub api (previous iterations of the commit made it pub, replacing the use of `Duration`). Co-authored-by: Yuval Kogman <nothingmuch@woobling.org>
5e045ba to
d8d7f99
Compare
|
LGTM |
Internally, introduce a newtype wrapping bitcoin::absolute::Time (which
is what BIP 77 specifies) instead of using std::time::SystemTime.
A fallible constructor
Time::from_now(std::time::Duration)is used toconstruct these values from a
Duration, which is indirectly called bywith_expiration. NoIntoTimetrait analogous toIntoUrlis included inthis commit, but this could be added there as long as both the
re-exported and the new
Timetype implement it.Introducing a newtype lets us add additional conversion and arithmetic
functionality later without breaking the API or relying on extension
traits on the bitcoin Time type. Since it is now only
pub(crate), thenewtype wrapper's existence is now not entirely justified, as this no
longer re-exports a foreign type in our pub api (previous iterations of
the commit made it pub, replacing the use of
Duration).Replaces #1021
Depends on #1082
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.