github.com/jonasnick/go-ethereum@v0.7.12-0.20150216215225-22176f05d387/crypto/mnemonic_test.go (about) 1 package crypto 2 3 import ( 4 "testing" 5 ) 6 7 func TestMnDecode(t *testing.T) { 8 words := []string{ 9 "ink", 10 "balance", 11 "gain", 12 "fear", 13 "happen", 14 "melt", 15 "mom", 16 "surface", 17 "stir", 18 "bottle", 19 "unseen", 20 "expression", 21 "important", 22 "curl", 23 "grant", 24 "fairy", 25 "across", 26 "back", 27 "figure", 28 "breast", 29 "nobody", 30 "scratch", 31 "worry", 32 "yesterday", 33 } 34 encode := "c61d43dc5bb7a4e754d111dae8105b6f25356492df5e50ecb33b858d94f8c338" 35 result := MnemonicDecode(words) 36 if encode != result { 37 t.Error("We expected", encode, "got", result, "instead") 38 } 39 } 40 func TestMnEncode(t *testing.T) { 41 encode := "c61d43dc5bb7a4e754d111dae8105b6f25356492df5e50ecb33b858d94f8c338" 42 result := []string{ 43 "ink", 44 "balance", 45 "gain", 46 "fear", 47 "happen", 48 "melt", 49 "mom", 50 "surface", 51 "stir", 52 "bottle", 53 "unseen", 54 "expression", 55 "important", 56 "curl", 57 "grant", 58 "fairy", 59 "across", 60 "back", 61 "figure", 62 "breast", 63 "nobody", 64 "scratch", 65 "worry", 66 "yesterday", 67 } 68 words := MnemonicEncode(encode) 69 for i, word := range words { 70 if word != result[i] { 71 t.Error("Mnenonic does not match:", words, result) 72 } 73 } 74 }