2024-01-26 11:16:55 +00:00
|
|
|
from common import * # isort:skip
|
2016-11-15 10:57:18 +00:00
|
|
|
|
|
|
|
from apps.common import coins
|
|
|
|
|
2017-12-16 01:11:26 +00:00
|
|
|
|
2016-11-15 10:57:18 +00:00
|
|
|
class TestCoins(unittest.TestCase):
|
2019-08-26 16:47:49 +00:00
|
|
|
def test_bitcoin(self):
|
2016-11-15 10:57:18 +00:00
|
|
|
ref = [
|
2023-06-28 10:46:29 +00:00
|
|
|
("BTC", "Bitcoin", 0),
|
|
|
|
("TEST", "Testnet", 111),
|
|
|
|
("REGTEST", "Regtest", 111),
|
2019-08-26 16:47:49 +00:00
|
|
|
]
|
|
|
|
for s, n, a in ref:
|
|
|
|
c = coins.by_name(n)
|
|
|
|
self.assertEqual(c.address_type, a)
|
|
|
|
self.assertEqual(c.coin_shortcut, s)
|
|
|
|
|
|
|
|
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
|
|
|
def test_altcoins(self):
|
|
|
|
ref = [
|
2023-06-28 10:46:29 +00:00
|
|
|
("LTC", "Litecoin", 48),
|
|
|
|
("ZEC", "Zcash", 7352),
|
|
|
|
("TAZ", "Zcash Testnet", 7461),
|
2016-11-15 10:57:18 +00:00
|
|
|
]
|
2024-08-27 10:21:40 +00:00
|
|
|
if utils.INTERNAL_MODEL in ("T1B1", "T2T1"):
|
2024-01-26 14:39:39 +00:00
|
|
|
ref.extend(
|
|
|
|
[
|
|
|
|
("NMC", "Namecoin", 52),
|
|
|
|
("DASH", "Dash", 76),
|
|
|
|
]
|
|
|
|
)
|
2016-11-15 10:57:18 +00:00
|
|
|
for s, n, a in ref:
|
2019-05-22 14:46:49 +00:00
|
|
|
c = coins.by_name(n)
|
|
|
|
self.assertEqual(c.address_type, a)
|
|
|
|
self.assertEqual(c.coin_shortcut, s)
|
2016-11-15 10:57:18 +00:00
|
|
|
|
|
|
|
def test_failure(self):
|
|
|
|
with self.assertRaises(ValueError):
|
2023-06-28 10:46:29 +00:00
|
|
|
coins.by_name("XXXXX")
|
2016-11-15 10:57:18 +00:00
|
|
|
|
|
|
|
|
2023-06-28 10:46:29 +00:00
|
|
|
if __name__ == "__main__":
|
2016-11-15 10:57:18 +00:00
|
|
|
unittest.main()
|