prysm-pulse/validator/keymanager/v2/derived/mnemonic_test.go
Victor Farazdagi e5b7c3f3e6
Applies assertion funcs to validator/keymanager tests (#6683)
* Applies assertion funcs to validator/keymanager/v1 tests
* gazelle
* Applies assertion funcs to validator/keymanager/v2 tests
* Merge refs/heads/master into validator-keymanager-apply-testutils-assertions
* Merge refs/heads/master into validator-keymanager-apply-testutils-assertions
2020-07-22 19:42:43 +00:00

21 lines
557 B
Go

package derived
import (
"testing"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/tyler-smith/go-bip39"
)
func TestMnemonic_Generate_CanRecover(t *testing.T) {
generator := &EnglishMnemonicGenerator{}
data := make([]byte, 32)
copy(data, "hello-world")
phrase, err := generator.Generate(data)
require.NoError(t, err)
entropy, err := bip39.EntropyFromMnemonic(phrase)
require.NoError(t, err)
assert.DeepEqual(t, data, entropy, "Expected to recover original data")
}