Skip to content

Commit

Permalink
Merge pull request #3 from oconnor663/master
Browse files Browse the repository at this point in the history
test round trips
  • Loading branch information
keis committed Apr 9, 2015
2 parents 11ed30a + 78c37f6 commit 06c297c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from contextlib import contextmanager
from itertools import product
from hamcrest import assert_that, equal_to, instance_of
from base58 import b58encode, b58decode, b58encode_check, b58decode_check

Expand Down Expand Up @@ -67,3 +68,12 @@ def test_check_failure():
data = '3vQB7B6MrGQZaxCuFg4oH'
with assert_raises(ValueError):
b58decode_check(data)


def test_round_trips():
possible_bytes = [b'\x00', b'\x01', b'\x10', b'\xff']
for length in range(0, 5):
for bytes_to_test in product(possible_bytes, repeat=length):
bytes_in = b''.join(bytes_to_test)
bytes_out = b58decode(b58encode(bytes_in))
assert_that(bytes_in, equal_to(bytes_out))

0 comments on commit 06c297c

Please sign in to comment.