From 617ccc21d9306dc1dfafdb580905ad209954ffa0 Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Fri, 23 Feb 2018 16:03:43 +0100 Subject: [PATCH] tests: deepcopy is required when debug_processor is invoked --- trezorlib/client.py | 12 ++++++++++-- trezorlib/tests/device_tests/test_msg_signtx.py | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/trezorlib/client.py b/trezorlib/client.py index 0743a38..1b7d6ae 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -937,9 +937,13 @@ class ProtocolMixin(object): msg = proto.TransactionType() msg._extend_inputs([current_tx.inputs[res.details.request_index], ]) 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, # 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) res = self.call(proto.TxAck(tx=msg)) @@ -953,9 +957,13 @@ class ProtocolMixin(object): msg._extend_outputs([current_tx.outputs[res.details.request_index], ]) 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, # 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) res = self.call(proto.TxAck(tx=msg)) diff --git a/trezorlib/tests/device_tests/test_msg_signtx.py b/trezorlib/tests/device_tests/test_msg_signtx.py index 56f7c7f..2319148 100644 --- a/trezorlib/tests/device_tests/test_msg_signtx.py +++ b/trezorlib/tests/device_tests/test_msg_signtx.py @@ -652,7 +652,6 @@ class TestMsgSigntx(TrezorTest): run_attack = True def attack_processor(req, msg): - import sys global run_attack if req.details.tx_hash is not None: