Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Jul 5, 2024
1 parent c49dd55 commit 0b932bf
Show file tree
Hide file tree
Showing 42 changed files with 1,535 additions and 83 deletions.
3 changes: 2 additions & 1 deletion BitMart.Net.UnitTests/BitMartRestClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Net.Http;
using BitMart.Net.Clients;
using BitMart.Net.Objects;

namespace BitMart.Net.UnitTests
{
Expand All @@ -14,7 +15,7 @@ public class BitMartRestClientTests
[Test]
public void CheckSignatureExample1()
{
var authProvider = new BitMartAuthenticationProvider(new ApiCredentials("XXX", "XXX"));
var authProvider = new BitMartAuthenticationProvider(new BitMartApiCredentials("XXX", "XXX"));
var client = (RestApiClient)new BitMartRestClient().SpotApi;

CryptoExchange.Net.Testing.TestHelpers.CheckSignature(
Expand Down
14 changes: 14 additions & 0 deletions BitMart.Net.UnitTests/Endpoints/Spot/Account/GetDepositAddress.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
GET
/account/v1/deposit/address
true
{
"message":"OK",
"code":1000,
"trace":"0e6edd79-f77f-4251-abe5-83ba75d06c1a",
"data":{
"currency":"USDT-TRC20",
"chain":"USDT-TRC20",
"address":"TGR3ghy2b5VLbyAYrmiE15jasR6aPHTvC5",
"address_memo":""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
GET
/account/v1/wallet
true
{
"message":"OK",
"code":1000,
"trace":"ef834248-51d3-4223-9481-f862aa9dd39f",
"data":{
"wallet":[
{
"currency":"USDT",
"name":"Tether USD",
"available":"1000.00000000",
"frozen":"0.00000000"
}
]
}
}
18 changes: 18 additions & 0 deletions BitMart.Net.UnitTests/Endpoints/Spot/Account/GetSpotBalances.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
GET
/spot/v1/wallet
true
{
"code": 1000,
"trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1",
"message": "OK",
"data": {
"wallet": [
{
"id": "BTC",
"available": "10.000000",
"name": "Bitcoin",
"frozen": "10.000000"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
GET
/account/v1/withdraw/charge
true
{
"message":"OK",
"code":1000,
"trace":"62a80bde-0cb4-4bf1-b8e5-5ad2c71463e7",
"data":{
"today_available_withdraw_BTC":"100.0000",
"min_withdraw":"0.00000000",
"withdraw_precision":8,
"withdraw_fee":"0.00000000",
"withdraw_Precision_GeTen": 10
}
}
5 changes: 0 additions & 5 deletions BitMart.Net.UnitTests/Endpoints/Spot/Account/TODOAsync.txt

This file was deleted.

11 changes: 11 additions & 0 deletions BitMart.Net.UnitTests/Endpoints/Spot/Account/Withdraw.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
POST
/account/v1/withdraw/apply
true
{
"code": 1000,
"trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1",
"message": "OK",
"data": {
"withdraw_id": "121212"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
GET
/account/v1/currencies
false
{
"code": 1000,
"trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1",
"message": "OK",
"data": {
"currencies": [
{
"currency": "USDT",
"name": "Tether USD",
"contract_address": null,
"network": "OMNI",
"withdraw_enabled": false,
"deposit_enabled": false,
"withdraw_minsize": null,
"withdraw_minfee": null
},
{
"currency": "USDT-TRC20",
"name": "USDT-TRC20",
"contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"network": "TRC20",
"withdraw_enabled": true,
"deposit_enabled": true,
"withdraw_minsize": "10",
"withdraw_minfee": "1"
},
{
"currency": "USDT-ERC20",
"name": "USDT-ERC20",
"contract_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"network": "ERC20",
"withdraw_enabled": true,
"deposit_enabled": true,
"withdraw_minsize": "26",
"withdraw_minfee": "13"
},
{
"currency": "USDT-BSC",
"name": "USDT-BSC",
"contract_address": "0x55d398326f99059fF775485246999027B3197955",
"network": "BEP20(BSC)",
"withdraw_enabled": true,
"deposit_enabled": true,
"withdraw_minsize": "2",
"withdraw_minfee": "1"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
GET
/system/service
false
{
"code": 1000,
"trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1",
"message": "OK",
"data": {
"service":[
{
"title": "Spot API Stop",
"service_type": "spot",
"status": "2",
"start_time": 1527777538000,
"end_time": 1527777538000
},
{
"title": "Contract API Stop",
"service_type": "contract",
"status": "2",
"start_time": 1527777538000,
"end_time": 1527777538000
}
]
}
}
23 changes: 23 additions & 0 deletions BitMart.Net.UnitTests/Endpoints/Spot/ExchangeData/GetTicker.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
GET
/spot/quotation/v3/ticker
false
{
"code": 1000,
"trace":"886fb6ae-456b-4654-b4e0-1231",
"message": "success",
"data": {
"symbol": "BTC_USDT",
"last": "30000.00",
"v_24h": "582.08066",
"qv_24h": "4793098.48",
"open_24h": "28596.30",
"high_24h": "31012.44",
"low_24h": "12.44",
"fluctuation": "0.04909",
"bid_px": "30000",
"bid_sz": "1",
"ask_px": "31012.44",
"ask_sz": "69994.75267",
"ts": "1691671061919"
}
}

This file was deleted.

31 changes: 25 additions & 6 deletions BitMart.Net.UnitTests/RestRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,47 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using BitMart.Net.Clients;
using BitMart.Net.Objects;
using System.Linq;

namespace BitMart.Net.UnitTests
{
[TestFixture]
public class RestRequestTests
{
[Test]
public async Task ValidateSpotAccountCalls()
public async Task ValidateSpotAccountDataCalls()
{
var client = new BitMartRestClient(opts =>
{
opts.AutoTimestamp = false;
opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456");
opts.ApiCredentials = new BitMartApiCredentials("123", "456");
});
var tester = new RestRequestValidator<BitMartRestClient>(client, "Endpoints/Spot/Account", "XXX", IsAuthenticated, stjCompare: false);
//await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetServerTimeAsync(), "GetServerTime");

var tester = new RestRequestValidator<BitMartRestClient>(client, "Endpoints/Spot/ACcount", "https://api-cloud.bitmart.com", IsAuthenticated, stjCompare: true);
await tester.ValidateAsync(client => client.SpotApi.Account.GetFundingBalancesAsync("123"), "GetFundingBalances", nestedJsonProperty: "data.wallet");
await tester.ValidateAsync(client => client.SpotApi.Account.GetSpotBalancesAsync(), "GetSpotBalances", nestedJsonProperty: "data.wallet");
await tester.ValidateAsync(client => client.SpotApi.Account.GetDepositAddressAsync("123"), "GetDepositAddress", nestedJsonProperty: "data");
await tester.ValidateAsync(client => client.SpotApi.Account.GetWithdrawalQuotaAsync("ETH"), "GetWithdrawalQuota", nestedJsonProperty: "data");
await tester.ValidateAsync(client => client.SpotApi.Account.WithdrawAsync("123", 0.1m), "Withdraw", nestedJsonProperty: "data");
}

[Test]
public async Task ValidateSpotExchangeDataCalls()
{
var client = new BitMartRestClient(opts =>
{
opts.AutoTimestamp = false;
opts.ApiCredentials = new BitMartApiCredentials("123", "456");
});
var tester = new RestRequestValidator<BitMartRestClient>(client, "Endpoints/Spot/ExchangeData", "https://api-cloud.bitmart.com", IsAuthenticated, stjCompare: true);
await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetTickerAsync("123"), "GetTicker", nestedJsonProperty: "data");
await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetAssetDepositWithdrawInfoAsync(), "GetAssetDepositWithdrawInfo", nestedJsonProperty: "data.currencies");
await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetServerStatusAsync(), "GetServerStatus", nestedJsonProperty: "data.service");
}

private bool IsAuthenticated(WebCallResult result)
{
return result.RequestUrl?.Contains("signature") == true || result.RequestBody?.Contains("signature=") == true;
return result.RequestHeaders.Any(x => x.Key == "X-BM-SIGN");
}
}
}
3 changes: 2 additions & 1 deletion BitMart.Net.UnitTests/SocketSubscriptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using BitMart.Net.Clients;
using BitMart.Net.Objects.Models;
using BitMart.Net.Objects;

namespace BitMart.Net.UnitTests
{
Expand All @@ -14,7 +15,7 @@ public async Task ValidateSpotExchangeDataSubscriptions()
{
var client = new BitMartSocketClient(opts =>
{
opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456");
opts.ApiCredentials = new BitMartApiCredentials("123", "456");
});
var tester = new SocketSubscriptionValidator<BitMartSocketClient>(client, "Subscriptions/Spot/ExchangeData", "XXX", "data", stjCompare: false);
//await tester.ValidateAsync<BitMartModel>((client, handler) => client.SpotApi.SubscribeToXXXUpdatesAsync(handler), "XXX");
Expand Down
4 changes: 3 additions & 1 deletion BitMart.Net/BitMart.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="7.7.2" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CryptoExchange.Net\CryptoExchange.Net\CryptoExchange.Net.csproj" />
</ItemGroup>
</Project>
Loading

0 comments on commit 0b932bf

Please sign in to comment.