1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-19 22:18:13 +00:00
trezor-firmware/core/tests/test_apps.eos.check_action.py
matejcik 2e578572dd 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 16:23:18 +02:00

65 lines
4.9 KiB
Python

from common import *
from apps.eos.actions import check_action
from trezor.messages.EosTxActionAck import EosTxActionAck
from trezor.messages.EosActionBuyRam import EosActionBuyRam
from trezor.messages.EosActionBuyRamBytes import EosActionBuyRamBytes
from trezor.messages.EosActionDelegate import EosActionDelegate
from trezor.messages.EosActionDeleteAuth import EosActionDeleteAuth
from trezor.messages.EosActionLinkAuth import EosActionLinkAuth
from trezor.messages.EosActionNewAccount import EosActionNewAccount
from trezor.messages.EosActionRefund import EosActionRefund
from trezor.messages.EosActionSellRam import EosActionSellRam
from trezor.messages.EosActionTransfer import EosActionTransfer
from trezor.messages.EosActionUndelegate import EosActionUndelegate
from trezor.messages.EosActionUnlinkAuth import EosActionUnlinkAuth
from trezor.messages.EosActionUpdateAuth import EosActionUpdateAuth
from trezor.messages.EosActionVoteProducer import EosActionVoteProducer
class TestEosActions(unittest.TestCase):
def test_check_action(self):
# return True
self.assertEqual(check_action(EosTxActionAck(buy_ram=EosActionBuyRam()), 'buyram', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(buy_ram_bytes=EosActionBuyRamBytes()), 'buyrambytes', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(sell_ram=EosActionSellRam()), 'sellram', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(delegate=EosActionDelegate()), 'delegatebw', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(undelegate=EosActionDeleteAuth()), 'undelegatebw', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(refund=EosActionRefund()), 'refund', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(vote_producer=EosActionVoteProducer()), 'voteproducer', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(update_auth=EosActionUpdateAuth()), 'updateauth', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(delete_auth=EosActionDeleteAuth()), 'deleteauth', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(link_auth=EosActionLinkAuth()), 'linkauth', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(unlink_auth=EosActionUnlinkAuth()), 'unlinkauth', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(new_account=EosActionNewAccount()), 'newaccount', 'eosio'), True)
self.assertEqual(check_action(EosTxActionAck(transfer=EosActionTransfer()), 'transfer', 'not_eosio'), True)
self.assertEqual(check_action(EosTxActionAck(unknown=[]), 'unknown', 'not_eosio'), True)
self.assertEqual(check_action(EosTxActionAck(unknown=[]), 'buyram', 'buygoods'), True)
# returns False
self.assertEqual(check_action(EosTxActionAck(buy_ram=EosActionBuyRam()), 'buyram', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(), 'buyram', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(buy_ram_bytes=EosActionBuyRamBytes()), 'buyrambytes', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(sell_ram=EosActionSellRam()), 'sellram', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(delegate=EosActionDelegate()), 'delegatebw', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(undelegate=EosActionDeleteAuth()), 'undelegatebw', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(refund=EosActionRefund()), 'refund', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(), 'refund', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(vote_producer=EosActionVoteProducer()), 'voteproducer', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(update_auth=EosActionUpdateAuth()), 'updateauth', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(delete_auth=EosActionDeleteAuth()), 'deleteauth', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(link_auth=EosActionLinkAuth()), 'linkauth', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(unlink_auth=EosActionUnlinkAuth()), 'unlinkauth', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(), 'unlinkauth', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(new_account=EosActionNewAccount()), 'newaccount', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(transfer=EosActionTransfer()), 'transfer', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(), 'unknown', 'not_eosio'), False)
self.assertEqual(check_action(EosTxActionAck(buy_ram=EosActionBuyRam()), 'test', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(unknown=[]), 'buyram', 'eosio'), False)
self.assertEqual(check_action(EosTxActionAck(unknown=[]), 'transfer', 'loveme'), False)
if __name__ == '__main__':
unittest.main()