Skip to content

Commit

Permalink
Merge pull request #1938 from EchterAgo/fix_cashaddr_test
Browse files Browse the repository at this point in the history
tests: fix cashaddr checksum test unreliability
  • Loading branch information
cculianu committed Aug 3, 2020
2 parents 9954742 + b774696 commit dffce1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/tests/test_cashaddrenc.py
Expand Up @@ -152,14 +152,14 @@ def test_bad_decode_checksum(self):
# Inject an error
values = list(cashaddr._CHARSET)
while True:
pos = random.randint(0, len(addr) - 1)
pos = random.randint(len(BCH_PREFIX) + 1, len(addr) - 1)
choice = random.choice(values)
if choice != addrlist[pos] and addrlist[pos] in values:
addrlist[pos] = choice
break

mangled_addr = ''.join(addrlist)
with self.assertRaises(ValueError) as e:
with self.assertRaises(ValueError, msg=mangled_addr) as e:
cashaddr.decode(mangled_addr)
self.assertTrue('invalid checksum' in e.exception.args[0])

Expand Down

0 comments on commit dffce1a

Please sign in to comment.