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

chore(common): Add sanity checks for protobuf definitions.

This commit is contained in:
Andrew Kozlik 2020-10-14 15:54:58 +02:00 committed by Andrew Kozlik
parent 9e5d5bd5f9
commit f71af43874

View File

@ -306,10 +306,20 @@ class Descriptor:
comment = "" comment = ""
if field.repeated: if field.repeated:
if field.default_value is not None:
raise ValueError("Repeated fields can't have default values.")
if field.experimental:
raise ValueError("Repeated experimental fields are currently not supported.")
flags = "p.FLAG_REPEATED" flags = "p.FLAG_REPEATED"
elif field.required: elif field.required:
if field.default_value is not None:
raise ValueError("Required fields can't have default values.")
if field.experimental:
raise ValueError("Required fields can't be experimental.")
flags = "p.FLAG_REQUIRED" flags = "p.FLAG_REQUIRED"
elif field.experimental: elif field.experimental:
if field.default_value is not None:
raise ValueError("Experimental fields can't have default values.")
flags = "p.FLAG_EXPERIMENTAL" flags = "p.FLAG_EXPERIMENTAL"
else: else:
flags = field.default_value flags = field.default_value