2021-11-04 08:05:53 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConfig_Keys(t *testing.T) {
|
2023-04-06 20:45:49 +00:00
|
|
|
/*
|
|
|
|
var nodeConfig NodeConfig
|
|
|
|
nodeConfig.NewKeys()
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
publicKey1, err := hex.DecodeString(nodeConfig.PublicKey)
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("can not decode generated public key")
|
|
|
|
}
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
if len(publicKey1) == 0 {
|
|
|
|
t.Fatal("empty public key generated")
|
|
|
|
}
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
privateKey1, err := hex.DecodeString(nodeConfig.PrivateKey)
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("can not decode generated private key")
|
|
|
|
}
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
if len(privateKey1) == 0 {
|
|
|
|
t.Fatal("empty private key generated")
|
|
|
|
}
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
nodeConfig.NewKeys()
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
publicKey2, err := hex.DecodeString(nodeConfig.PublicKey)
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("can not decode generated public key")
|
|
|
|
}
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
if bytes.Equal(publicKey2, publicKey1) {
|
|
|
|
t.Fatal("same public key generated")
|
|
|
|
}
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
privateKey2, err := hex.DecodeString(nodeConfig.PrivateKey)
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal("can not decode generated private key")
|
|
|
|
}
|
2021-11-04 08:05:53 +00:00
|
|
|
|
2023-04-06 20:45:49 +00:00
|
|
|
if bytes.Equal(privateKey2, privateKey1) {
|
|
|
|
t.Fatal("same private key generated")
|
|
|
|
}
|
|
|
|
*/
|
2021-11-04 08:05:53 +00:00
|
|
|
}
|