Compare commits

...

2 Commits

Author SHA1 Message Date
glyph 99b6a046b4 add test for str encoding 2022-09-20 11:38:01 +01:00
glyph 58d87d9c6a add str encoder 2022-09-20 11:37:24 +01:00
2 changed files with 11 additions and 1 deletions

View File

@ -46,4 +46,8 @@ defmodule SsbBfe.Encoder do
{:ok, decoded_base64_data} = extract_base64_data(sig, ".sig.ed25519")
<<4, 0>> <> decoded_base64_data
end
end
def encode_str(str), do: <<6, 0>> <> str
# def encode_uri(uri)
end

View File

@ -7,6 +7,7 @@ defmodule SsbBfeEncoderTest do
@classic_feed "@d/zDvFswFbQaYJc03i47C9CgDev+/A8QQSfG5l/SEfw=.ed25519"
@classic_msg "%R8heq/tQoxEIPkWf0Kxn1nCm/CsxG2CDpUYnAvdbXY8=.sha256"
@sig "nkY4Wsn9feosxvX7bpLK7OxjdSrw6gSL8sun1n2TMLXKySYK9L5itVQnV2nQUctFsrUOa2istD2vDk1B0uAMBQ==.sig.ed25519"
@str "golden ripples in the meshwork"
test "encode_blob_works" do
encoded_blob = SsbBfe.Encoder.encode_blob(@blob_id)
@ -44,4 +45,9 @@ defmodule SsbBfeEncoderTest do
encoded_sig = SsbBfe.Encoder.encode_sig(@sig)
assert encoded_sig == <<4, 0, 158, 70, 56, 90, 201, 253, 125, 234, 44, 198, 245, 251, 110, 146, 202, 236, 236, 99, 117, 42, 240, 234, 4, 139, 242, 203, 167, 214, 125, 147, 48, 181, 202, 201, 38, 10, 244, 190, 98, 181, 84, 39, 87, 105, 208, 81, 203, 69, 178, 181, 14, 107, 104, 172, 180, 61, 175, 14, 77, 65, 210, 224, 12, 5>>
end
test "encode_str_works" do
encoded_str = SsbBfe.Encoder.encode_str(@str)
assert encoded_str == <<6, 0, 103, 111, 108, 100, 101, 110, 32, 114, 105, 112, 112, 108, 101, 115, 32, 105, 110, 32, 116, 104, 101, 32, 109, 101, 115, 104, 119, 111, 114, 107>>
end
end