package nostr import "testing" func TestGraphResultContent(t *testing.T) { r := NewGraphResult() r.AddPubkeyAtDepth("bb", 1) r.AddPubkeyAtDepth("aa", 1) r.AddPubkeyAtDepth("aa", 2) // duplicate at a later depth is ignored r.AddPubkeyAtDepth("cc", 3) r.Sort() got := string(r.AppendContentJSON(nil)) want := `{"pubkeys_by_depth":[["aa","bb"],[],["cc"]],"total_pubkeys":3}` if got != want { t.Fatalf("content:\n got %s\nwant %s", got, want) } e := NewGraphResult() e.AddEventAtDepth("dd", 1) e.AddEventAtDepth("ee", 2) e.Sort() got = string(e.AppendContentJSON(nil)) want = `{"events_by_depth":[["dd"],["ee"]],"total_events":2}` if got != want { t.Fatalf("content:\n got %s\nwant %s", got, want) } }