lbry-sdk/tests/unit/wallet/test_mnemonic.py

24 lines
722 B
Python
Raw Normal View History

2018-05-25 08:03:25 +02:00
import unittest
from binascii import hexlify
2020-01-03 07:55:19 +01:00
from lbry.wallet.mnemonic import Mnemonic
2018-05-25 08:03:25 +02:00
class TestMnemonic(unittest.TestCase):
def test_mnemonic_to_seed(self):
seed = Mnemonic.mnemonic_to_seed(mnemonic='foobar', passphrase='torba')
2018-05-25 08:03:25 +02:00
self.assertEqual(
hexlify(seed),
b'475a419db4e991cab14f08bde2d357e52b3e7241f72c6d8a2f92782367feeee9f403dc6a37c26a3f02ab9'
b'dec7f5063161eb139cea00da64cd77fba2f07c49ddc'
)
def test_make_seed_decode_encode(self):
iters = 10
m = Mnemonic('en')
for _ in range(iters):
seed = m.make_seed()
i = m.mnemonic_decode(seed)
self.assertEqual(m.mnemonic_encode(i), seed)