2024-11-15 12:55:14 +00:00
|
|
|
# flake8: noqa: F403,F405
|
2024-01-26 11:16:55 +00:00
|
|
|
from common import * # isort:skip
|
2019-05-10 14:23:18 +00:00
|
|
|
|
2019-08-26 16:47:49 +00:00
|
|
|
if not utils.BITCOIN_ONLY:
|
2021-03-23 12:35:27 +00:00
|
|
|
from trezor.messages import EosAsset
|
2019-05-10 14:23:18 +00:00
|
|
|
|
2024-01-26 11:16:55 +00:00
|
|
|
from apps.eos import helpers
|
|
|
|
|
2019-08-26 16:47:49 +00:00
|
|
|
|
|
|
|
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
2019-05-10 14:23:18 +00:00
|
|
|
class TestEosConversions(unittest.TestCase):
|
|
|
|
def test_eos_name_to_string(self):
|
|
|
|
names_in = [
|
|
|
|
10639447606881920736,
|
|
|
|
614251623682315968,
|
|
|
|
614251535012020768,
|
|
|
|
7754926748989239168,
|
|
|
|
14895601873759291472,
|
|
|
|
595056260442243600,
|
|
|
|
]
|
|
|
|
names_out = [
|
2023-06-28 10:46:29 +00:00
|
|
|
"miniminimini",
|
|
|
|
"12345abcdefg",
|
|
|
|
"123451234512",
|
|
|
|
"hijklmnopqrs",
|
|
|
|
"tuvwxyz12345",
|
|
|
|
"111111111111",
|
2019-05-10 14:23:18 +00:00
|
|
|
]
|
|
|
|
for i, o in zip(names_in, names_out):
|
|
|
|
self.assertEqual(helpers.eos_name_to_string(i), o)
|
|
|
|
|
|
|
|
def test_eos_asset_to_string(self):
|
|
|
|
asset_in = [
|
|
|
|
EosAsset(
|
2023-06-28 10:46:29 +00:00
|
|
|
amount=10000,
|
|
|
|
symbol=1397703940,
|
2019-05-10 14:23:18 +00:00
|
|
|
),
|
|
|
|
EosAsset(
|
2023-06-28 10:46:29 +00:00
|
|
|
amount=200000,
|
|
|
|
symbol=1397703940,
|
2019-05-10 14:23:18 +00:00
|
|
|
),
|
|
|
|
EosAsset(
|
2023-06-28 10:46:29 +00:00
|
|
|
amount=255000,
|
|
|
|
symbol=1397703940,
|
2019-05-10 14:23:18 +00:00
|
|
|
),
|
|
|
|
EosAsset(
|
2023-06-28 10:46:29 +00:00
|
|
|
amount=999999,
|
|
|
|
symbol=1397703939,
|
2019-05-10 14:23:18 +00:00
|
|
|
),
|
|
|
|
EosAsset(
|
2023-06-28 10:46:29 +00:00
|
|
|
amount=1,
|
|
|
|
symbol=1397703940,
|
2019-05-10 14:23:18 +00:00
|
|
|
),
|
|
|
|
EosAsset(
|
2023-06-28 10:46:29 +00:00
|
|
|
amount=999,
|
|
|
|
symbol=1397703939,
|
2019-05-10 14:23:18 +00:00
|
|
|
),
|
|
|
|
]
|
|
|
|
asset_out = [
|
2023-06-28 10:46:29 +00:00
|
|
|
"1.0000 EOS",
|
|
|
|
"20.0000 EOS",
|
|
|
|
"25.5000 EOS",
|
|
|
|
"999.999 EOS",
|
|
|
|
"0.0001 EOS",
|
|
|
|
"0.999 EOS",
|
2019-05-10 14:23:18 +00:00
|
|
|
]
|
|
|
|
for i, o in zip(asset_in, asset_out):
|
|
|
|
self.assertEqual(helpers.eos_asset_to_string(i), o)
|
|
|
|
|
2023-06-28 10:46:29 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-05-10 14:23:18 +00:00
|
|
|
unittest.main()
|