1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

style: uppercase hex constants to conform with black 18.9b0 style

This commit is contained in:
matejcik 2018-10-01 14:01:33 +02:00
parent 3dad046c12
commit 4fb3acb029
17 changed files with 29 additions and 31 deletions

View File

@ -677,7 +677,7 @@ def sign_tx(connect, coin):
sequence = click.prompt(
"Sequence Number to use (RBF opt-in enabled by default)",
type=int,
default=0xfffffffd,
default=0xFFFFFFFD,
)
script_type = click.prompt(
"Input type",

View File

@ -74,7 +74,7 @@ except ImportError:
def getch():
while True:
key = msvcrt.getch()
if key in (0x00, 0xe0):
if key in (0x00, 0xE0):
# skip special keys: read the scancode and repeat
msvcrt.getch()
continue

View File

@ -1,4 +1,3 @@
import construct as c
import pyblake2
@ -6,7 +5,7 @@ from . import cosi, messages as proto, tools
def bytes_not(data):
return bytes(~b & 0xff for b in data)
return bytes(~b & 0xFF for b in data)
# fmt: off

View File

@ -1,4 +1,3 @@
from . import messages as proto
from .protobuf import dict_to_proto
from .tools import CallException, dict_from_camelcase, expect, normalize_nfc

View File

@ -356,7 +356,7 @@ def format_message(
def mostly_printable(bytes):
if not bytes:
return True
printable = sum(1 for byte in bytes if 0x20 <= byte <= 0x7e)
printable = sum(1 for byte in bytes if 0x20 <= byte <= 0x7E)
return printable / len(bytes) > 0.8
def pformat_value(value: Any, indent: int) -> str:

View File

@ -336,7 +336,7 @@ def _crc16_checksum(bytes):
if c15 ^ bit:
crc ^= polynomial
return crc & 0xffff
return crc & 0xFFFF
# ====== Client functions ====== #

View File

@ -70,4 +70,4 @@ class TestBip32Speed(TrezorTest):
print("CACHED TIME", cache_time)
# Cached time expected to be at least 2x faster
assert cache_time <= nocache_time / 2.
assert cache_time <= nocache_time / 2.0

View File

@ -366,8 +366,8 @@ class TestMsgEthereumSigntx(TrezorTest):
self.client,
n=[0, 0],
nonce=123456,
gas_price=0xffffffffffffffffffffffffffffffff,
gas_limit=0xffffffffffffffffffffffffffffff,
gas_price=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
gas_limit=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
to=TO_ADDR,
value=12345678901234567890,
)

View File

@ -33,8 +33,8 @@ class TestMsgOntologySignOntIdAddAttributes(TrezorTest):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7f7f1ceb,
type=0xd1,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",

View File

@ -33,8 +33,8 @@ class TestMsgOntologySignOntIdRegister(TrezorTest):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7f7f1ceb,
type=0xd1,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",

View File

@ -31,8 +31,8 @@ class TestMsgOntologySigntx(TrezorTest):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7f7f1ceb,
type=0xd1,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
@ -63,8 +63,8 @@ class TestMsgOntologySigntx(TrezorTest):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7f7f1ceb,
type=0xd1,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",

View File

@ -31,8 +31,8 @@ class TestMsgOntologySignWithdraw(TrezorTest):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7f7f1ceb,
type=0xd1,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",

View File

@ -68,7 +68,7 @@ class TestMsgStellarSignTransaction(TrezorTest):
self.setup_mnemonic_nopin_nopassphrase()
op = proto.StellarBumpSequenceOp()
op.bump_to = 0x7fffffffffffffff
op.bump_to = 0x7FFFFFFFFFFFFFFF
tx = self._create_msg()
response = stellar.sign_tx(

View File

@ -47,7 +47,7 @@ def dump_uvarint(value):
def test_dump_uvarint():
assert dump_uvarint(0) == b"\x00"
assert dump_uvarint(1) == b"\x01"
assert dump_uvarint(0xff) == b"\xff\x01"
assert dump_uvarint(0xFF) == b"\xff\x01"
assert dump_uvarint(123456) == b"\xc0\xc4\x07"
with pytest.raises(ValueError):
@ -57,7 +57,7 @@ def test_dump_uvarint():
def test_load_uvarint():
assert load_uvarint(b"\x00") == 0
assert load_uvarint(b"\x01") == 1
assert load_uvarint(b"\xff\x01") == 0xff
assert load_uvarint(b"\xff\x01") == 0xFF
assert load_uvarint(b"\xc0\xc4\x07") == 123456

View File

@ -23,9 +23,9 @@ from . import Transport, TransportException
from ..protocol_v1 import ProtocolV1
from ..protocol_v2 import ProtocolV2
DEV_TREZOR1 = (0x534c, 0x0001)
DEV_TREZOR2 = (0x1209, 0x53c1)
DEV_TREZOR2_BL = (0x1209, 0x53c0)
DEV_TREZOR1 = (0x534C, 0x0001)
DEV_TREZOR2 = (0x1209, 0x53C1)
DEV_TREZOR2_BL = (0x1209, 0x53C0)
class HidHandle:

View File

@ -24,9 +24,9 @@ from . import Transport, TransportException
from ..protocol_v1 import ProtocolV1
from ..protocol_v2 import ProtocolV2
DEV_TREZOR1 = (0x534c, 0x0001)
DEV_TREZOR2 = (0x1209, 0x53c1)
DEV_TREZOR2_BL = (0x1209, 0x53c0)
DEV_TREZOR1 = (0x534C, 0x0001)
DEV_TREZOR2 = (0x1209, 0x53C1)
DEV_TREZOR2_BL = (0x1209, 0x53C0)
INTERFACE = 0
ENDPOINT = 1

View File

@ -97,7 +97,7 @@ class TxApiInsight(TxApi):
i = t._add_inputs()
if "coinbase" in vin.keys():
i.prev_hash = b"\0" * 32
i.prev_index = 0xffffffff # signed int -1
i.prev_index = 0xFFFFFFFF # signed int -1
i.script_sig = bytes.fromhex(vin["coinbase"])
i.sequence = vin["sequence"]
@ -111,7 +111,7 @@ class TxApiInsight(TxApi):
o = t._add_bin_outputs()
o.amount = int(Decimal(vout["value"]) * 100000000)
o.script_pubkey = bytes.fromhex(vout["scriptPubKey"]["hex"])
if self.bip115 and o.script_pubkey[-1] == 0xb4:
if self.bip115 and o.script_pubkey[-1] == 0xB4:
# Verify if coin implements replay protection bip115 and script includes checkblockatheight opcode. 0xb4 - is op_code (OP_CHECKBLOCKATHEIGHT)
# <OP_32> <32-byte block hash> <OP_3> <3-byte block height> <OP_CHECKBLOCKATHEIGHT>
tail = o.script_pubkey[-38:]