mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Add some tests (#828)
* Add tests * Add tests * Add tests * Add tests * Fix code style * Remove unnecessary tests
This commit is contained in:
parent
e4e58831bf
commit
87e936195e
2 changed files with 168 additions and 0 deletions
54
src/config/config_test.go
Normal file
54
src/config/config_test.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfig_Keys(t *testing.T) {
|
||||
var nodeConfig NodeConfig
|
||||
nodeConfig.NewKeys()
|
||||
|
||||
publicKey1, err := hex.DecodeString(nodeConfig.PublicKey)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal("can not decode generated public key")
|
||||
}
|
||||
|
||||
if len(publicKey1) == 0 {
|
||||
t.Fatal("empty public key generated")
|
||||
}
|
||||
|
||||
privateKey1, err := hex.DecodeString(nodeConfig.PrivateKey)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal("can not decode generated private key")
|
||||
}
|
||||
|
||||
if len(privateKey1) == 0 {
|
||||
t.Fatal("empty private key generated")
|
||||
}
|
||||
|
||||
nodeConfig.NewKeys()
|
||||
|
||||
publicKey2, err := hex.DecodeString(nodeConfig.PublicKey)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal("can not decode generated public key")
|
||||
}
|
||||
|
||||
if bytes.Equal(publicKey2, publicKey1) {
|
||||
t.Fatal("same public key generated")
|
||||
}
|
||||
|
||||
privateKey2, err := hex.DecodeString(nodeConfig.PrivateKey)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal("can not decode generated private key")
|
||||
}
|
||||
|
||||
if bytes.Equal(privateKey2, privateKey1) {
|
||||
t.Fatal("same private key generated")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue