mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-13 17:00:59 +00:00
tests: add test for apps.common.coins
This commit is contained in:
parent
f7fe5344b8
commit
b09f0eaf4e
@ -90,18 +90,18 @@ def by_shortcut(shortcut):
|
||||
for c in COINS:
|
||||
if c.coin_shortcut == shortcut:
|
||||
return c
|
||||
raise Exception('Unknown coin shortcut "%s"' % shortcut)
|
||||
raise ValueError('Unknown coin shortcut "%s"' % shortcut)
|
||||
|
||||
|
||||
def by_name(name):
|
||||
for c in COINS:
|
||||
if c.coin_name == name:
|
||||
return c
|
||||
raise Exception('Unknown coin name "%s"' % name)
|
||||
raise ValueError('Unknown coin name "%s"' % name)
|
||||
|
||||
|
||||
def by_address_type(version):
|
||||
for c in COINS:
|
||||
if c.address_type == version:
|
||||
return c
|
||||
raise Exception('Unknown coin address type %d' % version)
|
||||
raise ValueError('Unknown coin address type %d' % version)
|
||||
|
36
tests/test_apps.common.coins.py
Normal file
36
tests/test_apps.common.coins.py
Normal file
@ -0,0 +1,36 @@
|
||||
from common import *
|
||||
|
||||
from apps.common import coins
|
||||
|
||||
class TestCoins(unittest.TestCase):
|
||||
|
||||
def test_coins(self):
|
||||
ref = [
|
||||
('BTC', 'Bitcoin', 0),
|
||||
('TEST', 'Testnet', 111),
|
||||
('NMC', 'Namecoin', 52),
|
||||
('LTC', 'Litecoin', 48),
|
||||
('DOGE', 'Dogecoin', 30),
|
||||
('DASH', 'Dash', 76),
|
||||
('ZEC', 'Zcash', 7352),
|
||||
('TAZ', 'Zcash Testnet', 7461),
|
||||
]
|
||||
for s, n, a in ref:
|
||||
c1 = coins.by_shortcut(s)
|
||||
c2 = coins.by_name(n)
|
||||
c3 = coins.by_address_type(a)
|
||||
self.assertEqual(c1, c2)
|
||||
self.assertEqual(c1, c3)
|
||||
self.assertEqual(c2, c3)
|
||||
|
||||
def test_failure(self):
|
||||
with self.assertRaises(ValueError):
|
||||
coins.by_shortcut('XXX')
|
||||
with self.assertRaises(ValueError):
|
||||
coins.by_name('XXXXX')
|
||||
with self.assertRaises(ValueError):
|
||||
coins.by_address_type(1234)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -17,7 +17,6 @@ from trezor.messages import OutputScriptType
|
||||
from apps.common import coins
|
||||
from apps.common import signtx
|
||||
|
||||
|
||||
class TestSignTx(unittest.TestCase):
|
||||
# pylint: disable=C0301
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user