-
Notifications
You must be signed in to change notification settings - Fork 61
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
Perform client time sync on login #1004
Conversation
Add current_time to the command welcome sent to the client on login. Closes FAForever#889
Update tests to suit #60d684a8ad3441c89f947a7aad4efffe291f4de6: Add current_time to the command welcome sent to the client on login.
Fix E261 at least two spaces before inline comment
I dont know wtf with that linter so just remove comments at all...
One failed test (tests/integration_tests/test_matchmaker.py→test_game_matchmaking_timeout[qstream]: asyncio.exceptions.TimeoutError) is irrelevant to this PR, so search someone fix for that in other issues. |
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.
Thanks for the contribution! The test failure was just a flaky test, there are still a few that can happen from time to time. I reran the tests which should probably take care of that.
Co-authored-by: Askaholic <[email protected]>
Also there are several |
Ah, yea you should leave those. They actually are a bit of a special case because they are compared to datetime objects created automatically by sqlalchemy which are always timezone unaware. The |
Nice, all checks passed finally! @Askaholic ure right, mocked server.timing plus added context manager helper for further cases. Can this be merged now? p.s. |
@Askaholic , hey! Hope ure going well. What is the status of this PR? |
Sorry, I haven’t had time to take care of this yet, my weekends have been pretty busy recently. It looks great though! My only suggestion would be if you were up for it, to rework the |
Sure, just checking everything is fine.
Well, that is not quite true because there can be timing-relying tests (like check timeout/latency/performance of net io) hence fixture with hard fix all timestamps will fail. I have several ideas:
What do you think about these? |
Is that an issue in any of these tests though? I think generally for timing related things internally we use either I'm thinking for scenarios like testing the ban expiration it would actually be really nice to be able to do something like: def test_ban_expired(fixed_time):
fixed_time.set(100)
# Insert 30 minute ban into database
...
fixed_time.set(100 + 30) # Whatever the units would be
# Assert that ban has expired
...
|
Np, if you assume no sequence timings are considered in tests. Now your example would be: def test_ban_expired(fixed_time):
assert server.lobbyconnection.datetime_now().timestamp == 0.
fixed_time(100)
assert server.lobbyconnection.datetime_now().timestamp == 100.
# Insert 30 minute ban into database
...
fixed_time(100 + 30) # Whatever the units would be
assert server.lobbyconnection.datetime_now().timestamp == 130.
# Assert that ban has expired
...
|
Add current_time to the command welcome sent to the client on login.
Closes #889