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
|
2017-12-18 15:33:26 +00:00
|
|
|
|
2019-08-26 16:47:49 +00:00
|
|
|
if not utils.BITCOIN_ONLY:
|
|
|
|
from apps.ethereum import tokens
|
2017-12-18 15:33:26 +00:00
|
|
|
|
2019-08-26 16:47:49 +00:00
|
|
|
|
|
|
|
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
2017-12-18 15:33:26 +00:00
|
|
|
class TestEthereumTokens(unittest.TestCase):
|
|
|
|
def test_token_by_chain_address(self):
|
|
|
|
|
2023-06-28 10:46:29 +00:00
|
|
|
token = tokens.token_by_chain_address(
|
|
|
|
1,
|
|
|
|
b"\x7f\xc6\x65\x00\xc8\x4a\x76\xad\x7e\x9c\x93\x43\x7b\xfc\x5a\xc3\x3e\x2d\xda\xe9",
|
|
|
|
)
|
|
|
|
self.assertEqual(token.symbol, "AAVE")
|
2017-12-18 15:33:26 +00:00
|
|
|
|
|
|
|
# invalid adress, invalid chain
|
2023-06-28 10:46:29 +00:00
|
|
|
token = tokens.token_by_chain_address(999, b"\x00\xFF")
|
2023-02-03 13:39:31 +00:00
|
|
|
self.assertIs(token, None)
|
|
|
|
|
2023-06-28 10:46:29 +00:00
|
|
|
self.assertEqual(tokens.UNKNOWN_TOKEN.symbol, "Wei UNKN")
|
2023-02-03 13:39:31 +00:00
|
|
|
self.assertEqual(tokens.UNKNOWN_TOKEN.decimals, 0)
|
2017-12-18 15:33:26 +00:00
|
|
|
|
|
|
|
|
2023-06-28 10:46:29 +00:00
|
|
|
if __name__ == "__main__":
|
2017-12-18 15:33:26 +00:00
|
|
|
unittest.main()
|