2020-07-01 13:43:02 +00:00
|
|
|
from common import *
|
2021-03-23 12:29:25 +00:00
|
|
|
from apps.common.paths import HARDENED
|
2020-07-01 13:43:02 +00:00
|
|
|
|
|
|
|
if not utils.BITCOIN_ONLY:
|
|
|
|
from apps.cardano.sign_tx import _should_hide_output
|
|
|
|
|
|
|
|
|
|
|
|
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
|
|
|
class TestCardanoSignTransaction(unittest.TestCase):
|
|
|
|
def test_should_show_outputs(self):
|
2021-02-11 12:52:45 +00:00
|
|
|
outputs_to_hide = [
|
2021-06-30 12:19:06 +00:00
|
|
|
# byron path
|
|
|
|
[44 | HARDENED, 1815 | HARDENED, 0 | HARDENED, 0, 0],
|
|
|
|
# shelley path
|
|
|
|
[1852 | HARDENED, 1815 | HARDENED, 0 | HARDENED, 0, 0],
|
|
|
|
# path account is 2
|
|
|
|
[1852 | HARDENED, 1815 | HARDENED, 2 | HARDENED, 0, 0],
|
|
|
|
# path index is 2
|
|
|
|
[1852 | HARDENED, 1815 | HARDENED, 0 | HARDENED, 0, 2],
|
2020-07-01 13:43:02 +00:00
|
|
|
]
|
2021-02-11 12:52:45 +00:00
|
|
|
outputs_to_show = [
|
2021-06-30 12:19:06 +00:00
|
|
|
# path is not complete
|
|
|
|
[1852 | HARDENED, 1815 | HARDENED],
|
|
|
|
# path is not complete
|
|
|
|
[1852 | HARDENED, 1815 | HARDENED, 0 | HARDENED],
|
2020-07-01 13:43:02 +00:00
|
|
|
# staking output path
|
2021-06-30 12:19:06 +00:00
|
|
|
[1852 | HARDENED, 1815 | HARDENED, 0 | HARDENED, 2, 0,],
|
2021-02-11 12:52:45 +00:00
|
|
|
# max safe account number exceeded
|
2021-06-30 12:19:06 +00:00
|
|
|
[1852 | HARDENED, 1815 | HARDENED, 101 | HARDENED, 0, 0],
|
|
|
|
# output address too large
|
|
|
|
[1852 | HARDENED, 1815 | HARDENED, 0 | HARDENED, 0, 1000001],
|
2020-07-01 13:43:02 +00:00
|
|
|
]
|
|
|
|
|
2021-06-30 12:19:06 +00:00
|
|
|
for output_path in outputs_to_hide:
|
|
|
|
self.assertTrue(_should_hide_output(output_path))
|
2020-07-01 13:43:02 +00:00
|
|
|
|
2021-06-30 12:19:06 +00:00
|
|
|
for output_path in outputs_to_show:
|
|
|
|
self.assertFalse(_should_hide_output(output_path))
|
2020-07-01 13:43:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|