def test_from_xdr_obj(self):
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"
     send_asset = Asset(
         "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"
     )
     dest_asset = Asset(
         "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"
     )
     send_amount = "3.1415000"
     dest_min = "3.0070000"
     path = [
         Asset("USD", "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB"),
         Asset("EUR", "GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL"),
     ]
     origin_xdr_obj = PathPaymentStrictSend(
         destination, send_asset, send_amount, dest_asset, dest_min, path, source
     ).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, PathPaymentStrictSend)
     assert op.source == source
     assert op.destination == destination
     assert op.send_asset == send_asset
     assert op.dest_asset == dest_asset
     assert op.send_amount == "3.1415"
     assert op.dest_min == "3.007"
     assert op.path == path
 def test_from_xdr_obj_muxed_account(self):
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     destination = (
         "MAAAAAAAAAAAJURAAB2X52XFQP6FBXLGT6LWOOWMEXWHEWBDVRZ7V5WH34Y22MPFBHUHY"
     )
     send_asset = Asset(
         "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"
     )
     dest_asset = Asset(
         "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"
     )
     send_amount = "3.1415000"
     dest_min = "3.0070000"
     path = [
         Asset("USD", "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB"),
         Asset("EUR", "GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL"),
     ]
     origin_xdr_obj = PathPaymentStrictSend(
         destination, send_asset, send_amount, dest_asset, dest_min, path, source
     ).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, PathPaymentStrictSend)
     assert op.source == source
     assert op.destination == destination
     assert op.send_asset == send_asset
     assert op.dest_asset == dest_asset
     assert op.send_amount == "3.1415"
     assert op.dest_min == "3.007"
     assert op.path == path
 def test_from_xdr_obj(self):
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"
     origin_xdr_obj = AccountMerge(destination, source).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, AccountMerge)
     assert op.source == source
     assert op.destination == destination
 def test_from_xdr_obj(self):
     bump_to = 123123123
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     origin_xdr_obj = BumpSequence(bump_to, source).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, BumpSequence)
     assert op.source == source
     assert op.bump_to == bump_to
 def test_from_xdr_obj(self):
     asset = Asset("USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7")
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     limit = "123456.789"
     origin_xdr_obj = ChangeTrust(asset, limit, source).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, ChangeTrust)
     assert op.source == source
     assert op.limit == limit
     assert op.asset == asset
    def test_get_source_no_exist_from_xdr_obj(self):  # BAD TEST
        destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"
        starting_balance = "1000.00"
        origin_op = CreateAccount(destination, starting_balance)
        origin_xdr_obj = origin_op.to_xdr_object()

        op = Operation.from_xdr_object(origin_xdr_obj)
        assert op.source == None
        assert op.starting_balance == "1000"
        assert op.destination == destination
 def test_from_xdr_obj(self, name, value):
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     origin_xdr_obj = ManageData(name, value, source).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, ManageData)
     assert op.source == source
     assert op.data_name == name
     if isinstance(value, str):
         value = value.encode()
     assert op.data_value == value
 def test_from_xdr_obj_muxed_account(self):
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     destination = (
         "MAAAAAAAAAAAJURAAB2X52XFQP6FBXLGT6LWOOWMEXWHEWBDVRZ7V5WH34Y22MPFBHUHY"
     )
     origin_xdr_obj = AccountMerge(destination, source).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, AccountMerge)
     assert op.source == source
     assert op.destination == destination
Example #9
0
 def test_from_xdr_obj(self, asset_code, authorize):
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     trustor = "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"
     origin_xdr_obj = AllowTrust(trustor, asset_code, authorize,
                                 source).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, AllowTrust)
     assert op.source == source
     assert op.trustor == trustor
     assert op.asset_code == asset_code
     assert op.authorize == authorize
    def test_get_source_exist_from_xdr_obj(self):  # BAD TEST
        source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
        destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"
        starting_balance = "1000.00"
        origin_op = CreateAccount(destination, starting_balance, source)
        origin_xdr_obj = origin_op.to_xdr_object()

        op = Operation.from_xdr_object(origin_xdr_obj)
        assert op.source == source
        assert op.starting_balance == "1000"
        assert op.destination == destination
    def test_get_muxed_account_source_exist_from_xdr_obj(self):  # BAD TEST
        source = "MAAAAAAAAAAAJURAAB2X52XFQP6FBXLGT6LWOOWMEXWHEWBDVRZ7V5WH34Y22MPFBHUHY"
        destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"
        starting_balance = "1000.00"
        origin_op = CreateAccount(destination, starting_balance, source)
        origin_xdr_obj = origin_op.to_xdr_object()

        op = Operation.from_xdr_object(origin_xdr_obj)
        assert op.source == source
        assert op.starting_balance == "1000"
        assert op.destination == destination
 def test_from_xdr_obj(self):
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"
     amount = "1000.0000000"
     asset = Asset("USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7")
     origin_xdr_obj = Payment(destination, asset, amount, source).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, Payment)
     assert op.source == source
     assert op.destination == destination
     assert op.amount == "1000"
     assert op.asset == asset
 def test_to_xdr(self, selling, buying, amount, price, source, xdr):
     op = CreatePassiveSellOffer(selling, buying, amount, price, source)
     xdr_obj = op.to_xdr_object()
     assert xdr_obj.to_xdr() == xdr
     from_instance = Operation.from_xdr_object(xdr_obj)
     assert isinstance(from_instance, CreatePassiveSellOffer)
     assert from_instance.source == source
     assert from_instance.buying == buying
     assert from_instance.selling == selling
     assert Decimal(from_instance.amount) == Decimal(amount)
     if not isinstance(price, Price):
         price = Price.from_raw_price(price)
     assert from_instance.price == price
 def test_to_xdr(self, selling, buying, amount, price, offer_id, source, xdr):
     op = ManageBuyOffer(selling, buying, amount, price, offer_id, source)
     xdr_obj = op.to_xdr_object()
     assert xdr_obj.to_xdr() == xdr
     from_instance = Operation.from_xdr_object(xdr_obj)
     assert isinstance(from_instance, ManageBuyOffer)
     assert from_instance.source == source
     assert from_instance.buying == buying
     assert from_instance.selling == selling
     assert from_instance.amount == amount
     if not isinstance(price, Price):
         price = Price.from_raw_price(price)
     assert from_instance.price == price
     assert from_instance.offer_id == offer_id
Example #15
0
    def test_get_source_muxed_from_xdr_obj(self):  # BAD TEST
        destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"
        source = "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB"
        source2 = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
        starting_balance = "1000.00"
        origin_op = CreateAccount(destination, starting_balance, source)
        origin_xdr_obj = origin_op.to_xdr_object()

        op = Operation.from_xdr_object(origin_xdr_obj)
        assert op.to_xdr_object().to_xdr() == origin_xdr_obj.to_xdr()
        assert op.source == source
        assert (
            op._source_muxed.to_xdr()
            == Keypair.from_public_key(source).xdr_muxed_account().to_xdr()
        )
        op.source = source2
        assert op.source == source2
        assert op._source_muxed is None
 def test_to_xdr(
     self,
     inflation_dest,
     clear_flags,
     set_flags,
     master_weight,
     low_threshold,
     med_threshold,
     high_threshold,
     home_domain,
     signer,
     source,
     xdr,
 ):
     op = SetOptions(
         inflation_dest,
         clear_flags,
         set_flags,
         master_weight,
         low_threshold,
         med_threshold,
         high_threshold,
         signer,
         home_domain,
         source,
     )
     xdr_obj = op.to_xdr_object()
     assert xdr_obj.to_xdr() == xdr
     from_instance = Operation.from_xdr_object(xdr_obj)
     assert isinstance(from_instance, SetOptions)
     assert from_instance.source == source
     assert from_instance.clear_flags == clear_flags
     assert from_instance.set_flags == set_flags
     assert from_instance.master_weight == master_weight
     assert from_instance.low_threshold == low_threshold
     assert from_instance.med_threshold == med_threshold
     assert from_instance.high_threshold == high_threshold
     assert from_instance.signer == signer
     assert from_instance.home_domain == home_domain
 def test_from_xdr_obj(self):
     source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV"
     origin_xdr_obj = Inflation(source).to_xdr_object()
     op = Operation.from_xdr_object(origin_xdr_obj)
     assert isinstance(op, Inflation)
     assert op.source == source