示例#1
0
class TrezorTest:
    # fmt: off
    #                1      2     3    4      5      6      7     8      9    10    11    12
    mnemonic12 = "alcohol woman abuse must during monitor noble actual mixed trade anger aisle"
    mnemonic18 = "owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel"
    mnemonic24 = "dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk host tomato cradle drill spread actor shine dismiss champion exotic"
    mnemonic_all = " ".join(["all"] * 12)
    # fmt: on

    pin4 = "1234"
    pin6 = "789456"
    pin8 = "45678978"

    def setup_method(self, method):
        wirelink = conftest.get_device()
        self.client = TrezorClientDebugLink(wirelink)
        self.client.set_tx_api(coins.tx_api["Bitcoin"])
        # self.client.set_buttonwait(3)

        device.wipe(self.client)
        self.client.transport.session_begin()

    def teardown_method(self, method):
        self.client.transport.session_end()
        self.client.close()

    def _setup_mnemonic(self, mnemonic=None, pin="", passphrase=False):
        if mnemonic is None:
            mnemonic = TrezorTest.mnemonic12
        debuglink.load_device_by_mnemonic(
            self.client,
            mnemonic=mnemonic,
            pin=pin,
            passphrase_protection=passphrase,
            label="test",
            language="english",
        )
        if conftest.TREZOR_VERSION > 1 and passphrase:
            device.apply_settings(self.client,
                                  passphrase_source=PASSPHRASE_ON_HOST)

    def setup_mnemonic_allallall(self):
        self._setup_mnemonic(mnemonic=TrezorTest.mnemonic_all)

    def setup_mnemonic_nopin_nopassphrase(self):
        self._setup_mnemonic()

    def setup_mnemonic_nopin_passphrase(self):
        self._setup_mnemonic(passphrase=True)

    def setup_mnemonic_pin_nopassphrase(self):
        self._setup_mnemonic(pin=TrezorTest.pin4)

    def setup_mnemonic_pin_passphrase(self):
        self._setup_mnemonic(pin=TrezorTest.pin4, passphrase=True)
示例#2
0
def client():
    wirelink = get_device()
    client = TrezorClientDebugLink(wirelink)
    client.set_tx_api(coins.tx_api["Bitcoin"])
    wipe_device(client)
    client.transport.session_begin()

    yield client

    client.transport.session_end()

    # XXX debuglink session must also be closed
    # client.close accomplishes that for now; going forward, there should
    # also be proper session handling for debuglink
    client.close()