style: Styling i forgot to commit earlier

This commit is contained in:
Gergely Polonkai 2023-11-18 06:50:51 +01:00
parent a85fce7e3f
commit 0c17410e18
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
6 changed files with 7 additions and 1 deletions

View File

@ -95,6 +95,7 @@ async def test_client() -> None:
if msg.type.name == "BUFFER":
img_data += msg.data
if msg.type.name == "JSON" and msg.data == b"true":
assert (
base64.b64encode(hashlib.sha256(img_data).digest()) == b"kqZ52sDcJSHOx7m4Ww80kK1KIZ65gpGnqwZlfaIVWWM="

View File

@ -43,6 +43,7 @@ async def on_connect(conn: SHSDuplexStream) -> None:
api.add_connection(packet_stream)
print("connect", conn)
async for msg in packet_stream:
print(msg)

View File

@ -109,7 +109,6 @@ class Message:
):
self.feed = feed
self.content = content
self.signature = signature
self.previous = previous
self.timestamp = get_millis_1970() if timestamp is None else timestamp
@ -199,4 +198,5 @@ class LocalMessage(Message):
def _sign(self) -> str:
# ensure ordering of keys and indentation of 2 characters, like ssb-keys
data = self.serialize(add_signature=False)
return (b64encode(bytes(self.feed.sign(data))) + b".sig.ed25519").decode("ascii")

View File

@ -134,6 +134,7 @@ class PSMessage:
if self.type == PSMessageType.TEXT:
assert isinstance(self.body, str)
return self.body.encode("utf-8")
if self.type == PSMessageType.JSON:

View File

@ -59,4 +59,5 @@ def load_ssb_secret(filename: Optional[str] = None) -> SSBSecret:
raise ConfigException("Algorithm not known: " + config["curve"])
server_prv_key = b64decode(config["private"][:-8])
return {"keypair": SigningKey(server_prv_key[:32]), "id": config["id"]}

View File

@ -303,6 +303,7 @@ async def test_message_stream(
handler = list(ps._event_map.values())[1][1] # pylint: disable=protected-access
mock_process = mocker.patch.object(handler, "process", wraps=handler.process)
ps_client.feed(
[
b"\n\x00\x00\x02\xc5\xff\xff\xff\xfe",
@ -348,6 +349,7 @@ async def test_message_request(
assert ps.register_handler.call_count == 1 # type: ignore[attr-defined] # pylint: disable=no-member
handler = list(ps._event_map.values())[0][1] # pylint: disable=protected-access
mock_process = mocker.patch.object(handler, "process")
ps_server.feed(
[
b"\x02\x00\x00\x00>\xff\xff\xff\xff",