Fix https://github.com/matrix-org/synapse/issues/15836
Adds type hints to tests.metrics and tests.crypto.