2017-12-18 15:33:26 +00:00
|
|
|
from common import *
|
|
|
|
|
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):
|
|
|
|
|
|
|
|
token = tokens.token_by_chain_address(1, b'\x7d\xd7\xf5\x6d\x69\x7c\xc0\xf2\xb5\x2b\xd5\x5c\x05\x7f\x37\x8f\x1f\xe6\xab\x4b')
|
2021-08-31 09:45:21 +00:00
|
|
|
self.assertEqual(token.symbol, '$TEAK')
|
2018-03-03 22:37:21 +00:00
|
|
|
|
2017-12-18 15:33:26 +00:00
|
|
|
token = tokens.token_by_chain_address(1, b'\x59\x41\x6a\x25\x62\x8a\x76\xb4\x73\x0e\xc5\x14\x86\x11\x4c\x32\xe0\xb5\x82\xa1')
|
2021-08-31 09:45:21 +00:00
|
|
|
self.assertEqual(token.symbol, 'PLASMA')
|
|
|
|
self.assertEqual(token.decimals, 6)
|
2018-03-03 22:37:21 +00:00
|
|
|
|
|
|
|
token = tokens.token_by_chain_address(4, b'\x0a\x05\x7a\x87\xce\x9c\x56\xd7\xe3\x36\xb4\x17\xc7\x9c\xf3\x0e\x8d\x27\x86\x0b')
|
2021-08-31 09:45:21 +00:00
|
|
|
self.assertEqual(token.symbol, 'WALL')
|
|
|
|
self.assertEqual(token.decimals, 15)
|
2018-03-03 22:37:21 +00:00
|
|
|
|
2017-12-18 15:33:26 +00:00
|
|
|
token = tokens.token_by_chain_address(8, b'\x4b\x48\x99\xa1\x0f\x3e\x50\x7d\xb2\x07\xb0\xee\x24\x26\x02\x9e\xfa\x16\x8a\x67')
|
2021-08-31 09:45:21 +00:00
|
|
|
self.assertEqual(token.symbol, 'QWARK')
|
2017-12-18 15:33:26 +00:00
|
|
|
|
|
|
|
# invalid adress, invalid chain
|
|
|
|
token = tokens.token_by_chain_address(999, b'\x00\xFF')
|
2018-05-10 12:50:56 +00:00
|
|
|
self.assertIs(token, tokens.UNKNOWN_TOKEN)
|
2021-08-31 09:45:21 +00:00
|
|
|
self.assertEqual(token.symbol, 'Wei UNKN')
|
|
|
|
self.assertEqual(token.decimals, 0)
|
2017-12-18 15:33:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|