def test_public_key_message_amino(self, wallet): pkm = PubKeyMsg(wallet) type_bytes = binascii.unhexlify(PubKeyMsg.AMINO_MESSAGE_TYPE) len_bytes = varint_encode(len(wallet.public_key)) assert pkm.to_amino() == type_bytes + len_bytes + wallet.public_key
def to_amino(self): proto = self.to_protobuf() if type(proto) != bytes: proto = proto.SerializeToString() # wrap with type type_bytes = b"" if self.AMINO_MESSAGE_TYPE: type_bytes = binascii.unhexlify(self.AMINO_MESSAGE_TYPE) varint_length = varint_encode(len(proto) + len(type_bytes)) else: varint_length = varint_encode(len(proto)) msg = b"" if self.INCLUDE_AMINO_LENGTH_PREFIX: msg += varint_length msg += type_bytes + proto return msg
def to_amino(self): proto = self.to_protobuf() type_bytes = binascii.unhexlify(self.AMINO_MESSAGE_TYPE) varint_length = varint_encode(len(proto)) msg = type_bytes + varint_length + proto return msg
def test_varint_encode_correct(num, expected): assert varint_encode(num) == expected