mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
Fix Kraken rate provider
This commit is contained in:
parent
de92677b69
commit
15e1169f62
@ -177,9 +177,15 @@ namespace BTCPayServer.Services.Rates
|
||||
var result = JsonConvert.DeserializeObject<T>(stringResult);
|
||||
if (result is JToken json)
|
||||
{
|
||||
if (!(json is JArray) && json["result"] is JObject {Count: > 0} pairResult)
|
||||
{
|
||||
return (T)(object)(pairResult);
|
||||
}
|
||||
|
||||
if (!(json is JArray) && json["error"] is JArray error && error.Count != 0)
|
||||
{
|
||||
throw new APIException(error[0].ToStringInvariant());
|
||||
throw new APIException(string.Join("\n",
|
||||
error.Select(token => token.ToStringInvariant()).Distinct()));
|
||||
}
|
||||
result = (T)(object)(json["result"] ?? json);
|
||||
}
|
||||
|
@ -72,10 +72,10 @@ namespace BTCPayServer.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanQueryDirectProviders()
|
||||
public async Task CanQueryDirectProviders()
|
||||
{
|
||||
// TODO: Check once in a while whether or not they are working again
|
||||
string[] brokenShitcoinCasinos = { "okex" };
|
||||
string[] brokenShitcoinCasinos = { };
|
||||
var factory = FastTests.CreateBTCPayRateFactory();
|
||||
var directlySupported = factory.GetSupportedExchanges().Where(s => s.Source == RateSource.Direct)
|
||||
.Select(s => s.Id).ToHashSet();
|
||||
@ -154,12 +154,11 @@ namespace BTCPayServer.Tests
|
||||
// Kraken emit one request only after first GetRates
|
||||
factory.Providers["kraken"].GetRatesAsync(default).GetAwaiter().GetResult();
|
||||
|
||||
using (var c = new HttpClient())
|
||||
{
|
||||
var p = new ExchangeSharpRateProvider<ExchangeSharp.ExchangeKrakenAPI>(c);
|
||||
var rates = p.GetRatesAsync(default).GetAwaiter().GetResult();
|
||||
Assert.Contains(rates, e => e.CurrencyPair == new CurrencyPair("XXMR", "XXBT") && e.BidAsk.Bid < 1.0m);
|
||||
}
|
||||
|
||||
var p = new KrakenExchangeRateProvider();
|
||||
var rates = await p.GetRatesAsync(default);
|
||||
Assert.Contains(rates, e => e.CurrencyPair == new CurrencyPair("XMR", "BTC") && e.BidAsk.Bid < 1.0m);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
Loading…
Reference in New Issue
Block a user