prysm-pulse/tools/unencrypted-keys-gen/main_test.go
2019-10-19 10:29:25 -07:00

27 lines
521 B
Go

package main
import (
"bytes"
"encoding/json"
"reflect"
"testing"
)
func TestSavesUnencryptedKeys(t *testing.T) {
keys := 2
numKeys = &keys
ctnr := generateUnencryptedKeys(0 /* start index */)
buf := new(bytes.Buffer)
if err := SaveUnencryptedKeysToFile(buf, ctnr); err != nil {
t.Fatal(err)
}
enc := buf.Bytes()
dec := &UnencryptedKeysContainer{}
if err := json.Unmarshal(enc, dec); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(ctnr, dec) {
t.Errorf("Wanted %v, received %v", ctnr, dec)
}
}