mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-21 15:08:12 +00:00
style(python): extend style checks to more targets
[no changelog]
This commit is contained in:
parent
821d70dd8d
commit
b5c541d8fd
@ -2,7 +2,7 @@ PYTHON=python3
|
||||
SETUP=$(PYTHON) setup.py
|
||||
|
||||
EXCLUDES=.vscode
|
||||
STYLE_TARGETS=src/trezorlib setup.py
|
||||
STYLE_TARGETS=src tests tools helper-scripts setup.py
|
||||
|
||||
all: build
|
||||
|
||||
@ -45,7 +45,7 @@ git-clean:
|
||||
|
||||
style:
|
||||
black $(STYLE_TARGETS)
|
||||
isort --apply --recursive $(STYLE_TARGETS)
|
||||
isort $(STYLE_TARGETS)
|
||||
autoflake -i --remove-all-unused-imports -r $(STYLE_TARGETS)
|
||||
flake8
|
||||
make pyright
|
||||
|
@ -19,7 +19,6 @@ from decimal import Decimal
|
||||
|
||||
from trezorlib import btc
|
||||
|
||||
|
||||
# https://btc1.trezor.io/api/tx-specific/f5e735549daeb480d4348f2574b8967a4f149715edb220a742d8bb654d668348
|
||||
TX_JSON_BIG = """
|
||||
{
|
||||
|
@ -6,9 +6,9 @@ import requests
|
||||
|
||||
from trezorlib import firmware
|
||||
from trezorlib.firmware import (
|
||||
VendorFirmware,
|
||||
LegacyFirmware,
|
||||
LegacyV2Firmware,
|
||||
VendorFirmware,
|
||||
VendorHeader,
|
||||
)
|
||||
|
||||
|
@ -14,19 +14,18 @@
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import pytest
|
||||
|
||||
import typing as t
|
||||
|
||||
from trezorlib.merkle_tree import (
|
||||
MerkleTree,
|
||||
Leaf,
|
||||
Node,
|
||||
leaf_hash,
|
||||
internal_hash,
|
||||
evaluate_proof,
|
||||
)
|
||||
import pytest
|
||||
|
||||
from trezorlib.merkle_tree import (
|
||||
Leaf,
|
||||
MerkleTree,
|
||||
Node,
|
||||
evaluate_proof,
|
||||
internal_hash,
|
||||
leaf_hash,
|
||||
)
|
||||
|
||||
NODE_VECTORS = ( # node, expected_hash
|
||||
( # leaf node
|
||||
|
@ -14,9 +14,9 @@
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import logging
|
||||
from enum import IntEnum
|
||||
from io import BytesIO
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
@ -90,7 +90,7 @@ class DefaultFields(protobuf.MessageType):
|
||||
class RecursiveMessage(protobuf.MessageType):
|
||||
FIELDS = {
|
||||
1: protobuf.Field("uvarint", "uint64"),
|
||||
2: protobuf.Field("recursivefield", "RecursiveMessage", required=False)
|
||||
2: protobuf.Field("recursivefield", "RecursiveMessage", required=False),
|
||||
}
|
||||
|
||||
|
||||
@ -314,11 +314,8 @@ def test_recursive():
|
||||
msg = RecursiveMessage(
|
||||
uvarint=1,
|
||||
recursivefield=RecursiveMessage(
|
||||
uvarint=2,
|
||||
recursivefield=RecursiveMessage(
|
||||
uvarint=3
|
||||
)
|
||||
)
|
||||
uvarint=2, recursivefield=RecursiveMessage(uvarint=3)
|
||||
),
|
||||
)
|
||||
|
||||
buf = dump_message(msg)
|
||||
|
@ -20,10 +20,10 @@ try:
|
||||
from stellar_sdk import (
|
||||
Account,
|
||||
Asset,
|
||||
MuxedAccount,
|
||||
Network,
|
||||
TransactionBuilder,
|
||||
TrustLineEntryFlag,
|
||||
MuxedAccount,
|
||||
)
|
||||
from stellar_sdk.strkey import StrKey
|
||||
except ImportError:
|
||||
|
@ -19,12 +19,30 @@ from trezorlib import tools
|
||||
|
||||
def test_descriptor_checksum():
|
||||
VECTOR = [
|
||||
("pkh([5c9e228d/44'/0'/0']xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7pQhtpjiYZVZARo14qHiay2fvrX996oEP42u8wZy/0/*)", "vzuemqzv"),
|
||||
("pkh([5c9e228d/44'/0'/0']xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7pQhtpjiYZVZARo14qHiay2fvrX996oEP42u8wZy/1/*)", "akecx4j5"),
|
||||
("sh(wpkh([5c9e228d/49'/0'/0']xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx/0/*))", "jkfqtdfw"),
|
||||
("sh(wpkh([5c9e228d/49'/0'/0']xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx/1/*))", "8h8knju3"),
|
||||
("wpkh([5c9e228d/84'/0'/0']xpub6DDUPHpUo4pcy43iJeZjbSVWGav1SMMmuWdMHiGtkK8rhKmfbomtkwW6GKs1GGAKehT6QRocrmda3WWxXawpjmwaUHfFRXuKrXSapdckEYF/0/*)", "l4dc6ccr"),
|
||||
("wpkh([5c9e228d/84'/0'/0']xpub6DDUPHpUo4pcy43iJeZjbSVWGav1SMMmuWdMHiGtkK8rhKmfbomtkwW6GKs1GGAKehT6QRocrmda3WWxXawpjmwaUHfFRXuKrXSapdckEYF/1/*)", "wpge8dgm"),
|
||||
(
|
||||
"pkh([5c9e228d/44'/0'/0']xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7pQhtpjiYZVZARo14qHiay2fvrX996oEP42u8wZy/0/*)",
|
||||
"vzuemqzv",
|
||||
),
|
||||
(
|
||||
"pkh([5c9e228d/44'/0'/0']xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7pQhtpjiYZVZARo14qHiay2fvrX996oEP42u8wZy/1/*)",
|
||||
"akecx4j5",
|
||||
),
|
||||
(
|
||||
"sh(wpkh([5c9e228d/49'/0'/0']xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx/0/*))",
|
||||
"jkfqtdfw",
|
||||
),
|
||||
(
|
||||
"sh(wpkh([5c9e228d/49'/0'/0']xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx/1/*))",
|
||||
"8h8knju3",
|
||||
),
|
||||
(
|
||||
"wpkh([5c9e228d/84'/0'/0']xpub6DDUPHpUo4pcy43iJeZjbSVWGav1SMMmuWdMHiGtkK8rhKmfbomtkwW6GKs1GGAKehT6QRocrmda3WWxXawpjmwaUHfFRXuKrXSapdckEYF/0/*)",
|
||||
"l4dc6ccr",
|
||||
),
|
||||
(
|
||||
"wpkh([5c9e228d/84'/0'/0']xpub6DDUPHpUo4pcy43iJeZjbSVWGav1SMMmuWdMHiGtkK8rhKmfbomtkwW6GKs1GGAKehT6QRocrmda3WWxXawpjmwaUHfFRXuKrXSapdckEYF/1/*)",
|
||||
"wpge8dgm",
|
||||
),
|
||||
]
|
||||
for d, c in VECTOR:
|
||||
assert tools.descriptor_checksum(d) == c
|
||||
|
@ -34,8 +34,8 @@ def test_disabled_transport():
|
||||
def test_import_all_transports():
|
||||
from trezorlib.transport.bridge import BridgeTransport
|
||||
from trezorlib.transport.hid import HidTransport
|
||||
from trezorlib.transport.webusb import WebUsbTransport
|
||||
from trezorlib.transport.udp import UdpTransport
|
||||
from trezorlib.transport.webusb import WebUsbTransport
|
||||
|
||||
assert BridgeTransport
|
||||
assert HidTransport
|
||||
|
@ -27,21 +27,21 @@ from gevent import monkey
|
||||
monkey.patch_all()
|
||||
|
||||
import json
|
||||
import logging
|
||||
import struct
|
||||
import time
|
||||
import typing as t
|
||||
import logging
|
||||
|
||||
import click
|
||||
from bottle import run, post, request, response
|
||||
from bottle import post, request, response, run
|
||||
|
||||
import trezorlib.transport
|
||||
import trezorlib.mapping
|
||||
import trezorlib.models
|
||||
import trezorlib.transport
|
||||
from trezorlib.client import TrezorClient
|
||||
from trezorlib.ui import TrezorClientUI
|
||||
from trezorlib.protobuf import format_message
|
||||
from trezorlib.transport.bridge import BridgeTransport
|
||||
from trezorlib.ui import TrezorClientUI
|
||||
|
||||
# ignore bridge. we are the bridge
|
||||
BridgeTransport.ENABLED = False
|
||||
|
@ -22,6 +22,7 @@ import re
|
||||
import sys
|
||||
|
||||
import pyotp
|
||||
|
||||
from trezorlib.client import TrezorClient
|
||||
from trezorlib.misc import decrypt_keyvalue, encrypt_keyvalue
|
||||
from trezorlib.tools import parse_path
|
||||
|
Loading…
Reference in New Issue
Block a user