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_init_source_assets(self): builder = StrictReceivePathsCallBuilder( horizon_url, client, source=[ Asset.native(), Asset( "USD", "GAYSHLG75RPSMXWJ5KX7O7STE6RSZTD6NE4CTWAXFZYYVYIFRUVJIBJH" ), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), ], destination_asset=Asset( "EUR", "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" ), destination_amount="20.0", ) assert builder.endpoint == "paths/strict-receive" assert builder.params == { "destination_amount": "20.0", "destination_asset_type": "credit_alphanum4", "destination_asset_code": "EUR", "destination_asset_issuer": "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", "source_assets": "native,USD:GAYSHLG75RPSMXWJ5KX7O7STE6RSZTD6NE4CTWAXFZYYVYIFRUVJIBJH,XCN:GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY", }
def test_invalid_resolution_raise(self): base = Asset("XCN", "GCOMOKXUA4TAEBB2QDHZD53SNRWKNTJMVEFLE47JYN5HS7KNLOABVA4Z") counter = Asset.native() resolution = 1000 with pytest.raises( ValueError, match="Invalid resolution: {}".format(resolution) ): TradeAggregationsCallBuilder( horizon_url, client, base=base, counter=counter, resolution=resolution )
def test_init(self): selling = Asset( "BTC", "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH") buying = Asset.native() builder = OrderbookCallBuilder(horizon_url, client, selling, buying) assert builder.endpoint == "order_book" assert builder.params == { "selling_asset_type": selling.type, "selling_asset_code": selling.code, "selling_asset_issuer": selling.issuer, "buying_asset_type": buying.type, }
def test_for_asset_pair(self): base = Asset( "XCN", "GCOMOKXUA4TAEBB2QDHZD53SNRWKNTJMVEFLE47JYN5HS7KNLOABVA4Z") counter = Asset.native() builder = TradesCallBuilder(horizon_url, client).for_asset_pair(base=base, counter=counter) assert builder.endpoint == "trades" assert builder.params == { "base_asset_type": base.type, "base_asset_code": base.code, "base_asset_issuer": base.issuer, "counter_asset_type": counter.type, }
def test_init(self): base = Asset("XCN", "GCOMOKXUA4TAEBB2QDHZD53SNRWKNTJMVEFLE47JYN5HS7KNLOABVA4Z") counter = Asset.native() resolution = 300000 builder = TradeAggregationsCallBuilder( horizon_url, client, base=base, counter=counter, resolution=resolution ) assert builder.endpoint == "trade_aggregations" assert builder.params == { "base_asset_type": base.type, "base_asset_code": base.code, "base_asset_issuer": base.issuer, "counter_asset_type": counter.type, "resolution": str(resolution), }
def test_to_xdr_obj_with_invalid_amount_raise(self): source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV" destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" amount = 1 asset = Asset("USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7") with pytest.raises(TypeError): Payment(destination, asset, amount, source)
def test_to_xdr_obj_with_invalid_destination_raise(self): source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV" destination = "GCEZW" amount = "1000.0000000" asset = Asset("USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7") with pytest.raises(Ed25519PublicKeyInvalidError): Payment(destination, asset, amount, source)
def test_to_xdr_str_source(self): source = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" destination = "GDJJRRMBK4IWLEPJGIE6SXD2LP7REGZODU7WDC3I2D6MR37F4XSHBKX2" amount = "1000.0" sequence = 1 memo = IdMemo(100) fee = 200 asset = Asset.native() time_bounds = TimeBounds(12345, 56789) ops = [Payment(destination, asset, amount), ManageData("hello", "world")] tx_object = Transaction( source, sequence, fee, ops, memo, time_bounds ).to_xdr_object() assert ( tx_object.to_xdr() == "AAAAAImbKEDtVjbFbdxfFLI5dfefG6I4jSaU5MVuzd3JYOXvAAAAyAAAAAAAAAABAAAAAQAAAAAAADA5AAAAAAAA3dUAAAACAAAAAAAAAGQAAAACAAAAAAAAAAEAAAAA0pjFgVcRZZHpMgnpXHpb/xIbLh0/YYto0PzI7+Xl5HAAAAAAAAAAAlQL5AAAAAAAAAAACgAAAAVoZWxsbwAAAAAAAAEAAAAFd29ybGQAAAAAAAAA" ) restore_transaction = Transaction.from_xdr_object(tx_object) assert isinstance(restore_transaction, Transaction) assert restore_transaction.source == Keypair.from_public_key(source) assert restore_transaction.fee == fee assert restore_transaction.memo == memo assert restore_transaction.time_bounds == time_bounds assert restore_transaction.sequence == sequence
def test_init(self): source_account = "GCOMOKXUA4TAEBB2QDHZD53SNRWKNTJMVEFLE47JYN5HS7KNLOABVA4Z" destination_account = "GBSHJKHCXZ4OCFT44UVNEERGIM25NCHXCLA6MUXMTNIOQ5UHV22X4H2R" destination_asset = Asset( "USD", "GAMLPCLHQMS4GOHBUXHLWVKUIKOZSHYPIOO54EMSWGHBUJBO4S5T2MGG") destination_amount = "1000.0" builder = PathsCallBuilder( horizon_url, client, source_account=source_account, destination_account=destination_account, destination_asset=destination_asset, destination_amount=destination_amount, ) assert builder.endpoint == "paths" assert builder.params == { "destination_account": destination_account, "source_account": source_account, "destination_amount": destination_amount, "destination_asset_type": destination_asset.type, "destination_asset_issuer": destination_asset.issuer, "destination_asset_code": destination_asset.code, }
def test_for_seller(self): seller = "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH" selling = Asset( "BTC", "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH" ) buying = Asset.native() builder = OffersCallBuilder(horizon_url, client) builder.for_seller(seller) builder.for_selling(selling) builder.for_buying(buying) assert builder.endpoint == "offers" assert builder.params == { "seller": seller, "selling_asset_type": selling.type, "selling_asset_code": selling.code, "selling_asset_issuer": selling.issuer, "buying_asset_type": buying.type, }
def test_to_xdr_obj(self): source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV" destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" amount = "1000.0000000" asset = Asset("USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7") op = Payment(destination, asset, amount, source) assert ( op.to_xdr_object().to_xdr() == "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAAEAAAAAiZsoQO1WNsVt3F8Usjl1958bojiNJpTkxW7N3clg5e8AAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAJUC+QA" )
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_to_xdr_obj_with_invalid_destination_raise(self): source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV" destination = "GCEZW" 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"), ] with pytest.raises(Ed25519PublicKeyInvalidError): PathPaymentStrictSend( destination, send_asset, send_amount, dest_asset, dest_min, path, source )
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_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"), ] op = PathPaymentStrictSend( destination, send_asset, send_amount, dest_asset, dest_min, path, source ) assert ( op.to_xdr_object().to_xdr() == "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAA0AAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAAB31rYAAAAAImbKEDtVjbFbdxfFLI5dfefG6I4jSaU5MVuzd3JYOXvAAAAAVVTRAAAAAAAzU64DztfTtBLJ2I0nN998lhiyhFcS8rtZHyowijs/XsAAAAAAcrU8AAAAAIAAAABVVNEAAAAAABCzwVZeQ9sO2TeFRIN8Lslyqt9wttPtKGKNeiBvzI69wAAAAFFVVIAAAAAAObbxW5I9YIF6lfUJkfp3sADdrm5wJmdBv78Py6kKta1" )
def test_none_memo(self): source = Keypair.from_public_key( "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" ) destination = "GDJJRRMBK4IWLEPJGIE6SXD2LP7REGZODU7WDC3I2D6MR37F4XSHBKX2" amount = "1000.0" sequence = 1 fee = 200 asset = Asset.native() ops = [Payment(destination, asset, amount), ManageData("hello", "world")] tx = Transaction(source, sequence, fee, ops) assert tx.memo == NoneMemo()
class TestManageBuyOffer: @pytest.mark.parametrize( "selling, buying, amount, price, offer_id, source, xdr", [ ( Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "3.123456", "8.141592", 1, "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV", "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAAwAAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAFYQ04AAAAAAJuOuviWOFUdz56k90MgcRBrh6sOLbPWm3WlOCJy91nYAAAAAAHcmgAAD4djAAHoSAAAAAAAAAAB", ), ( Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "8", "238.141592", 0, None, "AAAAAAAAAAwAAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAFYQ04AAAAAAJuOuviWOFUdz56k90MgcRBrh6sOLbPWm3WlOCJy91nYAAAAAATEtAABxjgTAAHoSAAAAAAAAAAA", ), ( Asset("PAYDEX"), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "3.123456", Price(11, 10), 1, "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV", "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAAwAAAAAAAAAAVhDTgAAAAAAm466+JY4VR3PnqT3QyBxEGuHqw4ts9abdaU4InL3WdgAAAAAAdyaAAAAAAsAAAAKAAAAAAAAAAE=", ), ], ) 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
class TestCreatePassiveSellOffer: @pytest.mark.parametrize( "selling, buying, amount, price, source, xdr", [ ( Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "11.2782700", "3.07", "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV", "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAAQAAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAFYQ04AAAAAAJuOuviWOFUdz56k90MgcRBrh6sOLbPWm3WlOCJy91nYAAAAAAa47WwAAAEzAAAAZA==", ), ( Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "8.000", "238.141592", None, "AAAAAAAAAAQAAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAFYQ04AAAAAAJuOuviWOFUdz56k90MgcRBrh6sOLbPWm3WlOCJy91nYAAAAAATEtAABxjgTAAHoSA==", ), ( Asset("PAYDEX"), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "11.2782700", Price(453, 4354), "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV", "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAAQAAAAAAAAAAVhDTgAAAAAAm466+JY4VR3PnqT3QyBxEGuHqw4ts9abdaU4InL3WdgAAAAABrjtbAAAAcUAABEC", ), ], ) 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_init_source_account(self): builder = StrictReceivePathsCallBuilder( horizon_url, client, source="GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP", destination_asset=Asset( "EUR", "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" ), destination_amount="20.0", ) assert builder.endpoint == "paths/strict-receive" assert builder.params == { "destination_amount": "20.0", "destination_asset_type": "credit_alphanum4", "destination_asset_code": "EUR", "destination_asset_issuer": "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", "source_account": "GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP", }
def test_to_xdr(self): sequence = 1 source = Account( "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", sequence ) builder = TransactionBuilder( source, Network.TESTNET_NETWORK_PASSPHRASE, base_fee=150 ) builder.add_text_memo("Paydex Python SDK") builder.add_time_bounds(1565590000, 1565600000) te = ( builder.append_create_account_op( "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", "5.5", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", ) .append_change_trust_op( "XCN", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", "100000", ) .append_payment_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", "12.25", "PAYDEX", ) .append_path_payment_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", "PAYDEX", None, "100", "XCN", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", "1000.5", [ Asset( "USD", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), Asset( "BTC", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), ], ) .append_path_payment_strict_receive_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", "PAYDEX", None, "100", "XCN", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", "1000.5", [ Asset( "USD", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), Asset( "BTC", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), ], ) .append_path_payment_strict_send_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", "PAYDEX", None, "100", "XCN", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", "1000.5", [ Asset( "USD", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), Asset( "BTC", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), ], ) .append_allow_trust_op( "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", "XCN", True ) .append_set_options_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", 1, 6, 20, 20, 20, 20, "paydexcn.org", Signer.ed25519_public_key( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", 10 ), "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", ) .append_ed25519_public_key_signer( "GCN4HBZGFPOAI5DF4YQIS6OBC6KJKDC7CJSS5B4FWEXMJSWOPEYABLSD", 5 ) .append_hashx_signer( bytes.fromhex( "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8000" ), 10, ) .append_pre_auth_tx_signer( bytes.fromhex( "2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cfa4fc5a000" ), 10, ) .append_inflation_op() .append_manage_data_op("hello", "overcat") .append_bump_sequence_op(10) .append_manage_buy_offer_op( "XCN", "GCN4HBZGFPOAI5DF4YQIS6OBC6KJKDC7CJSS5B4FWEXMJSWOPEYABLSD", "PAYDEX", None, "10.5", "11.25", ) .append_manage_sell_offer_op( "PAYDEX", None, "XCN", "GCN4HBZGFPOAI5DF4YQIS6OBC6KJKDC7CJSS5B4FWEXMJSWOPEYABLSD", "10.5", Price(8, 9), 10086, ) .append_create_passive_sell_offer_op( "XCN", "GCN4HBZGFPOAI5DF4YQIS6OBC6KJKDC7CJSS5B4FWEXMJSWOPEYABLSD", "PAYDEX", None, "10.5", "11.25", ) .append_account_merge_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF" ) .build() ) xdr = "AAAAAMvXcdYjKhx0qxnsDsczxKuqa/65lZz6sjjHHczyh50JAAAKjAAAAAAAAAACAAAAAQAAAABdUQHwAAAAAF1RKQAAAAABAAAAElN0ZWxsYXIgUHl0aG9uIFNESwAAAAAAEgAAAAEAAAAAy9dx1iMqHHSrGewOxzPEq6pr/rmVnPqyOMcdzPKHnQkAAAAAAAAAANspYkKUk/8Uke2IS7CdNxkxUCocYSU7D9+VRVRh1UTCAAAAAANHO8AAAAAAAAAABgAAAAFYQ04AAAAAAMvXcdYjKhx0qxnsDsczxKuqa/65lZz6sjjHHczyh50JAAAA6NSlEAAAAAAAAAAAAQAAAAAu358wmdD7fbo5nguyPNLentV4uwQnX4PaRcFDJkD3TAAAAAAAAAAAB00zoAAAAAAAAAACAAAAAAAAAAA7msoAAAAAAC7fnzCZ0Pt9ujmeC7I80t6e1Xi7BCdfg9pFwUMmQPdMAAAAAVhDTgAAAAAAy9dx1iMqHHSrGewOxzPEq6pr/rmVnPqyOMcdzPKHnQkAAAACVFgvQAAAAAIAAAABVVNEAAAAAADbKWJClJP/FJHtiEuwnTcZMVAqHGElOw/flUVUYdVEwgAAAAFCVEMAAAAAANspYkKUk/8Uke2IS7CdNxkxUCocYSU7D9+VRVRh1UTCAAAAAAAAAAIAAAAAAAAAADuaygAAAAAALt+fMJnQ+326OZ4LsjzS3p7VeLsEJ1+D2kXBQyZA90wAAAABWENOAAAAAADL13HWIyocdKsZ7A7HM8Srqmv+uZWc+rI4xx3M8oedCQAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIzienw8aZfGXNsrPVEwuglMT6ER/VpIzu42zmqYHyAAAAAAAoAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEttLIsoBgRnFAnqAV4gT/89YLNpKqeMc2StDz6T8WgAAAAAAoAAAAAAAAACQAAAAAAAAAKAAAABWhlbGxvAAAAAAAAAQAAAAdvdmVyY2F0AAAAAAAAAAALAAAAAAAAAAoAAAAAAAAADAAAAAFYQ04AAAAAAJvDhyYr3AR0ZeYgiXnBF5SVDF8SZS6HhbEuxMrOeTAAAAAAAAAAAAAGQixAAAAALQAAAAQAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAFYQ04AAAAAAJvDhyYr3AR0ZeYgiXnBF5SVDF8SZS6HhbEuxMrOeTAAAAAAAAZCLEAAAAAIAAAACQAAAAAAACdmAAAAAAAAAAQAAAABWENOAAAAAACbw4cmK9wEdGXmIIl5wReUlQxfEmUuh4WxLsTKznkwAAAAAAAAAAAABkIsQAAAAC0AAAAEAAAAAAAAAAgAAAAALt+fMJnQ+326OZ4LsjzS3p7VeLsEJ1+D2kXBQyZA90wAAAAAAAAAAfKHnQkAAABAK4QrN2s/qldwTQG+XHZ/KgKmc1t3MoTE7wa34OuIBVCDdC58WChaHVaB40hcGGbR6Q9Y83Qdj+e1dPNLBQ18Bw==" signer = Keypair.from_secret( "SCCS5ZBI7WVIJ4SW36WGOQQIWJYCL3VOAULSXX3FB57USIO25EDOYQHH" ) te.sign(signer) assert te.to_xdr() == xdr_signed restore_te = TransactionBuilder.from_xdr( xdr_signed, Network.TESTNET_NETWORK_PASSPHRASE ).build() assert restore_te.to_xdr() == xdr assert source.sequence == sequence + 1
def test_to_xdr_obj(self, limit, xdr): asset = Asset("USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7") source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV" op = ChangeTrust(asset, limit, source) assert op.to_xdr_object().to_xdr() == xdr