|
|
|
|
@ -59,6 +59,25 @@ defmodule GcIndexRelay.Nostr.PubEventTest do
@@ -59,6 +59,25 @@ defmodule GcIndexRelay.Nostr.PubEventTest do
|
|
|
|
|
assert {:error, :not_found} = PubEvent.from_db(nil) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "restores Nostr tag order from shuffled tag rows by database id" do |
|
|
|
|
event = %Event{ |
|
|
|
|
id: Base.decode16!(String.duplicate("ab", 32), case: :lower), |
|
|
|
|
pubkey: Base.decode16!(String.duplicate("cd", 32), case: :lower), |
|
|
|
|
created_at: ~U[2021-12-20 17:46:40Z], |
|
|
|
|
kind: 30_040, |
|
|
|
|
content: "", |
|
|
|
|
sig: Base.decode16!(String.duplicate("ef", 64), case: :lower), |
|
|
|
|
tags: [ |
|
|
|
|
%Tag{id: 300, name: "a", value: "chapter-2", additional_values: []}, |
|
|
|
|
%Tag{id: 100, name: "d", value: "book", additional_values: []}, |
|
|
|
|
%Tag{id: 200, name: "title", value: "Title", additional_values: []} |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
assert {:ok, pub_event} = PubEvent.from_db(event) |
|
|
|
|
assert pub_event.tags == [["d", "book"], ["title", "Title"], ["a", "chapter-2"]] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "converts Tag structs back to nested lists" do |
|
|
|
|
event = %Event{ |
|
|
|
|
id: Base.decode16!(String.duplicate("ab", 32), case: :lower), |
|
|
|
|
|