You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment Message class generated does not have a good programmatic definition of performatives and fields relation
This relation check is done in code as
Check correct contents
actual_nb_of_contents = len(self._body) - DEFAULT_BODY_SIZE
expected_nb_of_contents = 0
if self.performative == SigningMessage.Performative.SIGN_TRANSACTION:
expected_nb_of_contents = 2
enforce(
isinstance(self.terms, CustomTerms),
"Invalid type for content 'terms'. Expected 'Terms'. Found '{}'.".format(
type(self.terms)
),
)
enforce(
isinstance(self.raw_transaction, CustomRawTransaction),
"Invalid type for content 'raw_transaction'. Expected 'RawTransaction'. Found '{}'.".format(
type(self.raw_transaction)
),
)
elif self.performative == SigningMessage.Performative.SIGN_MESSAGE:
expected_nb_of_contents = 2
enforce(
isinstance(self.terms, CustomTerms),
"Invalid type for content 'terms'. Expected 'Terms'. Found '{}'.".format(
type(self.terms)
),
)
enforce(
isinstance(self.raw_message, CustomRawMessage),
"Invalid type for content 'raw_message'. Expected 'RawMessage'. Found '{}'.".format(
type(self.raw_message)
),
)
but can be replaced with something like
class SomeMessage:
PERFORMATIVES_FIELDS = {Performative1: (("field1", Field1Type), ("str_field", str))}
and all the checks can be done using this definition.
it will give more flexibility, like check on message creation with list of missing fields in error
introspection features, like code can check how to construct message or provide list of expected fields.
also can help to build automated tests of message encoding/decoding
The text was updated successfully, but these errors were encountered:
At the moment Message class generated does not have a good programmatic definition of performatives and fields relation
This relation check is done in code as
but can be replaced with something like
and all the checks can be done using this definition.
it will give more flexibility, like check on message creation with list of missing fields in error
introspection features, like code can check how to construct message or provide list of expected fields.
also can help to build automated tests of message encoding/decoding
The text was updated successfully, but these errors were encountered: