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_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_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_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()
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_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, }