コード例 #1
0
    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
コード例 #2
0
    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
コード例 #3
0
    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
コード例 #4
0
def test_varint_encode_correct(num, expected):
    assert varint_encode(num) == expected