From 341c1ec7d7a0d2cae3c70dbc480de8499d1da7d5 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Thu, 5 Aug 2021 10:33:21 +0500 Subject: [PATCH] Add tests --- src/address/address_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/address/address_test.go b/src/address/address_test.go index 21aa6c29..247f5963 100644 --- a/src/address/address_test.go +++ b/src/address/address_test.go @@ -1,6 +1,7 @@ package address import ( + "crypto/ed25519" "math/rand" "testing" ) @@ -50,3 +51,20 @@ func TestAddress_Subnet_IsValid(t *testing.T) { 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") + } +}