2018-06-21 14:28:34 +00:00
|
|
|
# This file is part of the Trezor project.
|
2018-04-03 11:43:03 +00:00
|
|
|
#
|
2019-05-29 16:44:09 +00:00
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
2018-04-03 11:43:03 +00:00
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
2018-06-21 14:28:34 +00:00
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
2018-04-03 11:43:03 +00:00
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
2018-06-21 14:28:34 +00:00
|
|
|
# You should have received a copy of the License along with this library.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
2018-04-03 11:43:03 +00:00
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
import pytest
|
2018-04-03 11:43:03 +00:00
|
|
|
|
|
|
|
from trezorlib import nem
|
2018-04-18 13:53:40 +00:00
|
|
|
from trezorlib.tools import parse_path
|
2018-04-03 11:43:03 +00:00
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
from .common import TrezorTest
|
|
|
|
|
2018-04-03 11:43:03 +00:00
|
|
|
|
|
|
|
# assertion data from T1
|
device_tests: allow custom runxfail
We can now selectively runxfail certain tests. This is useful for
accepting PRs into trezor-core:
1. trezor-core is going to get a pytest.ini that sets xfail_strict.
That means that if an `xfail`ed test actually passes, that will
break the test suite. So it will be visible when we implement
a feature for which tests exist.
2. To allow PRs to pass the test suite without touching python-trezor
directly, we add a new pytest.ini option: run_xfail.
This adds a list of markers which will ignore `xfail`.
So:
2.1 First, the python-trezor PR marks the tests with the name
of the feature. This commit already does that: Lisk tests
are marked `@pytest.mark.lisk`, NEMs are `@pytest.mark.nem`,
etc.
The tests will be also marked with `xfail`, because the
feature is not in core yet.
2.2 Then, the trezor-core PR implements the feature, which makes
the `xfail`ed tests pass. That breaks the test suite.
2.3 To fix the test suite, the core PR also adds a `run_xfail`
to `pytest.ini`: `run_xfail = lisk`.
(it can take a list: `run_xfail = lisk nem stellar`)
That will make the test suite behave as if the tests are not
`xfail`ed. If the feature is implemented correctly, the tests
will pass.
2.4 When the PR is accepted to core, the next step should be
a PR to python-trezor that removes the `xfail`s. After that,
we should also remove the `run_xfail` option, just to be tidy.
2018-05-21 15:44:02 +00:00
|
|
|
@pytest.mark.nem
|
2018-04-03 11:43:03 +00:00
|
|
|
class TestMsgNEMSignTxOther(TrezorTest):
|
|
|
|
def test_nem_signtx_importance_transfer(self):
|
|
|
|
self.setup_mnemonic_nopin_nopassphrase()
|
|
|
|
|
|
|
|
with self.client:
|
2018-08-13 16:21:24 +00:00
|
|
|
tx = nem.sign_tx(
|
|
|
|
self.client,
|
|
|
|
parse_path("m/44'/1'/0'/0'/0'"),
|
|
|
|
{
|
|
|
|
"timeStamp": 12349215,
|
|
|
|
"fee": 9900,
|
|
|
|
"type": nem.TYPE_IMPORTANCE_TRANSFER,
|
|
|
|
"deadline": 99,
|
|
|
|
"message": {},
|
|
|
|
"importanceTransfer": {
|
|
|
|
"mode": 1, # activate
|
|
|
|
"publicKey": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
|
|
|
|
},
|
|
|
|
"version": (0x98 << 24),
|
2018-04-03 11:43:03 +00:00
|
|
|
},
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|
2018-04-03 11:43:03 +00:00
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
2018-09-12 18:34:26 +00:00
|
|
|
tx.data.hex()
|
|
|
|
== "01080000010000981f6fbc0020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b4062084ac26000000000000630000000100000020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844"
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|
|
|
|
assert (
|
2018-09-12 18:34:26 +00:00
|
|
|
tx.signature.hex()
|
|
|
|
== "b6d9434ec5df80e65e6e45d7f0f3c579b4adfe8567c42d981b06e8ac368b1aad2b24eebecd5efd41f4497051fca8ea8a5e77636a79afc46ee1a8e0fe9e3ba90b"
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|
2018-04-03 11:43:03 +00:00
|
|
|
|
|
|
|
def test_nem_signtx_provision_namespace(self):
|
|
|
|
|
|
|
|
self.setup_mnemonic_nopin_nopassphrase()
|
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
tx = nem.sign_tx(
|
|
|
|
self.client,
|
|
|
|
parse_path("m/44'/1'/0'/0'/0'"),
|
|
|
|
{
|
|
|
|
"timeStamp": 74649215,
|
|
|
|
"fee": 2000000,
|
|
|
|
"type": nem.TYPE_PROVISION_NAMESPACE,
|
|
|
|
"deadline": 74735615,
|
|
|
|
"message": {},
|
|
|
|
"newPart": "ABCDE",
|
|
|
|
"rentalFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
|
|
|
|
"rentalFee": 1500,
|
|
|
|
"parent": None,
|
|
|
|
"version": (0x98 << 24),
|
2018-04-05 14:02:25 +00:00
|
|
|
},
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|
2018-04-03 11:43:03 +00:00
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
assert (
|
2018-09-12 18:34:26 +00:00
|
|
|
tx.data.hex()
|
|
|
|
== "01200000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000050000004142434445ffffffff"
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|
|
|
|
assert (
|
2018-09-12 18:34:26 +00:00
|
|
|
tx.signature.hex()
|
|
|
|
== "f047ae7987cd3a60c0d5ad123aba211185cb6266a7469dfb0491a0df6b5cd9c92b2e2b9f396cc2a3146ee185ba02df4f9e7fb238fe479917b3d274d97336640d"
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|