Beispiel #1
0
 def test_for_offer(self):
     offer_id = "1000"
     builder = OffersCallBuilder(horizon_url, client)
     builder.offer(offer_id)
     assert builder.endpoint == "offers/{offer_id}".format(
         offer_id=offer_id)
     assert builder.params == {}
Beispiel #2
0
 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,
     }
Beispiel #3
0
    def test_endpoint(self):
        horizon_url = "https://horizon.stellar.org"
        client = RequestsClient()
        with Server(horizon_url, client) as server:
            assert server.accounts() == AccountsCallBuilder(
                horizon_url, client)
            assert server.assets() == AssetsCallBuilder(horizon_url, client)
            assert server.claimable_balances() == ClaimableBalancesCallBuilder(
                horizon_url, client)
            assert server.data(
                "GDV6FVHPY4JH7EEBSJYPQQYZA3OC6TKTM2TAXRHWT4EEL7BJ2BTDQT5D",
                "hello") == DataCallBuilder(
                    horizon_url,
                    client,
                    "GDV6FVHPY4JH7EEBSJYPQQYZA3OC6TKTM2TAXRHWT4EEL7BJ2BTDQT5D",
                    "hello",
                )
            assert server.effects() == EffectsCallBuilder(horizon_url, client)
            assert server.fee_stats() == FeeStatsCallBuilder(
                horizon_url, client)
            assert server.ledgers() == LedgersCallBuilder(horizon_url, client)
            assert server.offers() == OffersCallBuilder(horizon_url, client)
            assert server.operations() == OperationsCallBuilder(
                horizon_url, client)
            buying = Asset.native()
            selling = Asset(
                "MOE",
                "GDV6FVHPY4JH7EEBSJYPQQYZA3OC6TKTM2TAXRHWT4EEL7BJ2BTDQT5D")
            assert server.orderbook(buying, selling) == OrderbookCallBuilder(
                horizon_url, client, buying, selling)
            source = "GAYSHLG75RPSMXWJ5KX7O7STE6RSZTD6NE4CTWAXFZYYVYIFRUVJIBJH"
            destination_asset = Asset(
                "EUR",
                "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")
            destination_amount = "20.0"
            assert server.strict_receive_paths(
                source, destination_asset,
                destination_amount) == StrictReceivePathsCallBuilder(
                    horizon_url, client, source, destination_asset,
                    destination_amount)

            source_asset = Asset(
                "EUR",
                "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")
            source_amount = "10.25"
            destination = "GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP"
            assert server.strict_send_paths(
                source_asset, source_amount,
                destination) == StrictSendPathsCallBuilder(
                    horizon_url, client, source_asset, source_amount,
                    destination)
            assert server.payments() == PaymentsCallBuilder(
                horizon_url, client)
            assert server.root() == RootCallBuilder(horizon_url, client)
            base = Asset.native()
            counter = Asset(
                "MOE",
                "GDV6FVHPY4JH7EEBSJYPQQYZA3OC6TKTM2TAXRHWT4EEL7BJ2BTDQT5D")
            resolution = 3600000
            start_time = 1565272000000
            end_time = 1565278000000
            offset = 3600000
            assert server.trade_aggregations(
                base, counter, resolution, start_time, end_time,
                offset) == TradeAggregationsCallBuilder(
                    horizon_url,
                    client,
                    base,
                    counter,
                    resolution,
                    start_time,
                    end_time,
                    offset,
                )
            assert server.trades() == TradesCallBuilder(horizon_url, client)
            assert server.transactions() == TransactionsCallBuilder(
                horizon_url, client)
Beispiel #4
0
 def test_endpoint(self):
     horizon_url = "https://horizon.stellar.org"
     client = RequestsClient()
     with Server(horizon_url, client) as server:
         assert server.accounts() == AccountsCallBuilder(
             horizon_url, client)
         assert server.assets() == AssetsCallBuilder(horizon_url, client)
         assert server.effects() == EffectsCallBuilder(horizon_url, client)
         assert server.fee_stats() == FeeStatsCallBuilder(
             horizon_url, client)
         assert server.ledgers() == LedgersCallBuilder(horizon_url, client)
         assert server.offers(
             "GDV6FVHPY4JH7EEBSJYPQQYZA3OC6TKTM2TAXRHWT4EEL7BJ2BTDQT5D"
         ) == OffersCallBuilder(
             horizon_url,
             client,
             "GDV6FVHPY4JH7EEBSJYPQQYZA3OC6TKTM2TAXRHWT4EEL7BJ2BTDQT5D",
         )
         assert server.operations() == OperationsCallBuilder(
             horizon_url, client)
         buying = Asset.native()
         selling = Asset(
             "MOE",
             "GDV6FVHPY4JH7EEBSJYPQQYZA3OC6TKTM2TAXRHWT4EEL7BJ2BTDQT5D")
         assert server.orderbook(buying, selling) == OrderbookCallBuilder(
             horizon_url, client, buying, selling)
         source_account = "GABUVMDURJFF477AEDAXOG5TL7JBHGDAKJQLH5K6FB5QONMLEV52C6IO"
         destination_account = (
             "GDV6FVHPY4JH7EEBSJYPQQYZA3OC6TKTM2TAXRHWT4EEL7BJ2BTDQT5D")
         destination_asset = Asset.native()
         destination_amount = "100.0"
         assert server.paths(
             source_account,
             destination_account,
             destination_asset,
             destination_amount,
         ) == PathsCallBuilder(
             horizon_url,
             client,
             source_account,
             destination_account,
             destination_asset,
             destination_amount,
         )
         assert server.payments() == PaymentsCallBuilder(
             horizon_url, client)
         assert server.root() == RootCallBuilder(horizon_url, client)
         base = Asset.native()
         counter = Asset(
             "MOE",
             "GDV6FVHPY4JH7EEBSJYPQQYZA3OC6TKTM2TAXRHWT4EEL7BJ2BTDQT5D")
         resolution = 3600000
         start_time = 1565272000000
         end_time = 1565278000000
         offset = 3600000
         assert server.trade_aggregations(
             base, counter, resolution, start_time, end_time,
             offset) == TradeAggregationsCallBuilder(
                 horizon_url,
                 client,
                 base,
                 counter,
                 resolution,
                 start_time,
                 end_time,
                 offset,
             )
         assert server.trades() == TradesCallBuilder(horizon_url, client)
         assert server.transactions() == TransactionsCallBuilder(
             horizon_url, client)
Beispiel #5
0
 def test_init(self):
     builder = OffersCallBuilder(horizon_url, client)
     assert builder.endpoint == "offers"
     assert builder.params == {}
 def test_for_sponsor(self):
     sponsor = "GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V"
     builder = OffersCallBuilder(horizon_url, client).for_sponsor(sponsor)
     assert builder.endpoint == "offers"
     assert builder.params == {"sponsor": sponsor}