Exemplo n.º 1
0
        public async Task TestAccountsAccount()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "account.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var account = await server.Accounts.Account(KeyPair.FromAccountId("GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"));

                AccountDeserializerTest.AssertTestData(account);
            }
        }
Exemplo n.º 2
0
        public async Task TestExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "feeStats.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var fees = await server.FeeStats.Execute();

                FeeStatsDeserializerTest.AssertTestData(fees);
            }
        }
Exemplo n.º 3
0
        public async Task TestOffersExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "offerPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var offerResponsePage = await server.Offers.ForAccount(KeyPair.FromAccountId("GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"))
                                        .Execute();

                OfferPageDeserializerTest.AssertTestData(offerResponsePage);
            }
        }
        public async Task TestLedgersExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "ledgerPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var ledgersPage = await server.Ledgers
                                  .Execute();

                LedgerPageDeserializerTest.AssertTestData(ledgersPage);
            }
        }
        public async Task TestOperationsExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata/operations", "operationPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var account = await server.Operations.ForAccount("GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7")
                              .Execute();

                OperationPageDeserializerTest.AssertTestData(account);
            }
        }
Exemplo n.º 6
0
        public async Task TestAccountsData()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "accountData.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var accountData = await server.Accounts.AccountData(KeyPair.FromAccountId("GAKLBGHNHFQ3BMUYG5KU4BEWO6EYQHZHAXEWC33W34PH2RBHZDSQBD75"), "TestValue");

                Assert.AreEqual("VGVzdFZhbHVl", accountData.Value);
                Assert.AreEqual("TestValue", accountData.ValueDecoded);
            }
        }
Exemplo n.º 7
0
        public async Task TestClaimableBalance()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "claimableBalance.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var claimableBalance =
                    await server.ClaimableBalances.ClaimableBalance(
                        "00000000c582697b67cbec7f9ce64f4dc67bfb2bfd26318bb9f964f4d70e3f41f650b1e6");

                ClaimableBalanceDeserializerTest.AssertTestData(claimableBalance);
            }
        }
        public async Task TestAssetExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "assetPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                //the assetcode string really doesn't matter for testing, as the response is static for testing purposes...
                var assetsPage = await server.Assets.AssetCode("")
                                 .Execute();

                AssetPageDeserializerTest.AssertTestData(assetsPage);
            }
        }
        public async Task TestOrderBookExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "orderBook.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var orderBookPage = await server.OrderBook
                                    .BuyingAsset(new AssetTypeNative())
                                    .SellingAsset(new AssetTypeCreditAlphaNum4("DEMO", "GC3BVJOU7SHHFLZ2LDYW6JU4YW36R2MRF6C37QJWQXZWG3JBYNODGHOB"))
                                    .Execute();

                OrderBookDeserializerTest.AssertTestData(orderBookPage);
            }
        }
Exemplo n.º 10
0
        public async Task TestTradesExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "tradesPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var trades = await server.Trades
                             .BaseAsset(new AssetTypeCreditAlphaNum4("EUR", "GAUPA4HERNBDPVO4IUA3MJXBCRRK5W54EVXTDK6IIUTGDQRB6D5W242W"))
                             .CounterAsset(new AssetTypeCreditAlphaNum4("USD", "GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ"))
                             .Execute();

                TradesPageDeserializerTest.AssertTestData(trades);
            }
        }
Exemplo n.º 11
0
        public async Task TestLink()
        {
            var link = new Link <AccountResponse>(
                "https://horizon.stellar.org/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");

            Assert.AreEqual("horizon.stellar.org", link.Uri.Host);
            Assert.AreEqual("/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7",
                            string.Concat(link.Uri.Segments));

            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "account.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            var response = await link.Follow(fakeHttpClient);

            AccountDeserializerTest.AssertTestData(response);
        }
        public async Task TestFriendBotExecute()
        {
            Network.UseTestNetwork();

            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "friendBotSuccess.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var friendBotResponse = await server.TestNetFriendBot
                                        .FundAccount(KeyPair.FromAccountId("GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"))
                                        .Execute();

                FriendBotResponseTest.AssertSuccessTestData(friendBotResponse);
            }
        }
Exemplo n.º 13
0
        public async Task TestOffersWithSeller()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "offerPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var req = server.Offers.WithSeller("GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");

                Assert.AreEqual("https://horizon-testnet.stellar.org/offers?seller=GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", req.BuildUri().ToString());

                var offerResponsePage = await req.Execute();

                OfferPageDeserializerTest.AssertTestData(offerResponsePage);
            }
        }
Exemplo n.º 14
0
        public async Task TestPathsExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "pathsPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var account = await server.Paths
                              .SourceAccount(KeyPair.FromAccountId("GD4KO3IOYYWIYVI236Y35K2DU6VNYRH3BPNFJSH57J5BLLCQHBIOK3IN"))
                              .DestinationAccount(KeyPair.FromAccountId("GB24QI3BJNKBY4YNJZ2I37HFIYK56BL2OURFML76X46RQQKDLVT7WKJF"))
                              .DestinationAmount("20")
                              .Execute();

                PathsPageDeserializerTest.AssertTestData(account);
            }
        }
Exemplo n.º 15
0
        public async Task TestOffersWithSellingNativeAsset()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "offerPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var req = server.Offers.WithSellingAsset(new AssetTypeNative());

                Assert.AreEqual(
                    "https://horizon-testnet.stellar.org/offers?selling_asset_type=native",
                    req.BuildUri().ToString());

                var offerResponsePage = await req.Execute();

                OfferPageDeserializerTest.AssertTestData(offerResponsePage);
            }
        }
        public async Task TestTradeAggregationsExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "tradeAggregationsPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var account = await server.TradeAggregations
                              .BaseAsset(new AssetTypeNative())
                              .CounterAsset(new AssetTypeCreditAlphaNum4("BTC", KeyPair.FromAccountId("GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH")))
                              .StartTime(1512689100000L)
                              .EndTime(1512775500000L)
                              .Resolution(300000L)
                              .Execute();

                TradeAggregationsPageDeserializerTest.AssertTestData(account);
            }
        }
Exemplo n.º 17
0
        public async Task TestAccountsWithSigner()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "accountsWithSigner.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var req = server.Accounts
                          .WithSigner("GBPOFUJUHOFTZHMZ63H5GE6NX5KVKQRD6N3I2E5AL3T2UG7HSLPLXN2K");

                Assert.AreEqual(
                    "https://horizon-testnet.stellar.org/accounts?signer=GBPOFUJUHOFTZHMZ63H5GE6NX5KVKQRD6N3I2E5AL3T2UG7HSLPLXN2K",
                    req.BuildUri().ToString());
                var accounts = await req.Execute();

                Assert.AreEqual(1, accounts.Records.Count);
            }
        }
Exemplo n.º 18
0
        public async Task TestExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "pathsPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var sourceAsset =
                    Asset.CreateNonNativeAsset("USD", "GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V");

                var assets = await server.PathStrictSend
                             .SourceAmount("10.1")
                             .SourceAsset(sourceAsset)
                             .DestinationAssets(new [] { new AssetTypeNative(), sourceAsset })
                             .Execute();

                PathsPageDeserializerTest.AssertTestData(assets);
            }
        }
Exemplo n.º 19
0
        public async Task TestAccountsWithTrustline()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "accountsWithTrustline.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var asset = Asset.CreateNonNativeAsset("FOO",
                                                       "GAGLYFZJMN5HEULSTH5CIGPOPAVUYPG5YSWIYDJMAPIECYEBPM2TA3QR");
                var req = server.Accounts.WithTrustline(asset);

                Assert.AreEqual(
                    "https://horizon-testnet.stellar.org/accounts?asset=FOO:GAGLYFZJMN5HEULSTH5CIGPOPAVUYPG5YSWIYDJMAPIECYEBPM2TA3QR",
                    req.BuildUri().ToString());
                var accounts = await req.Execute();

                Assert.AreEqual(1, accounts.Records.Count);
            }
        }
        public async Task TestExecute()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "pathsPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var destinationAsset =
                    Asset.CreateNonNativeAsset("USD", "GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V");

                var assets = await server.PathStrictReceive
                             .SourceAccount("GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP")
                             .DestinationAccount("GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V")
                             .DestinationAsset(destinationAsset)
                             .DestinationAmount("10.1")
                             .Execute();

                PathsPageDeserializerTest.AssertTestData(assets);
            }
        }
Exemplo n.º 21
0
        public async Task TestOffersWithBuyingCreditAsset()
        {
            var jsonResponse   = File.ReadAllText(Path.Combine("testdata", "offerPage.json"));
            var fakeHttpClient = FakeHttpClient.CreateFakeHttpClient(jsonResponse);

            using (var server = new Server("https://horizon-testnet.stellar.org", fakeHttpClient))
            {
                var notNativeAsset = Asset.CreateNonNativeAsset("FOOBARBAZ",
                                                                "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
                var req = server.Offers.WithBuyingAsset(notNativeAsset);

                Assert.AreEqual(
                    "https://horizon-testnet.stellar.org/offers?buying_asset_type=credit_alphanum12&buying_asset_code=FOOBARBAZ&buying_asset_issuer=GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7",
                    req.BuildUri().ToString());

                var offerResponsePage = await req.Execute();

                OfferPageDeserializerTest.AssertTestData(offerResponsePage);
            }
        }