Add tests

This commit is contained in:
Alex Kotov 2021-08-05 10:33:21 +05:00
parent 451fbd32c3
commit 341c1ec7d7
No known key found for this signature in database
GPG key ID: 553C0EBBEB5D5F08

View file

@ -1,6 +1,7 @@
package address package address
import ( import (
"crypto/ed25519"
"math/rand" "math/rand"
"testing" "testing"
) )
@ -50,3 +51,20 @@ func TestAddress_Subnet_IsValid(t *testing.T) {
t.Fatal("valid subnet marked as invalid") t.Fatal("valid subnet marked as invalid")
} }
} }
func TestAddress_AddrForKey(t *testing.T) {
publicKey := ed25519.PublicKey{
189, 186, 207, 216, 34, 64, 222, 61, 205, 18, 57, 36, 203, 181, 82, 86,
251, 141, 171, 8, 170, 152, 227, 5, 82, 138, 184, 79, 65, 158, 110, 251,
}
gotAddress := AddrForKey(publicKey)
expectedAddress := Address{
2, 0, 132, 138, 96, 79, 187, 126, 67, 132, 101, 219, 141, 182, 104, 149,
}
if *gotAddress != expectedAddress {
t.Fatal("invalid address returned")
}
}