1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

tests/device: assert exception type and message

This commit is contained in:
Tomas Susanka 2018-02-27 15:08:00 +01:00
parent 03b3ef10f4
commit aec8f04f68
3 changed files with 21 additions and 13 deletions

View File

@ -233,5 +233,10 @@ class TestMsgSigntxSegwit(TrezorTest):
proto.TxRequest(request_type=proto.RequestType.TXINPUT, details=proto.TxRequestDetailsType(request_index=0)),
proto.Failure(code=proto.FailureType.ProcessError),
])
with pytest.raises(CallException):
try:
self.client.sign_tx('Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
except CallException as exc:
assert exc.args[0] == proto.FailureType.ProcessError
assert exc.args[1] == 'Transaction has changed during signing'
else:
assert False # exception expected

View File

@ -249,7 +249,10 @@ class TestMultisig(TrezorTest):
script_type=proto.OutputScriptType.PAYTOADDRESS
)
with self.client:
# It should throw Failure 'Pubkey not found in multisig script'
with pytest.raises(CallException):
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
try:
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
except CallException as exc:
assert exc.args[0] == proto.FailureType.DataError
assert exc.args[1] == 'Pubkey not found in multisig script'
else:
assert False # exception expected

View File

@ -88,12 +88,6 @@ class TestOpReturn(TrezorTest):
prev_index=0,
)
out1 = proto.TxOutputType(
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
amount=390000 - 10000 - 10000,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
out1 = proto.TxOutputType(
op_return_data=b'test of the op_return data',
amount=10000,
@ -110,5 +104,11 @@ class TestOpReturn(TrezorTest):
proto.TxRequest(request_type=proto.RequestType.TXOUTPUT, details=proto.TxRequestDetailsType(request_index=0)),
proto.Failure()
])
with pytest.raises(CallException):
self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
try:
self.client.sign_tx('Bitcoin', [inp1], [out1])
except CallException as exc:
assert exc.args[0] == proto.FailureType.DataError
assert exc.args[1] == 'OP_RETURN output with non-zero amount'
else:
assert False # exception expected