1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 06:48:16 +00:00

device_tests: fix T1 test differences in wording

This commit is contained in:
matejcik 2018-05-23 16:40:17 +02:00
parent 7e83eb11e5
commit f8f0be9c86
5 changed files with 25 additions and 10 deletions

View File

@ -20,6 +20,7 @@ from binascii import hexlify, unhexlify
import pytest import pytest
from .common import TrezorTest from .common import TrezorTest
from .conftest import TREZOR_VERSION
from trezorlib import coins from trezorlib import coins
from trezorlib import messages as proto from trezorlib import messages as proto
@ -625,8 +626,8 @@ class TestMsgSigntx(TrezorTest):
# Now run the attack, must trigger the exception # Now run the attack, must trigger the exception
with pytest.raises(CallException) as exc: with pytest.raises(CallException) as exc:
self.client.sign_tx('Bitcoin', [inp1, inp2], [out1, out2], debug_processor=attack_processor) self.client.sign_tx('Bitcoin', [inp1, inp2], [out1, out2], debug_processor=attack_processor)
assert exc.value.args[0] == proto.FailureType.ProcessError assert exc.value.args[0] in (proto.FailureType.ProcessError, proto.FailureType.DataError)
assert exc.value.args[1] == 'Transaction has changed during signing' assert exc.value.args[1].endswith('Transaction has changed during signing')
def test_attack_change_input_address(self): def test_attack_change_input_address(self):
# This unit test attempts to modify input address after the Trezor checked # This unit test attempts to modify input address after the Trezor checked
@ -700,8 +701,12 @@ class TestMsgSigntx(TrezorTest):
# Now run the attack, must trigger the exception # Now run the attack, must trigger the exception
with pytest.raises(CallException) as exc: with pytest.raises(CallException) as exc:
self.client.sign_tx('Testnet', [inp1], [out1, out2], debug_processor=attack_processor) self.client.sign_tx('Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
assert exc.value.args[0] == proto.FailureType.ProcessError assert exc.value.args[0] == proto.FailureType.ProcessError
assert exc.value.args[1] == 'Transaction has changed during signing' if TREZOR_VERSION == 1:
assert exc.value.args[1].endswith('Failed to compile input')
else:
assert exc.value.args[1].endswith('Transaction has changed during signing')
def test_spend_coinbase(self): def test_spend_coinbase(self):
# 25 TEST generated to m/1 (mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV) # 25 TEST generated to m/1 (mfiGQVPcRcaEvQPYDErR34DcCovtxYvUUV)

View File

@ -219,13 +219,14 @@ class TestMsgSigntxBch(TrezorTest):
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx), proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)), proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)), proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=1)),
proto.Failure(code=proto.FailureType.ProcessError), proto.Failure(),
]) ])
with pytest.raises(CallException) as exc: with pytest.raises(CallException) as exc:
self.client.sign_tx('Bcash', [inp1, inp2], [out1], debug_processor=attack_processor) self.client.sign_tx('Bcash', [inp1, inp2], [out1], debug_processor=attack_processor)
assert exc.value.args[0] == proto.FailureType.ProcessError
assert exc.value.args[1] == 'Transaction has changed during signing' assert exc.value.args[0] == proto.FailureType.DataError
assert exc.value.args[1].endswith('Transaction has changed during signing')
def test_attack_change_input(self): def test_attack_change_input(self):
self.setup_mnemonic_allallall() self.setup_mnemonic_allallall()

View File

@ -18,6 +18,7 @@
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
import pytest import pytest
from .conftest import TREZOR_VERSION
from .common import TrezorTest from .common import TrezorTest
from trezorlib import coins from trezorlib import coins
from trezorlib import messages as proto from trezorlib import messages as proto
@ -240,4 +241,7 @@ class TestMsgSigntxSegwit(TrezorTest):
with pytest.raises(CallException) as exc: with pytest.raises(CallException) as exc:
self.client.sign_tx('Testnet', [inp1], [out1, out2], debug_processor=attack_processor) self.client.sign_tx('Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
assert exc.value.args[0] == proto.FailureType.ProcessError assert exc.value.args[0] == proto.FailureType.ProcessError
assert exc.value.args[1] == 'Transaction has changed during signing' if TREZOR_VERSION == 1:
assert exc.value.args[1].endswith("Failed to compile input")
else:
assert exc.value.args[1].endswith('Transaction has changed during signing')

View File

@ -254,4 +254,4 @@ class TestMultisig(TrezorTest):
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ]) self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
assert exc.value.args[0] == proto.FailureType.DataError assert exc.value.args[0] == proto.FailureType.DataError
assert 'Pubkey not found in multisig script' in exc.value.args[1] assert exc.value.args[1].endswith('Pubkey not found in multisig script')

View File

@ -19,6 +19,7 @@ from binascii import unhexlify, hexlify
import pytest import pytest
from .common import TrezorTest from .common import TrezorTest
from .conftest import TREZOR_VERSION
from trezorlib import messages as proto from trezorlib import messages as proto
from trezorlib.client import CallException from trezorlib.client import CallException
@ -110,5 +111,9 @@ class TestOpReturn(TrezorTest):
with pytest.raises(CallException) as exc: with pytest.raises(CallException) as exc:
self.client.sign_tx('Bitcoin', [inp1], [out1]) self.client.sign_tx('Bitcoin', [inp1], [out1])
if TREZOR_VERSION == 1:
assert exc.value.args[0] == proto.FailureType.ProcessError
assert exc.value.args[1].endswith("Failed to compile output")
else:
assert exc.value.args[0] == proto.FailureType.DataError assert exc.value.args[0] == proto.FailureType.DataError
assert exc.value.args[1] == 'OP_RETURN output with non-zero amount' assert exc.value.args[1].endswith('OP_RETURN output with non-zero amount')