1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-09 15:00:58 +00:00

tests: deepcopy is required when debug_processor is invoked

This commit is contained in:
Tomas Susanka 2018-02-23 16:03:43 +01:00
parent cbd3751bdb
commit 617ccc21d9
2 changed files with 10 additions and 3 deletions

View File

@ -937,9 +937,13 @@ class ProtocolMixin(object):
msg = proto.TransactionType() msg = proto.TransactionType()
msg._extend_inputs([current_tx.inputs[res.details.request_index], ]) msg._extend_inputs([current_tx.inputs[res.details.request_index], ])
if debug_processor is not None: if debug_processor is not None:
# msg needs to be deep copied so when it's modified
# the other messages stay intact
from copy import deepcopy
msg = deepcopy(msg)
# If debug_processor function is provided, # If debug_processor function is provided,
# pass thru it the request and prepared response. # pass thru it the request and prepared response.
# This is useful for unit tests, see test_msg_signtx # This is useful for tests, see test_msg_signtx
msg = debug_processor(res, msg) msg = debug_processor(res, msg)
res = self.call(proto.TxAck(tx=msg)) res = self.call(proto.TxAck(tx=msg))
@ -953,9 +957,13 @@ class ProtocolMixin(object):
msg._extend_outputs([current_tx.outputs[res.details.request_index], ]) msg._extend_outputs([current_tx.outputs[res.details.request_index], ])
if debug_processor is not None: if debug_processor is not None:
# msg needs to be deep copied so when it's modified
# the other messages stay intact
from copy import deepcopy
msg = deepcopy(msg)
# If debug_processor function is provided, # If debug_processor function is provided,
# pass thru it the request and prepared response. # pass thru it the request and prepared response.
# This is useful for unit tests, see test_msg_signtx # This is useful for tests, see test_msg_signtx
msg = debug_processor(res, msg) msg = debug_processor(res, msg)
res = self.call(proto.TxAck(tx=msg)) res = self.call(proto.TxAck(tx=msg))

View File

@ -652,7 +652,6 @@ class TestMsgSigntx(TrezorTest):
run_attack = True run_attack = True
def attack_processor(req, msg): def attack_processor(req, msg):
import sys
global run_attack global run_attack
if req.details.tx_hash is not None: if req.details.tx_hash is not None: