-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed SpotApi.Account.GetUserAssetsAsync deserialization due to too l…
…arge number being returned, added integration tests
- Loading branch information
Showing
3 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using Mexc.Net.Clients; | ||
using Mexc.Net.Objects; | ||
using CryptoExchange.Net.Authentication; | ||
using CryptoExchange.Net.Testing; | ||
using Microsoft.Extensions.Logging; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Mexc.Net.UnitTests | ||
{ | ||
[NonParallelizable] | ||
internal class MexcRestIntegrationTests : RestIntergrationTest<MexcRestClient> | ||
{ | ||
public override bool Run { get; set; } = true; | ||
|
||
public MexcRestIntegrationTests() | ||
{ | ||
} | ||
|
||
public override MexcRestClient GetClient(ILoggerFactory loggerFactory) | ||
{ | ||
var key = Environment.GetEnvironmentVariable("APIKEY"); | ||
var sec = Environment.GetEnvironmentVariable("APISECRET"); | ||
|
||
key = "mx0vglXH1pl1WUt0Kd"; | ||
sec = "d812baf264d24b08817d618bcad3b062"; | ||
|
||
Authenticated = key != null && sec != null; | ||
return new MexcRestClient(null, loggerFactory, opts => | ||
{ | ||
opts.OutputOriginalData = true; | ||
opts.ApiCredentials = Authenticated ? new ApiCredentials(key, sec) : null; | ||
}); | ||
} | ||
|
||
[Test] | ||
public async Task TestErrorResponseParsing() | ||
{ | ||
if (!ShouldRun()) | ||
return; | ||
|
||
var result = await CreateClient().SpotApi.ExchangeData.GetKlinesAsync("TSTTST", Enums.KlineInterval.OneDay, default); | ||
|
||
Assert.That(result.Success, Is.False); | ||
Assert.That(result.Error.Code, Is.EqualTo(-1121)); | ||
} | ||
|
||
[Test] | ||
public async Task TestSpotAccount() | ||
{ | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetAccountInfoAsync(default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetUserAssetsAsync(default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetDepositHistoryAsync(default, default, default, default, default, default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetWithdrawHistoryAsync(default, default, default, default, default, default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetWithdrawAddressesAsync(default, default, default, default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetTransferHistoryAsync(Enums.AccountType.Spot, Enums.AccountType.Futures, default, default, default, default, default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetAssetsForDustTransferAsync(default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetDustLogAsync(default, default, default, default, default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetMxDeductionStatusAsync(default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Account.GetTradeFeeAsync("ETHUSDT", default), true); | ||
} | ||
|
||
[Test] | ||
public async Task TestSpotExchangeData() | ||
{ | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetServerTimeAsync(default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetApiSymbolsAsync(default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetExchangeInfoAsync(default, default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetOrderBookAsync("ETHUSDT", default, default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetRecentTradesAsync("ETHUSDT", default, default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetAggregatedTradeHistoryAsync("ETHUSDT", default, default, default, default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetKlinesAsync("ETHUSDT",Enums.KlineInterval.OneDay, default, default, default, default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetAveragePriceAsync("ETHUSDT", default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT", default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetPricesAsync(default, default), false); | ||
await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetBookPricesAsync(default, default), false); | ||
} | ||
|
||
[Test] | ||
public async Task TestSpotTrading() | ||
{ | ||
await RunAndCheckResult(client => client.SpotApi.Trading.GetOpenOrdersAsync("ETHUSDT", default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Trading.GetOrdersAsync("ETHUSDT", default, default, default, default), true); | ||
await RunAndCheckResult(client => client.SpotApi.Trading.GetUserTradesAsync("ETHUSDT", default, default, default, default, default), true); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters