mirror of
https://git.wownero.com/lza_menace/wownero-python.git
synced 2024-08-15 03:25:25 +00:00
Add range check
This commit is contained in:
parent
b0526972bd
commit
3b832040c6
2 changed files with 11 additions and 0 deletions
|
@ -199,6 +199,11 @@ class Wallet(object):
|
|||
|
||||
:rtype: :class:`BaseAddress <monero.address.BaseAddress>`
|
||||
"""
|
||||
# ensure indexes are within uint32
|
||||
if major < 0 or major >= 2**32:
|
||||
raise ValueError('major index {} is outside uint32 range'.format(major))
|
||||
if minor < 0 or minor >= 2**32:
|
||||
raise ValueError('minor index {} is outside uint32 range'.format(minor))
|
||||
master_address = self.address()
|
||||
if major == minor == 0:
|
||||
return master_address
|
||||
|
|
|
@ -38,6 +38,12 @@ class AddressTestCase(Tests, unittest.TestCase):
|
|||
svk = '6d9056aa2c096bfcd2f272759555e5764ba204dd362604a983fa3e0aafd35901'
|
||||
net = 'mainnet'
|
||||
|
||||
def test_subaddress_out_of_range(self):
|
||||
self.assertRaises(ValueError, self.wallet.get_address, 0, -1)
|
||||
self.assertRaises(ValueError, self.wallet.get_address, -1, 0)
|
||||
self.assertRaises(ValueError, self.wallet.get_address, 1, 2**32)
|
||||
self.assertRaises(ValueError, self.wallet.get_address, 2**32, 1)
|
||||
|
||||
|
||||
class TestnetAddressTestCase(Tests, unittest.TestCase):
|
||||
addr = '9wuKTHsxGiwEsMp2fYzJiVahyhU2aZi1oZ6R6fK5U64uRa1Pxi8diZh2S1GJFqYXRRhcbfzfWiPD819zKEZkXTMwP7hMs5N'
|
||||
|
|
Loading…
Reference in a new issue