dns-api/utils_test.go

22 lines
670 B
Go

package dns_api
import (
"git.gammaspectra.live/givna.me/dns-api/ed25519"
"testing"
)
const testPrivateKey = "PT0gZWQyNTUxOXYxLXNlY3JldDogdHlwZTAgPT0AAAC4WKtXqyPlfMRwf37uSI/0kZRY8rzFBCpcDPeCp15uUalOhEmCQtBYH7oihSe8J4Znf9Gzw1E7W377Y6K3ux8V"
const testOnionAddress = "testdqzsnwe6dpmbhgcm5arrvhqzhomxs27nn2sertphnmfx7z44gzyd"
func TestPublicKeyToOnionV3(t *testing.T) {
privateKey := DecodeTorPrivateKey(testPrivateKey)
if privateKey == nil {
t.Fail()
}
generatedAddress := PublicKeyToOnionV3(privateKey.Public().(ed25519.PublicKey))
if generatedAddress != testOnionAddress {
t.Errorf("expected address %s, got %s", testOnionAddress, generatedAddress)
}
}