mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-12 04:30:04 +00:00
26 lines
522 B
Go
26 lines
522 B
Go
|
package direct
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/tyler-smith/go-bip39"
|
||
|
)
|
||
|
|
||
|
func TestMnemonic_Generate_CanRecover(t *testing.T) {
|
||
|
generator := &EnglishMnemonicGenerator{}
|
||
|
data := make([]byte, 32)
|
||
|
copy(data, []byte("hello-world"))
|
||
|
phrase, err := generator.Generate(data)
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
entropy, err := bip39.EntropyFromMnemonic(phrase)
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
if !bytes.Equal(entropy, data) {
|
||
|
t.Errorf("Expected to recover original data: %v, received %v", data, entropy)
|
||
|
}
|
||
|
}
|