2017-12-18 15:33:26 +00:00
|
|
|
from common import *
|
2017-12-22 15:17:32 +00:00
|
|
|
from apps.ethereum import sign_tx
|
2017-12-18 15:33:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestEthereumSignTx(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_format(self):
|
2017-12-22 15:17:32 +00:00
|
|
|
text = sign_tx.format_amount((1).to_bytes(5, 'little'), None, 1)
|
2017-12-18 15:33:26 +00:00
|
|
|
self.assertEqual(text, '1 Wei')
|
2017-12-22 15:17:32 +00:00
|
|
|
text = sign_tx.format_amount((1000).to_bytes(5, 'little'), None, 1)
|
2017-12-18 15:33:26 +00:00
|
|
|
self.assertEqual(text, '1000 Wei')
|
|
|
|
|
2017-12-22 15:17:32 +00:00
|
|
|
text = sign_tx.format_amount((1000000000000000001).to_bytes(20, 'little'), None, 1)
|
2017-12-18 15:33:26 +00:00
|
|
|
self.assertEqual(text, '1 ETH')
|
2017-12-22 15:17:32 +00:00
|
|
|
text = sign_tx.format_amount((10000000000000000001).to_bytes(20, 'little'), None, 1)
|
2017-12-18 15:33:26 +00:00
|
|
|
self.assertEqual(text, '10 ETH')
|
2017-12-22 15:17:32 +00:00
|
|
|
text = sign_tx.format_amount((10000000000000000001).to_bytes(20, 'little'), None, 61)
|
2017-12-18 15:33:26 +00:00
|
|
|
self.assertEqual(text, '10 ETC')
|
2017-12-22 15:17:32 +00:00
|
|
|
text = sign_tx.format_amount((1000000000000000001).to_bytes(20, 'little'), None, 31)
|
2017-12-18 15:33:26 +00:00
|
|
|
self.assertEqual(text, '1 tRSK')
|
|
|
|
|
|
|
|
# unknown chain
|
2017-12-22 15:17:32 +00:00
|
|
|
text = sign_tx.format_amount((1).to_bytes(20, 'little'), None, 9999)
|
2017-12-18 15:33:26 +00:00
|
|
|
self.assertEqual(text, '1 Wei')
|
2017-12-22 15:17:32 +00:00
|
|
|
text = sign_tx.format_amount((10000000000000000001).to_bytes(20, 'little'), None, 9999)
|
2017-12-18 15:33:26 +00:00
|
|
|
self.assertEqual(text, '10 UNKN')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|