File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 11defmodule Nostr.Models.Note.IdTest do
22 use ExUnit.Case
33
4- doctest Nostr.Models.Note.Id
4+ alias Nostr.Models.Note
5+
6+ doctest Note.Id
7+
8+ test "convert an bech32 note id with to_binary/1" do
9+ bech32_note_id = "note1qkjgra6cm5ms6m88kqdapfjnxm8q50lcurevtpvm4f6pfs8j5sxq90f098"
10+
11+ { :ok , note_id } = Note.Id . to_binary ( bech32_note_id )
12+
13+ assert << 0x05A481F758DD370D6CE7B01BD0A65336CE0A3FF8E0F2C5859BAA7414C0F2A40C :: 256 >> == note_id
14+ end
15+
16+ test "convert a binary note id to binary with to_binary/1" do
17+ note_id = << 0x05A481F758DD370D6CE7B01BD0A65336CE0A3FF8E0F2C5859BAA7414C0F2A40C :: 256 >>
18+
19+ { :ok , binary_note_id } = Note.Id . to_binary ( note_id )
20+
21+ assert note_id == binary_note_id
22+ end
23+
24+ test "try converting an invalid string to binary note id with to_binary/1" do
25+ invalid_note_id = "this_won't_work"
26+
27+ { :error , message } = Note.Id . to_binary ( invalid_note_id )
28+
29+ assert message =~ "is not a valid note id"
30+ end
531end
You can’t perform that action at this time.
0 commit comments