Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit eaec12b

Browse files
committed
Added unit test for digest -> address.
Also renamed `address_from_digest` to `address_from_digest_trits`.
1 parent f723546 commit eaec12b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/iota/crypto/addresses.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def create_iterator(self, start=0, step=1):
256256
yield address
257257

258258
@staticmethod
259-
def address_from_digest(digest_trits, key_index):
259+
def address_from_digest_trits(digest_trits, key_index):
260260
# type: (List[int], int) -> Address
261261
"""
262262
Generates an address from a private key digest.
@@ -279,13 +279,13 @@ def _generate_address(self, key_iterator):
279279
280280
Used in the event of a cache miss.
281281
"""
282-
return self.address_from_digest(*self._get_digest_params(key_iterator))
282+
return self.address_from_digest_trits(*self._get_digest_params(key_iterator))
283283

284284
@staticmethod
285285
def _get_digest_params(key_iterator):
286286
# type: (KeyIterator) -> Tuple[List[int], int]
287287
"""
288-
Extracts parameters for :py:meth:`address_from_digest`.
288+
Extracts parameters for :py:meth:`address_from_digest_trits`.
289289
290290
Split into a separate method so that it can be mocked during unit
291291
tests.

test/crypto/addresses_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ def setUp(self):
4646
b'CFANWBQFGMFKITZBJDSYLGXYUIQVCMXFWSWFRNHRV'
4747
)
4848

49+
# noinspection SpellCheckingInspection
50+
def test_address_from_digest(self):
51+
"""
52+
Generating an address from a private key digest.
53+
"""
54+
digest =\
55+
Hash(
56+
b'ABQXVJNER9MPMXMBPNMFBMDGTXRWSYHNZKGAGUOI'
57+
b'JKOJGZVGHCUXXGFZEMMGDSGWDCKJXO9ILLFAKGGZE'
58+
)
59+
60+
self.assertEqual(
61+
AddressGenerator.address_from_digest_trits(digest.as_trits(), 0),
62+
63+
Address(
64+
b'QLOEDSBXXOLLUJYLEGKEPYDRIJJTPIMEPKMFHUVJ'
65+
b'MPMLYYCLPQPANEVDSERQWPVNHCAXYRLAYMBHJLWWR'
66+
),
67+
)
68+
4969
def test_get_addresses_single(self):
5070
"""
5171
Generating a single address.

0 commit comments

Comments
 (0)