-
Notifications
You must be signed in to change notification settings - Fork 561
Update HomeserverTestCase.get_success(...) and friends to drive async Rust (Tokio runtime/thread pool)
#19871
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
Changes from all commits
520a4bc
65a1c59
fdeed9a
5ca9050
6e9b2a2
c45774c
ae7e367
f54d0c0
997a160
b501ad1
9cfd0f9
66a515b
a1092da
09c91d3
4357aa4
edce488
5cc4590
5b27102
44253df
47297af
cc2c27b
26dc512
2bce6e7
3425d15
ecce873
2c51142
999d22d
41642be
350b15f
60ddfc6
167ad62
ad0bbb6
f0e968a
85edec1
919a94c
2c8ea3a
2300a19
a1170c6
efcd574
749ea8b
77ddfcf
92346f2
ce1758c
0add7cd
a871de0
74060df
28586c6
cb91056
a975f83
34f015f
e7b09b3
f11be8b
453a296
2bff819
a12a9e0
d034373
77184c8
5be3534
77ce7a5
bc54b65
3cb3c66
c37b6ce
6e86cf3
235c90a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Update `HomeserverTestCase.get_success(...)` and friends to drive async Rust (Tokio runtime/thread pool). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -499,7 +499,7 @@ async def get_json(destination: str, path: str, **kwargs: Any) -> JsonDict: | |
| res = key_json[testverifykey_id] | ||
| self.assertIsNotNone(res) | ||
| assert res is not None | ||
| self.assertEqual(res.added_ts, self.reactor.seconds() * 1000) | ||
| self.assertEqual(res.added_ts, self.clock.time_msec()) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated this to actually use millisecond resolution. Previously, this test passed because the clock was using round numbers but we updated |
||
| self.assertEqual(res.valid_until_ts, VALID_UNTIL_TS) | ||
|
|
||
| # we expect it to be encoded as canonical json *before* it hits the db | ||
|
|
@@ -614,7 +614,7 @@ def test_get_keys_from_perspectives(self) -> None: | |
| res = key_json[testverifykey_id] | ||
| self.assertIsNotNone(res) | ||
| assert res is not None | ||
| self.assertEqual(res.added_ts, self.reactor.seconds() * 1000) | ||
| self.assertEqual(res.added_ts, self.clock.time_msec()) | ||
| self.assertEqual(res.valid_until_ts, VALID_UNTIL_TS) | ||
|
|
||
| self.assertEqual(res.key_json, canonicaljson.encode_canonical_json(response)) | ||
|
|
@@ -732,7 +732,7 @@ def test_get_perspectives_own_key(self) -> None: | |
| res = key_json[testverifykey_id] | ||
| self.assertIsNotNone(res) | ||
| assert res is not None | ||
| self.assertEqual(res.added_ts, self.reactor.seconds() * 1000) | ||
| self.assertEqual(res.added_ts, self.clock.time_msec()) | ||
| self.assertEqual(res.valid_until_ts, VALID_UNTIL_TS) | ||
|
|
||
| self.assertEqual(res.key_json, canonicaljson.encode_canonical_json(response)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -357,7 +357,6 @@ def create_invite() -> EventBase: | |
| event.room_version, | ||
| ), | ||
| exc=LimitExceededError, | ||
| by=0.5, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a lot of cases, the |
||
| ) | ||
|
|
||
| def _build_and_send_join_event( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -960,7 +960,7 @@ def test_exchange_code_jwt_key(self) -> None: | |
| # advance the clock a bit before we start, so we aren't working with zero | ||
| # timestamps. | ||
| self.reactor.advance(1000) | ||
| start_time = self.reactor.seconds() | ||
| start_time_s = int(self.reactor.seconds()) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated this to actually use second resolution. Previously, this test passed because the clock was using round numbers but we updated |
||
| ret = self.get_success(self.provider._exchange_code(code, code_verifier="")) | ||
|
|
||
| self.assertEqual(ret, token) | ||
|
|
@@ -981,8 +981,8 @@ def test_exchange_code_jwt_key(self) -> None: | |
| self.assertEqual(claims["aud"], ISSUER) | ||
| self.assertEqual(claims["iss"], "DEFGHI") | ||
| self.assertEqual(claims["sub"], CLIENT_ID) | ||
| self.assertEqual(claims["iat"], start_time) | ||
| self.assertGreater(claims["exp"], start_time) | ||
| self.assertEqual(claims["iat"], start_time_s) | ||
| self.assertGreater(claims["exp"], start_time_s) | ||
|
|
||
| # check the rest of the POSTed data | ||
| self.assertEqual(args["grant_type"], ["authorization_code"]) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
The explanation here is slightly hand-wavey.
The other comment explanations are more concrete at-least in the fact that I've traced some scheduled reactor callback.