-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package nip05 | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestParse(t *testing.T) { | ||
name, domain, _ := ParseIdentifier("[email protected]") | ||
if name != "saknd" || domain != "yyq.com" { | ||
t.Fatalf("wrong parsing") | ||
} | ||
|
||
name, domain, _ = ParseIdentifier("287354gkj+asbdfo8gw3rlicbsopifbcp3iougb5piseubfdikswub5ks@yyq.com") | ||
if name != "287354gkj+asbdfo8gw3rlicbsopifbcp3iougb5piseubfdikswub5ks" || domain != "yyq.com" { | ||
t.Fatalf("wrong parsing") | ||
} | ||
|
||
name, domain, _ = ParseIdentifier("asdn.com") | ||
if name != "_" || domain != "asdn.com" { | ||
t.Fatalf("wrong parsing") | ||
} | ||
|
||
name, domain, _ = ParseIdentifier("[email protected]") | ||
if name != "_" || domain != "uxux.com.br" { | ||
t.Fatalf("wrong parsing") | ||
} | ||
|
||
_, _, err := ParseIdentifier("821yh498ig21") | ||
if err == nil { | ||
t.Fatalf("should have errored") | ||
} | ||
|
||
_, _, err = ParseIdentifier("////") | ||
if err == nil { | ||
t.Fatalf("should have errored") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package nip46 | ||
|
||
import "testing" | ||
|
||
func TestValidBunkerURL(t *testing.T) { | ||
if !IsValidBunkerURL("bunker://3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d?relay=wss%3A%2F%2Frelay.damus.io&relay=wss%3A%2F%2Frelay.snort.social&relay=wss%3A%2F%2Frelay.nsecbunker.com") { | ||
t.Fatalf("should be valid") | ||
} | ||
if IsValidBunkerURL("askjdbkajdbv") { | ||
t.Fatalf("should be invalid") | ||
} | ||
if IsValidBunkerURL("[email protected]") { | ||
t.Fatalf("should be invalid") | ||
} | ||
if IsValidBunkerURL("https://hello.com?relays=wss://xxxxxx.xxxx") { | ||
t.Fatalf("should be invalid") | ||
} | ||
if IsValidBunkerURL("bunker://fa883d107ef9e558472c4eb9aaaefa459d?relay=wss%3A%2F%2Frelay.damus.io&relay=wss%3A%2F%2Frelay.snort.social&relay=wss%3A%2F%2Frelay.nsecbunker.com") { | ||
t.Fatalf("should be invalid") | ||
} | ||
} |