Example #1
0
 def test_message_inconsistency(self):
     """Test for an error in consistency of a message."""
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.SIGN_TRANSACTION,
         skill_callback_ids=self.skill_callback_ids,
         terms=self.terms,
     )
     assert not tx_msg._is_consistent()
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.SIGN_MESSAGE,
         skill_callback_ids=self.skill_callback_ids,
         terms=self.terms,
     )
     assert not tx_msg._is_consistent()
Example #2
0
 def test_message_consistency(self):
     """Test for an error in consistency of a message."""
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.SIGN_TRANSACTION,
         skill_callback_ids=self.skill_callback_ids,
         skill_callback_info=self.skill_callback_info,
         terms=self.terms,
         raw_transaction=RawTransaction(self.ledger_id, "transaction"),
     )
     assert tx_msg._is_consistent()
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.SIGN_MESSAGE,
         skill_callback_ids=self.skill_callback_ids,
         skill_callback_info=self.skill_callback_info,
         terms=self.terms,
         raw_message=RawMessage(self.ledger_id, "message"),
     )
     assert tx_msg._is_consistent()
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.SIGNED_TRANSACTION,
         message_id=2,
         target=1,
         skill_callback_ids=self.skill_callback_ids,
         skill_callback_info=self.skill_callback_info,
         signed_transaction=SignedTransaction(self.ledger_id, "signature"),
     )
     assert tx_msg._is_consistent()
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.SIGNED_MESSAGE,
         message_id=2,
         target=1,
         skill_callback_ids=self.skill_callback_ids,
         skill_callback_info=self.skill_callback_info,
         signed_message=SignedMessage(self.ledger_id, "message"),
     )
     assert tx_msg._is_consistent()
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.ERROR,
         message_id=2,
         target=1,
         skill_callback_ids=self.skill_callback_ids,
         skill_callback_info=self.skill_callback_info,
         error_code=SigningMessage.ErrorCode.UNSUCCESSFUL_MESSAGE_SIGNING,
     )
     assert tx_msg._is_consistent()
     assert str(tx_msg.performative) == "error"
     assert len(tx_msg.valid_performatives) == 5
Example #3
0
 def test_sign_message(self):
     """Test for an error for a sign transaction message."""
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.SIGN_MESSAGE,
         skill_callback_ids=self.skill_callback_ids,
         skill_callback_info=self.skill_callback_info,
         terms=self.terms,
         raw_message=RawMessage(self.ledger_id, "message"),
     )
     assert tx_msg._is_consistent()
     encoded_tx_msg = tx_msg.encode()
     decoded_tx_msg = tx_msg.serializer.decode(encoded_tx_msg)
     assert tx_msg == decoded_tx_msg
Example #4
0
 def test_signed_message(self):
     """Test for an error for a signed message."""
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.SIGNED_MESSAGE,
         message_id=2,
         target=1,
         skill_callback_ids=self.skill_callback_ids,
         skill_callback_info=self.skill_callback_info,
         signed_message=SignedMessage(self.ledger_id, "message"),
     )
     assert tx_msg._is_consistent()
     encoded_tx_msg = tx_msg.encode()
     decoded_tx_msg = tx_msg.serializer.decode(encoded_tx_msg)
     assert tx_msg == decoded_tx_msg
Example #5
0
 def test_signed_transaction(self):
     """Test for an error for a signed transaction."""
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.SIGNED_TRANSACTION,
         message_id=2,
         target=1,
         skill_callback_ids=self.skill_callback_ids,
         skill_callback_info=self.skill_callback_info,
         signed_transaction=SignedTransaction(self.ledger_id, "signature"),
     )
     assert tx_msg._is_consistent()
     encoded_tx_msg = tx_msg.encode()
     decoded_tx_msg = tx_msg.serializer.decode(encoded_tx_msg)
     assert tx_msg == decoded_tx_msg
Example #6
0
 def test_error_message(self):
     """Test for an error for an error message."""
     tx_msg = SigningMessage(
         performative=SigningMessage.Performative.ERROR,
         message_id=2,
         target=1,
         skill_callback_ids=self.skill_callback_ids,
         skill_callback_info=self.skill_callback_info,
         error_code=SigningMessage.ErrorCode.UNSUCCESSFUL_MESSAGE_SIGNING,
     )
     assert tx_msg._is_consistent()
     encoded_tx_msg = tx_msg.encode()
     decoded_tx_msg = tx_msg.serializer.decode(encoded_tx_msg)
     assert tx_msg == decoded_tx_msg
     assert str(tx_msg.performative) == "error"
     assert len(tx_msg.valid_performatives) == 5
Example #7
0
def test_consistency_check_negative():
    """Test the consistency check, negative case."""
    tx_msg = SigningMessage(
        performative=SigningMessage.Performative.SIGN_TRANSACTION, )
    assert not tx_msg._is_consistent()