tMerge pull request #1419 from romanz/tests - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit f9ab33592f5d109e5c50fac67548d034cd698276 DIR parent 686153bed3faa2e25a96a87553f0bdf2f3732470 HTML Author: ThomasV <electrumdev@gmail.com> Date: Mon, 24 Aug 2015 17:09:31 +0200 Merge pull request #1419 from romanz/tests ttest_mnemonic: add tests for mnemonics Diffstat: A lib/tests/test_mnemonic.py | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+), 0 deletions(-) --- DIR diff --git a/lib/tests/test_mnemonic.py b/lib/tests/test_mnemonic.py t@@ -0,0 +1,34 @@ +import unittest +from lib import mnemonic +from lib import old_mnemonic + +class Test_NewMnemonic(unittest.TestCase): + + def test_prepare_seed(self): + seed = 'foo BAR Baz' + self.assertEquals(mnemonic.prepare_seed(seed), 'foo bar baz') + + def test_to_seed(self): + seed = mnemonic.Mnemonic.mnemonic_to_seed(mnemonic='foobar', passphrase='none') + self.assertEquals(seed.encode('hex'), + '741b72fd15effece6bfe5a26a52184f66811bd2be363190e07a42cca442b1a5b' + 'b22b3ad0eb338197287e6d314866c7fba863ac65d3f156087a5052ebc7157fce') + + def test_random_seeds(self): + iters = 10 + m = mnemonic.Mnemonic(lang='en') + for _ in range(iters): + seed = m.make_seed() + self.assertTrue(m.check_seed(seed, custom_entropy=1)) + i = m.mnemonic_decode(seed) + self.assertEquals(m.mnemonic_encode(i), seed) + + +class Test_OldMnemonic(unittest.TestCase): + + def test(self): + seed = '8edad31a95e7d59f8837667510d75a4d' + result = old_mnemonic.mn_encode(seed) + words = 'hardly point goal hallway patience key stone difference ready caught listen fact' + self.assertEquals(result, words.split()) + self.assertEquals(old_mnemonic.mn_decode(result), seed)