Skip to content
Snippets Groups Projects
Commit be769901 authored by Holger's avatar Holger
Browse files

Fix Brainkey.suggest() for python 2.7

Unit test added for keygen and suggest()
parent 7b9ee9c7
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ beem - Unofficial Python Library for Steem
===============================================
beem is an unofficial python library for steem, which is created new from scratch from `python-bitshares`_
The library name is derived from a beam maschine, similar to the analogy between steem and steam. beem includes `python-graphenelib`_.
The library name is derived from a beam machine, similar to the analogy between steem and steam. beem includes `python-graphenelib`_.
.. image:: https://img.shields.io/pypi/v/beem.svg
:target: https://pypi.python.org/pypi/beem/
......
......@@ -132,7 +132,10 @@ class BrainKey(object):
if not len(dict_lines) == 49744:
raise AssertionError()
for j in range(0, word_count):
num = int.from_bytes(os.urandom(2), byteorder="little")
urand = os.urandom(2)
if isinstance(urand, str):
urand = py23_bytes(urand, 'ascii')
num = int.from_bytes(urand, byteorder="little")
rndMult = num / 2 ** 16 # returns float between 0..1 (inclusive)
wIdx = round(len(dict_lines) * rndMult)
brainkey[j] = dict_lines[wIdx]
......
......@@ -145,6 +145,11 @@ class Testcases(unittest.TestCase):
result = runner.invoke(cli, ['walletinfo'])
self.assertEqual(result.exit_code, 0)
def test_keygen(self):
runner = CliRunner()
result = runner.invoke(cli, ['keygen'])
self.assertEqual(result.exit_code, 0)
def test_set(self):
runner = CliRunner()
result = runner.invoke(cli, ['-o', 'set', 'set_default_vote_weight', '100'])
......
......@@ -157,6 +157,10 @@ class Testcases(unittest.TestCase):
],
[b, b, b, b, b, b, b])
def test_BrainKey_suggest(self):
b = BrainKey()
self.assertTrue(len(b.suggest()) > 0)
def test_BrainKey_sequences(self):
b = BrainKey("COLORER BICORN KASBEKE FAERIE LOCHIA GOMUTI SOVKHOZ Y GERMAL AUNTIE PERFUMY TIME FEATURE GANGAN CELEMIN MATZO")
keys = ["5Hsbn6kXio4bb7eW5bX7kTp2sdkmbzP8kGWoau46Cf7en7T1RRE",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment