1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00
trezor-firmware/core/tests/test_apps.eos.check_action.py

53 lines
4.4 KiB
Python
Raw Normal View History

add EOS support Squashed commit of the following: commit 060563458fbc3b4a17f4d77ba5cd62d0c265c806 Author: matejcik <ja@matejcik.cz> Date: Fri May 10 16:16:19 2019 +0200 skip t1 in eos test commit f759089fef29501467b62bf1540715132a72c4cf Author: matejcik <ja@matejcik.cz> Date: Fri May 10 15:55:20 2019 +0200 make style commit 3ecdd5f77b331d7a6e5a46a10c79d80f214f31bd Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu May 9 22:05:41 2019 +0300 Refinements in asset to to string conversion function according to code review and test cases for amounts less than 1 commit 72e44a35bada76abdd94ab866c2113a6d9d85191 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Wed May 8 00:27:45 2019 +0300 Moved to input_flow rest of the tests, cleanup and styling commit 92f9acbabcbef44a6912b074a309393450f0c8de Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue May 7 21:47:12 2019 +0300 Fix for amounts less then 1 commit 8a0154f7432ab78e69a123202a97194d34c2a3cb Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:26:24 2019 +0300 removed unnecessary peace of code commit b25c15de3eb1df863760e81ca69f09094349c26e Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:16:57 2019 +0300 Fixed validate path parameters commit f0f6e7036a8b88d9c5c6b702a8d851e9a9bd3378 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:04:58 2019 +0300 Fixes commit 0c64d3814300df86d452975b2bd46fea13f512d2 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:19:51 2019 +0300 Fixed styling commit 41d1e77231e7da78fade9b2efa1b7d1980f0d3a8 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:13:58 2019 +0300 Changes to core, added CURVE to path validation commit c045b4554ee8e058dbfe35f715b003d0d85ab1d4 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:07:37 2019 +0300 Changes according to review commit 3f0e6cfd40e7d87dc3287bc3a0b2b9db5dea5377 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon Apr 29 21:37:16 2019 +0300 Added change to make expiration date timezone agnostic commit efdf44c326cc3f3137c447e798db5439b57c91fa Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu Apr 18 00:14:30 2019 +0300 changes according to code review commit 3b3723da8f8f536c7c370a14236ea81aac25080a Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:44:50 2019 +0300 Merged python to monorepo commit da6b0c683c29388e15c889ecea6e7f7471961a19 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:13:42 2019 +0300 Merged core to monorepo
2019-05-10 14:23:18 +00:00
from common import *
if not utils.BITCOIN_ONLY:
from apps.eos.actions import check_action
from trezor.messages import EosTxActionAck
add EOS support Squashed commit of the following: commit 060563458fbc3b4a17f4d77ba5cd62d0c265c806 Author: matejcik <ja@matejcik.cz> Date: Fri May 10 16:16:19 2019 +0200 skip t1 in eos test commit f759089fef29501467b62bf1540715132a72c4cf Author: matejcik <ja@matejcik.cz> Date: Fri May 10 15:55:20 2019 +0200 make style commit 3ecdd5f77b331d7a6e5a46a10c79d80f214f31bd Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu May 9 22:05:41 2019 +0300 Refinements in asset to to string conversion function according to code review and test cases for amounts less than 1 commit 72e44a35bada76abdd94ab866c2113a6d9d85191 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Wed May 8 00:27:45 2019 +0300 Moved to input_flow rest of the tests, cleanup and styling commit 92f9acbabcbef44a6912b074a309393450f0c8de Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue May 7 21:47:12 2019 +0300 Fix for amounts less then 1 commit 8a0154f7432ab78e69a123202a97194d34c2a3cb Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:26:24 2019 +0300 removed unnecessary peace of code commit b25c15de3eb1df863760e81ca69f09094349c26e Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:16:57 2019 +0300 Fixed validate path parameters commit f0f6e7036a8b88d9c5c6b702a8d851e9a9bd3378 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:04:58 2019 +0300 Fixes commit 0c64d3814300df86d452975b2bd46fea13f512d2 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:19:51 2019 +0300 Fixed styling commit 41d1e77231e7da78fade9b2efa1b7d1980f0d3a8 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:13:58 2019 +0300 Changes to core, added CURVE to path validation commit c045b4554ee8e058dbfe35f715b003d0d85ab1d4 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:07:37 2019 +0300 Changes according to review commit 3f0e6cfd40e7d87dc3287bc3a0b2b9db5dea5377 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon Apr 29 21:37:16 2019 +0300 Added change to make expiration date timezone agnostic commit efdf44c326cc3f3137c447e798db5439b57c91fa Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu Apr 18 00:14:30 2019 +0300 changes according to code review commit 3b3723da8f8f536c7c370a14236ea81aac25080a Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:44:50 2019 +0300 Merged python to monorepo commit da6b0c683c29388e15c889ecea6e7f7471961a19 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:13:42 2019 +0300 Merged core to monorepo
2019-05-10 14:23:18 +00:00
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
add EOS support Squashed commit of the following: commit 060563458fbc3b4a17f4d77ba5cd62d0c265c806 Author: matejcik <ja@matejcik.cz> Date: Fri May 10 16:16:19 2019 +0200 skip t1 in eos test commit f759089fef29501467b62bf1540715132a72c4cf Author: matejcik <ja@matejcik.cz> Date: Fri May 10 15:55:20 2019 +0200 make style commit 3ecdd5f77b331d7a6e5a46a10c79d80f214f31bd Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu May 9 22:05:41 2019 +0300 Refinements in asset to to string conversion function according to code review and test cases for amounts less than 1 commit 72e44a35bada76abdd94ab866c2113a6d9d85191 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Wed May 8 00:27:45 2019 +0300 Moved to input_flow rest of the tests, cleanup and styling commit 92f9acbabcbef44a6912b074a309393450f0c8de Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue May 7 21:47:12 2019 +0300 Fix for amounts less then 1 commit 8a0154f7432ab78e69a123202a97194d34c2a3cb Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:26:24 2019 +0300 removed unnecessary peace of code commit b25c15de3eb1df863760e81ca69f09094349c26e Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:16:57 2019 +0300 Fixed validate path parameters commit f0f6e7036a8b88d9c5c6b702a8d851e9a9bd3378 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:04:58 2019 +0300 Fixes commit 0c64d3814300df86d452975b2bd46fea13f512d2 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:19:51 2019 +0300 Fixed styling commit 41d1e77231e7da78fade9b2efa1b7d1980f0d3a8 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:13:58 2019 +0300 Changes to core, added CURVE to path validation commit c045b4554ee8e058dbfe35f715b003d0d85ab1d4 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:07:37 2019 +0300 Changes according to review commit 3f0e6cfd40e7d87dc3287bc3a0b2b9db5dea5377 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon Apr 29 21:37:16 2019 +0300 Added change to make expiration date timezone agnostic commit efdf44c326cc3f3137c447e798db5439b57c91fa Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu Apr 18 00:14:30 2019 +0300 changes according to code review commit 3b3723da8f8f536c7c370a14236ea81aac25080a Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:44:50 2019 +0300 Merged python to monorepo commit da6b0c683c29388e15c889ecea6e7f7471961a19 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:13:42 2019 +0300 Merged core to monorepo
2019-05-10 14:23:18 +00:00
class TestEosActions(unittest.TestCase):
def test_check_action(self):
2019-05-26 20:20:14 +00:00
# return True
self.assertEqual(check_action(EosTxActionAck(common=object(), buy_ram=object()), 'buyram', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), buy_ram_bytes=object()), 'buyrambytes', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), sell_ram=object()), 'sellram', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), delegate=object()), 'delegatebw', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), undelegate=object()), 'undelegatebw', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), refund=object()), 'refund', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), vote_producer=object()), 'voteproducer', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), update_auth=object()), 'updateauth', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), delete_auth=object()), 'deleteauth', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), link_auth=object()), 'linkauth', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), unlink_auth=object()), 'unlinkauth', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), new_account=object()), 'newaccount', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), transfer=object()), 'transfer', 'not_eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), unknown=[]), 'unknown', 'not_eosio'), True)
self.assertEqual(check_action(EosTxActionAck(common=object(), unknown=[]), 'buyram', 'buygoods'), True)
add EOS support Squashed commit of the following: commit 060563458fbc3b4a17f4d77ba5cd62d0c265c806 Author: matejcik <ja@matejcik.cz> Date: Fri May 10 16:16:19 2019 +0200 skip t1 in eos test commit f759089fef29501467b62bf1540715132a72c4cf Author: matejcik <ja@matejcik.cz> Date: Fri May 10 15:55:20 2019 +0200 make style commit 3ecdd5f77b331d7a6e5a46a10c79d80f214f31bd Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu May 9 22:05:41 2019 +0300 Refinements in asset to to string conversion function according to code review and test cases for amounts less than 1 commit 72e44a35bada76abdd94ab866c2113a6d9d85191 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Wed May 8 00:27:45 2019 +0300 Moved to input_flow rest of the tests, cleanup and styling commit 92f9acbabcbef44a6912b074a309393450f0c8de Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue May 7 21:47:12 2019 +0300 Fix for amounts less then 1 commit 8a0154f7432ab78e69a123202a97194d34c2a3cb Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:26:24 2019 +0300 removed unnecessary peace of code commit b25c15de3eb1df863760e81ca69f09094349c26e Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:16:57 2019 +0300 Fixed validate path parameters commit f0f6e7036a8b88d9c5c6b702a8d851e9a9bd3378 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:04:58 2019 +0300 Fixes commit 0c64d3814300df86d452975b2bd46fea13f512d2 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:19:51 2019 +0300 Fixed styling commit 41d1e77231e7da78fade9b2efa1b7d1980f0d3a8 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:13:58 2019 +0300 Changes to core, added CURVE to path validation commit c045b4554ee8e058dbfe35f715b003d0d85ab1d4 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:07:37 2019 +0300 Changes according to review commit 3f0e6cfd40e7d87dc3287bc3a0b2b9db5dea5377 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon Apr 29 21:37:16 2019 +0300 Added change to make expiration date timezone agnostic commit efdf44c326cc3f3137c447e798db5439b57c91fa Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu Apr 18 00:14:30 2019 +0300 changes according to code review commit 3b3723da8f8f536c7c370a14236ea81aac25080a Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:44:50 2019 +0300 Merged python to monorepo commit da6b0c683c29388e15c889ecea6e7f7471961a19 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:13:42 2019 +0300 Merged core to monorepo
2019-05-10 14:23:18 +00:00
2019-05-26 20:20:14 +00:00
# returns False
self.assertEqual(check_action(EosTxActionAck(common=object(), buy_ram=object()), 'buyram', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object()), 'buyram', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), buy_ram_bytes=object()), 'buyrambytes', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), sell_ram=object()), 'sellram', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), delegate=object()), 'delegatebw', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), undelegate=object()), 'undelegatebw', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), refund=object()), 'refund', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object()), 'refund', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), vote_producer=object()), 'voteproducer', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), update_auth=object()), 'updateauth', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), delete_auth=object()), 'deleteauth', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), link_auth=object()), 'linkauth', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), unlink_auth=object()), 'unlinkauth', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object()), 'unlinkauth', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), new_account=object()), 'newaccount', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), transfer=object()), 'transfer', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object()), 'unknown', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), buy_ram=object()), 'test', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), unknown=[]), 'buyram', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(common=object(), unknown=[]), 'transfer', 'loveme'), False)
2019-05-26 20:20:14 +00:00
add EOS support Squashed commit of the following: commit 060563458fbc3b4a17f4d77ba5cd62d0c265c806 Author: matejcik <ja@matejcik.cz> Date: Fri May 10 16:16:19 2019 +0200 skip t1 in eos test commit f759089fef29501467b62bf1540715132a72c4cf Author: matejcik <ja@matejcik.cz> Date: Fri May 10 15:55:20 2019 +0200 make style commit 3ecdd5f77b331d7a6e5a46a10c79d80f214f31bd Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu May 9 22:05:41 2019 +0300 Refinements in asset to to string conversion function according to code review and test cases for amounts less than 1 commit 72e44a35bada76abdd94ab866c2113a6d9d85191 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Wed May 8 00:27:45 2019 +0300 Moved to input_flow rest of the tests, cleanup and styling commit 92f9acbabcbef44a6912b074a309393450f0c8de Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue May 7 21:47:12 2019 +0300 Fix for amounts less then 1 commit 8a0154f7432ab78e69a123202a97194d34c2a3cb Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:26:24 2019 +0300 removed unnecessary peace of code commit b25c15de3eb1df863760e81ca69f09094349c26e Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:16:57 2019 +0300 Fixed validate path parameters commit f0f6e7036a8b88d9c5c6b702a8d851e9a9bd3378 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 23:04:58 2019 +0300 Fixes commit 0c64d3814300df86d452975b2bd46fea13f512d2 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:19:51 2019 +0300 Fixed styling commit 41d1e77231e7da78fade9b2efa1b7d1980f0d3a8 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:13:58 2019 +0300 Changes to core, added CURVE to path validation commit c045b4554ee8e058dbfe35f715b003d0d85ab1d4 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon May 6 22:07:37 2019 +0300 Changes according to review commit 3f0e6cfd40e7d87dc3287bc3a0b2b9db5dea5377 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Mon Apr 29 21:37:16 2019 +0300 Added change to make expiration date timezone agnostic commit efdf44c326cc3f3137c447e798db5439b57c91fa Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Thu Apr 18 00:14:30 2019 +0300 changes according to code review commit 3b3723da8f8f536c7c370a14236ea81aac25080a Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:44:50 2019 +0300 Merged python to monorepo commit da6b0c683c29388e15c889ecea6e7f7471961a19 Author: Andriy Tkachyshyn <atkachyshyn@gmail.com> Date: Tue Apr 16 23:13:42 2019 +0300 Merged core to monorepo
2019-05-10 14:23:18 +00:00
if __name__ == '__main__':
unittest.main()