style: Styling i forgot to commit earlier
This commit is contained in:
parent
a85fce7e3f
commit
0c17410e18
@ -95,6 +95,7 @@ async def test_client() -> None:
|
|||||||
|
|
||||||
if msg.type.name == "BUFFER":
|
if msg.type.name == "BUFFER":
|
||||||
img_data += msg.data
|
img_data += msg.data
|
||||||
|
|
||||||
if msg.type.name == "JSON" and msg.data == b"true":
|
if msg.type.name == "JSON" and msg.data == b"true":
|
||||||
assert (
|
assert (
|
||||||
base64.b64encode(hashlib.sha256(img_data).digest()) == b"kqZ52sDcJSHOx7m4Ww80kK1KIZ65gpGnqwZlfaIVWWM="
|
base64.b64encode(hashlib.sha256(img_data).digest()) == b"kqZ52sDcJSHOx7m4Ww80kK1KIZ65gpGnqwZlfaIVWWM="
|
||||||
|
@ -43,6 +43,7 @@ async def on_connect(conn: SHSDuplexStream) -> None:
|
|||||||
api.add_connection(packet_stream)
|
api.add_connection(packet_stream)
|
||||||
|
|
||||||
print("connect", conn)
|
print("connect", conn)
|
||||||
|
|
||||||
async for msg in packet_stream:
|
async for msg in packet_stream:
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
|
@ -109,7 +109,6 @@ class Message:
|
|||||||
):
|
):
|
||||||
self.feed = feed
|
self.feed = feed
|
||||||
self.content = content
|
self.content = content
|
||||||
|
|
||||||
self.signature = signature
|
self.signature = signature
|
||||||
self.previous = previous
|
self.previous = previous
|
||||||
self.timestamp = get_millis_1970() if timestamp is None else timestamp
|
self.timestamp = get_millis_1970() if timestamp is None else timestamp
|
||||||
@ -199,4 +198,5 @@ class LocalMessage(Message):
|
|||||||
def _sign(self) -> str:
|
def _sign(self) -> str:
|
||||||
# ensure ordering of keys and indentation of 2 characters, like ssb-keys
|
# ensure ordering of keys and indentation of 2 characters, like ssb-keys
|
||||||
data = self.serialize(add_signature=False)
|
data = self.serialize(add_signature=False)
|
||||||
|
|
||||||
return (b64encode(bytes(self.feed.sign(data))) + b".sig.ed25519").decode("ascii")
|
return (b64encode(bytes(self.feed.sign(data))) + b".sig.ed25519").decode("ascii")
|
||||||
|
@ -134,6 +134,7 @@ class PSMessage:
|
|||||||
|
|
||||||
if self.type == PSMessageType.TEXT:
|
if self.type == PSMessageType.TEXT:
|
||||||
assert isinstance(self.body, str)
|
assert isinstance(self.body, str)
|
||||||
|
|
||||||
return self.body.encode("utf-8")
|
return self.body.encode("utf-8")
|
||||||
|
|
||||||
if self.type == PSMessageType.JSON:
|
if self.type == PSMessageType.JSON:
|
||||||
|
@ -59,4 +59,5 @@ def load_ssb_secret(filename: Optional[str] = None) -> SSBSecret:
|
|||||||
raise ConfigException("Algorithm not known: " + config["curve"])
|
raise ConfigException("Algorithm not known: " + config["curve"])
|
||||||
|
|
||||||
server_prv_key = b64decode(config["private"][:-8])
|
server_prv_key = b64decode(config["private"][:-8])
|
||||||
|
|
||||||
return {"keypair": SigningKey(server_prv_key[:32]), "id": config["id"]}
|
return {"keypair": SigningKey(server_prv_key[:32]), "id": config["id"]}
|
||||||
|
@ -303,6 +303,7 @@ async def test_message_stream(
|
|||||||
handler = list(ps._event_map.values())[1][1] # pylint: disable=protected-access
|
handler = list(ps._event_map.values())[1][1] # pylint: disable=protected-access
|
||||||
|
|
||||||
mock_process = mocker.patch.object(handler, "process", wraps=handler.process)
|
mock_process = mocker.patch.object(handler, "process", wraps=handler.process)
|
||||||
|
|
||||||
ps_client.feed(
|
ps_client.feed(
|
||||||
[
|
[
|
||||||
b"\n\x00\x00\x02\xc5\xff\xff\xff\xfe",
|
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
|
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
|
handler = list(ps._event_map.values())[0][1] # pylint: disable=protected-access
|
||||||
mock_process = mocker.patch.object(handler, "process")
|
mock_process = mocker.patch.object(handler, "process")
|
||||||
|
|
||||||
ps_server.feed(
|
ps_server.feed(
|
||||||
[
|
[
|
||||||
b"\x02\x00\x00\x00>\xff\xff\xff\xff",
|
b"\x02\x00\x00\x00>\xff\xff\xff\xff",
|
||||||
|
Loading…
Reference in New Issue
Block a user