# Path: keepkeylib/client.py
# class CallException(Exception):
#     def __init__(self, code, message):
#         super(CallException, self).__init__()
#         self.args = [code, message]
# 
# Path: keepkeylib/tools.py
# def int_to_big_endian(value):
#     import struct
# 
#     res = b''
#     while 0 < value:
#         res = struct.pack("B", value & 0xff) + res
#         value = value >> 8
# 
#     return res


import unittest
import common
import binascii
import struct
import keepkeylib.messages_pb2 as proto
import keepkeylib.types_pb2 as proto_types
import keepkeylib.exchange_pb2 as proto_exchange
from keepkeylib.client import CallException
from keepkeylib.tools import int_to_big_endian
                chain_id=1,
                )
        except CallException as e:
            self.assertEndsWith(e.args[1], 'Failed to compile output')
        else:
            self.assert_(False, "Failed to detect error condition")

        #reset policy ("ShapeShift")
        self.client.apply_policy('ShapeShift', 0)

    def test_ethereum_xfer_account_path_error_1(self):
        self.setup_mnemonic_nopin_nopassphrase()
        self.client.apply_policy('ShapeShift', 1)

        # Really we should warn instead in this case, and show:
        #     "Transfer 0.001234 ETH to m/44'/60'/1'/0/0/"
        # on the device, rathern than erroring out.

        try:
            signature_der = self.client.ethereum_sign_tx(
                n=[0, 0],
                nonce=0,
                gas_price=20,
                gas_limit=20,
                to_n=[0x8000002c, 0x8000003c, 1, 0, 0],
                                 #error here -^-
                value=1234000000000000,
                address_type=proto_types.TRANSFER,
                chain_id=1,
                )

# Path: keepkeylib/client.py
# class CallException(Exception):
#     def __init__(self, code, message):
#         super(CallException, self).__init__()
#         self.args = [code, message]
# 
# Path: keepkeylib/tools.py
# def int_to_big_endian(value):
#     import struct
# 
#     res = b''
#     while 0 < value:
#         res = struct.pack("B", value & 0xff) + res
#         value = value >> 8
# 
#     return res


# Path: tests/test_msg_ethereum_signtx_xfer.py
import unittest
import common
import binascii
import struct
import keepkeylib.messages_pb2 as proto
import keepkeylib.types_pb2 as proto_types
import keepkeylib.exchange_pb2 as proto_exchange
from keepkeylib.client import CallException
from keepkeylib.tools import int_to_big_endian

                chain_id=1,
                )
        except CallException as e:
            self.assertEndsWith(e.args[1], 'Failed to compile output')
        else:
            self.assert_(False, "Failed to detect error condition")

        #reset policy ("ShapeShift")
        self.client.apply_policy('ShapeShift', 0)

    def test_ethereum_xfer_account_path_error_1(self):
        self.setup_mnemonic_nopin_nopassphrase()
        self.client.apply_policy('ShapeShift', 1)

        # Really we should warn instead in this case, and show:
        #     "Transfer 0.001234 ETH to m/44'/60'/1'/0/0/"
        # on the device, rathern than erroring out.

        try:
            signature_der = self.client.ethereum_sign_tx(
                n=[0, 0],
                nonce=0,
                gas_price=20,
                gas_limit=20,
                to_n=[0x8000002c, 0x8000003c, 1, 0, 0],
                                 #error here -^-
                value=1234000000000000,
                address_type=proto_types.TRANSFER,
                chain_id=1,
                )

        except CallException as e: