mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
nip49: add normalization test.
This commit is contained in:
parent
2cba101c22
commit
faf76711a5
@ -1,6 +1,8 @@
|
||||
package nip49
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@ -51,3 +53,21 @@ func TestEncryptAndDecrypt(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalization(t *testing.T) {
|
||||
nonce := []byte{1, 2, 3, 4}
|
||||
n := 8
|
||||
key1, err1 := getKey(string([]byte{0xE2, 0x84, 0xAB, 0xE2, 0x84, 0xA6}), nonce, n)
|
||||
key2, err2 := getKey(string([]byte{0xC3, 0x85, 0xCE, 0xA9}), nonce, n)
|
||||
key3, err3 := getKey("ÅΩ", nonce, n)
|
||||
key4, err4 := getKey("ÅΩ", nonce, n)
|
||||
if merr := errors.Join(err1, err2, err3, err4); merr != nil {
|
||||
t.Fatalf("getKey errored: %s", merr)
|
||||
return
|
||||
}
|
||||
|
||||
if !slices.Equal(key1, key2) || !slices.Equal(key2, key3) || !slices.Equal(key3, key4) {
|
||||
t.Fatalf("normalization failed")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user