-
Notifications
You must be signed in to change notification settings - Fork 27
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(simulator): Patch BaseTransaction.resolve() to prevent updating timestamp #641
Conversation
09d8bf0
to
0d70490
Compare
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.
Just curious, why would the timestamp update make tests fail?
Because Check out this part of the code: https://github.com/HathorNetwork/hathor-core/blob/master/hathor/manager.py#L976-L982 |
0d70490
to
96e8b0f
Compare
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.
Do we still need the timestamp update? Couldn't we just remove it? Or default it to not doing an update and requiring a "timestamp source", like a reactor to do it?
Mostly I'd prefer to avoid doing patches.
96e8b0f
to
0cf0e1d
Compare
Codecov Report
@@ Coverage Diff @@
## master #641 +/- ##
==========================================
- Coverage 84.06% 84.05% -0.01%
==========================================
Files 245 245
Lines 20270 20277 +7
Branches 2758 2758
==========================================
+ Hits 17039 17043 +4
- Misses 2635 2636 +1
- Partials 596 598 +2
|
Acceptance criteria
BaseTransaction.resolve()
to prevent updating timestamp.Notice that
BaseTransaction.resolve()
callsBaseTransaction.start_mining()
, which updates the timestamp usingtime.time()
if mining takes more than two seconds. This might be causing tests to randomly fail.The reasons for tests to randomly fail is that
Transaction.start_mining()
is usingtime.time()
to get the timestamp (instead ofreactor.seconds()
). As the reactor time is not related to the current timestamp, the transaction timestamp can be too much in the future raising aInvalidNewTransaction
exception.For more details, check out this part of the code: https://github.com/HathorNetwork/hathor-core/blob/master/hathor/manager.py#L976-L982