def test_get_public_key(self, client):
     with client:
         client.use_pin_sequence([PIN4])
         client.set_expected_responses(
             [proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.PublicKey()]
         )
         btc.get_public_node(client, [])
예제 #2
0
def test_clear_session(client):
    is_trezor1 = client.features.model == "1"
    init_responses = [
        messages.PinMatrixRequest()
        if is_trezor1 else messages.ButtonRequest(),
        messages.PassphraseRequest(),
    ]

    cached_responses = [messages.PublicKey()]

    with client:
        client.use_pin_sequence([PIN4])
        client.set_expected_responses(init_responses + cached_responses)
        assert get_public_node(client, ADDRESS_N).xpub == XPUB

    with client:
        # pin and passphrase are cached
        client.set_expected_responses(cached_responses)
        assert get_public_node(client, ADDRESS_N).xpub == XPUB

    client.clear_session()

    # session cache is cleared
    with client:
        client.use_pin_sequence([PIN4])
        client.set_expected_responses(init_responses + cached_responses)
        assert get_public_node(client, ADDRESS_N).xpub == XPUB

    with client:
        # pin and passphrase are cached
        client.set_expected_responses(cached_responses)
        assert get_public_node(client, ADDRESS_N).xpub == XPUB
def test_clear_session(client):
    if client.features.model == "1":
        init_responses = [
            messages.PinMatrixRequest(),
            messages.PassphraseRequest()
        ]
    else:
        init_responses = [messages.PassphraseRequest()]

    cached_responses = [messages.PublicKey()]

    with client:
        client.set_expected_responses(init_responses + cached_responses)
        assert get_public_node(client, ADDRESS_N).xpub == XPUB

    with client:
        # pin and passphrase are cached
        client.set_expected_responses(cached_responses)
        assert get_public_node(client, ADDRESS_N).xpub == XPUB

    client.clear_session()

    # session cache is cleared
    with client:
        client.set_expected_responses(init_responses + cached_responses)
        assert get_public_node(client, ADDRESS_N).xpub == XPUB

    with client:
        # pin and passphrase are cached
        client.set_expected_responses(cached_responses)
        assert get_public_node(client, ADDRESS_N).xpub == XPUB
예제 #4
0
def _get_xpub(client, passphrase=None):
    """Get XPUB and check that the appropriate passphrase flow has happened."""
    if passphrase is not None:
        expected_responses = [
            messages.PassphraseRequest(),
            messages.ButtonRequest(),
            messages.ButtonRequest(),
            messages.PublicKey(),
        ]
    else:
        expected_responses = [messages.PublicKey()]

    with client:
        client.use_passphrase(passphrase or "")
        client.set_expected_responses(expected_responses)
        result = client.call(XPUB_REQUEST)
        return result.xpub
예제 #5
0
 def test_get_public_key(self):
     with self.client:
         self.setup_mnemonic_pin_passphrase()
         self.client.set_expected_responses([
             proto.PinMatrixRequest(),
             proto.PassphraseRequest(),
             proto.PublicKey()
         ])
         self.client.get_public_node([])