mnemonic_test.go 1.1 KB

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