diff --git a/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj b/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj index 4857d6e..1e7d9ae 100644 --- a/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj +++ b/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj @@ -7,10 +7,10 @@ - - - - + + + + diff --git a/Bitfinex.Net.UnitTests/BitfinexClientTests.cs b/Bitfinex.Net.UnitTests/BitfinexClientTests.cs index 2e52db5..67527f0 100644 --- a/Bitfinex.Net.UnitTests/BitfinexClientTests.cs +++ b/Bitfinex.Net.UnitTests/BitfinexClientTests.cs @@ -15,6 +15,7 @@ using Bitfinex.Net.Clients; using Bitfinex.Net.ExtensionMethods; using CryptoExchange.Net.Objects.Sockets; +using NUnit.Framework.Legacy; namespace Bitfinex.Net.UnitTests { @@ -31,9 +32,9 @@ public async Task ReceivingHttpError_Should_ResultInErrorResult() var result = await client.SpotApi.ExchangeData.GetAssetFullNamesAsync(); // assert - Assert.AreEqual(false, result.Success); - Assert.IsTrue(result.Error.ToString().Contains("Error message")); - Assert.AreEqual(HttpStatusCode.BadRequest, result.ResponseStatusCode); + Assert.That(false == result.Success); + Assert.That(result.Error.ToString().Contains("Error message")); + Assert.That(HttpStatusCode.BadRequest == result.ResponseStatusCode); } @@ -45,7 +46,7 @@ public void ProvidingApiCredentials_Should_SaveApiCredentials() var authProvider = new BitfinexAuthenticationProvider(new ApiCredentials("TestKey", "TestSecret"), null); // assert - Assert.AreEqual(authProvider.GetApiKey(), "TestKey"); + Assert.That(authProvider.GetApiKey() == "TestKey"); } [Test] @@ -58,7 +59,7 @@ public void SigningString_Should_ReturnCorrectString() string signed = authProvider.Sign("SomeTestString"); // assert - Assert.AreEqual(signed, "9052C73092B21B945BC5859CADBA6A5658E142F021FCB092A72F68E8A0D5E6351CFEBAE52DB9067D4360F796CB520960"); + Assert.That(signed == "9052C73092B21B945BC5859CADBA6A5658E142F021FCB092A72F68E8A0D5E6351CFEBAE52DB9067D4360F796CB520960"); } [Test] @@ -112,7 +113,7 @@ public void CheckRestInterfaces() foreach (var method in implementation.GetMethods().Where(m => m.ReturnType.IsAssignableTo(typeof(Task)))) { var interfaceMethod = clientInterface.GetMethod(method.Name, method.GetParameters().Select(p => p.ParameterType).ToArray()); - Assert.NotNull(interfaceMethod, $"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}"); + ClassicAssert.NotNull(interfaceMethod, $"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}"); methods++; } Debug.WriteLine($"{clientInterface.Name} {methods} methods validated"); @@ -132,7 +133,7 @@ public void CheckSocketInterfaces() foreach (var method in implementation.GetMethods().Where(m => m.ReturnType.IsAssignableTo(typeof(Task>)))) { var interfaceMethod = clientInterface.GetMethod(method.Name, method.GetParameters().Select(p => p.ParameterType).ToArray()); - Assert.NotNull(interfaceMethod, $"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}"); + ClassicAssert.NotNull(interfaceMethod, $"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}"); methods++; } Debug.WriteLine($"{clientInterface.Name} {methods} methods validated"); diff --git a/Bitfinex.Net.UnitTests/BitfinexSocketClientTests.cs b/Bitfinex.Net.UnitTests/BitfinexSocketClientTests.cs index 8eca51f..3f889c1 100644 --- a/Bitfinex.Net.UnitTests/BitfinexSocketClientTests.cs +++ b/Bitfinex.Net.UnitTests/BitfinexSocketClientTests.cs @@ -19,6 +19,7 @@ using Bitfinex.Net.Objects.Models.Socket; using System.Diagnostics; using Bitfinex.Net.Objects.Sockets; +using NUnit.Framework.Legacy; namespace Bitfinex.Net.UnitTests { @@ -56,12 +57,12 @@ public async Task SubscribingToBookUpdates_Should_SubscribeSuccessfully(Precisio }; // act - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); var taskResult = await subTask.ConfigureAwait(false); // assert - Assert.IsTrue(taskResult.Success); + Assert.That(taskResult.Success); } [TestCase(Precision.PrecisionLevel0, Frequency.Realtime)] @@ -72,7 +73,7 @@ public async Task SubscribingToBookUpdates_Should_SubscribeSuccessfully(Precisio [TestCase(Precision.PrecisionLevel1, Frequency.TwoSeconds)] [TestCase(Precision.PrecisionLevel2, Frequency.TwoSeconds)] [TestCase(Precision.PrecisionLevel3, Frequency.TwoSeconds)] - public async Task SubscribingToBookUpdates_Should_TriggerWithBookUpdate(Precision prec, Frequency freq) + public void SubscribingToBookUpdates_Should_TriggerWithBookUpdate(Precision prec, Frequency freq) { // arrange var socket = new TestSocket(); @@ -93,15 +94,15 @@ public async Task SubscribingToBookUpdates_Should_TriggerWithBookUpdate(Precisio Precision = JsonConvert.SerializeObject(prec, new PrecisionConverter(false)), Symbol = "tBTCUSD" }; - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); subTask.Wait(5000); BitfinexOrderBookEntry[] expected = new[] { new BitfinexOrderBookEntry() { RawPrice = "1", RawQuantity = "2", Count = 3, Price = 1, Quantity = 2 } }; // act - await socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); + socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); // assert - Assert.IsTrue(TestHelpers.AreEqual(result[0], expected[0])); + Assert.That(TestHelpers.AreEqual(result[0], expected[0])); } [TestCase(KlineInterval.OneMinute)] @@ -115,7 +116,7 @@ public async Task SubscribingToBookUpdates_Should_TriggerWithBookUpdate(Precisio [TestCase(KlineInterval.OneDay)] [TestCase(KlineInterval.SevenDays)] [TestCase(KlineInterval.FourteenDays)] - public async Task SubscribingToCandleUpdates_Should_SubscribeSuccessfully(KlineInterval timeframe) + public void SubscribingToCandleUpdates_Should_SubscribeSuccessfully(KlineInterval timeframe) { // arrange var socket = new TestSocket(); @@ -133,12 +134,12 @@ public async Task SubscribingToCandleUpdates_Should_SubscribeSuccessfully(KlineI }; // act - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); subTask.Wait(5000); // assert - Assert.IsTrue(subTask.Result.Success); + Assert.That(subTask.Result.Success); } [TestCase(KlineInterval.OneMinute)] @@ -152,7 +153,7 @@ public async Task SubscribingToCandleUpdates_Should_SubscribeSuccessfully(KlineI [TestCase(KlineInterval.OneDay)] [TestCase(KlineInterval.SevenDays)] [TestCase(KlineInterval.FourteenDays)] - public async Task SubscribingToCandleUpdates_Should_TriggerWithCandleUpdate(KlineInterval timeframe) + public void SubscribingToCandleUpdates_Should_TriggerWithCandleUpdate(KlineInterval timeframe) { // arrange var socket = new TestSocket(); @@ -169,19 +170,19 @@ public async Task SubscribingToCandleUpdates_Should_TriggerWithCandleUpdate(Klin ChannelId = 1, Key = "trade:" + JsonConvert.SerializeObject(timeframe, new KlineIntervalConverter(false)) + ":tBTCUSD" }; - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); subTask.Wait(5000); BitfinexKline[] expected = new[] { new BitfinexKline() }; // act - await socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); + socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); // assert - Assert.IsTrue(TestHelpers.AreEqual(result[0], expected[0])); + Assert.That(TestHelpers.AreEqual(result[0], expected[0])); } [Test] - public async Task SubscribingToTickerUpdates_Should_SubscribeSuccessfully() + public void SubscribingToTickerUpdates_Should_SubscribeSuccessfully() { // arrange var socket = new TestSocket(); @@ -200,16 +201,16 @@ public async Task SubscribingToTickerUpdates_Should_SubscribeSuccessfully() }; // act - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); subTask.Wait(5000); // assert - Assert.IsTrue(subTask.Result.Success); + Assert.That(subTask.Result.Success); } [Test] - public async Task SubscribingToTickerUpdates_Should_TriggerWithTickerUpdate() + public void SubscribingToTickerUpdates_Should_TriggerWithTickerUpdate() { // arrange var socket = new TestSocket(); @@ -227,19 +228,19 @@ public async Task SubscribingToTickerUpdates_Should_TriggerWithTickerUpdate() Symbol = "tBTCUSD", Pair = "BTCUSD" }; - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); subTask.Wait(5000); BitfinexStreamTicker expected = new BitfinexStreamTicker(); // act - await socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); + socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); // assert - Assert.IsTrue(TestHelpers.AreEqual(result, expected)); + Assert.That(TestHelpers.AreEqual(result, expected)); } [Test] - public async Task SubscribingToRawBookUpdates_Should_SubscribeSuccessfully() + public void SubscribingToRawBookUpdates_Should_SubscribeSuccessfully() { // arrange var socket = new TestSocket(); @@ -261,16 +262,16 @@ public async Task SubscribingToRawBookUpdates_Should_SubscribeSuccessfully() }; // act - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); subTask.Wait(5000); // assert - Assert.IsTrue(subTask.Result.Success); + Assert.That(subTask.Result.Success); } [Test] - public async Task SubscribingToRawBookUpdates_Should_TriggerWithRawBookUpdate() + public void SubscribingToRawBookUpdates_Should_TriggerWithRawBookUpdate() { // arrange var socket = new TestSocket(); @@ -291,19 +292,19 @@ public async Task SubscribingToRawBookUpdates_Should_TriggerWithRawBookUpdate() Precision = "R0", Length = 10 }; - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); subTask.Wait(5000); BitfinexRawOrderBookEntry[] expected = new []{ new BitfinexRawOrderBookEntry()}; // act - await socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); + socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); // assert - Assert.IsTrue(TestHelpers.AreEqual(result[0], expected[0])); + Assert.That(TestHelpers.AreEqual(result[0], expected[0])); } [Test] - public async Task SubscribingToTradeUpdates_Should_SubscribeSuccessfully() + public void SubscribingToTradeUpdates_Should_SubscribeSuccessfully() { // arrange var socket = new TestSocket(); @@ -322,16 +323,16 @@ public async Task SubscribingToTradeUpdates_Should_SubscribeSuccessfully() }; // act - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); subTask.Wait(5000); // assert - Assert.IsTrue(subTask.Result.Success); + Assert.That(subTask.Result.Success); } [Test] - public async Task SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() + public void SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() { // arrange var socket = new TestSocket(); @@ -349,15 +350,15 @@ public async Task SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() Symbol = "BTCUSD", Pair = "BTCUSD" }; - await socket.InvokeMessage(subResponse); + socket.InvokeMessage(subResponse); subTask.Wait(5000); BitfinexTradeSimple[] expected = new[] { new BitfinexTradeSimple() }; // act - await socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); + socket.InvokeMessage($"[1, {JsonConvert.SerializeObject(expected)}]"); // assert - Assert.IsTrue(TestHelpers.AreEqual(result[0], expected[0])); + Assert.That(TestHelpers.AreEqual(result[0], expected[0])); } //[TestCase("ou", BitfinexEventType.OrderUpdate)] @@ -386,7 +387,7 @@ public async Task SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() // rstEvent.WaitOne(1000); // // assert - // Assert.IsTrue(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); + // Assert.That(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); //} //[TestCase("te", BitfinexEventType.TradeExecuted)] @@ -414,7 +415,7 @@ public async Task SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() // rstEvent.WaitOne(1000); // // assert - // Assert.IsTrue(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); + // Assert.That(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); //} //[TestCase("ws", BitfinexEventType.WalletSnapshot, false)] @@ -441,7 +442,7 @@ public async Task SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() // rstEvent.WaitOne(1000); // // assert - // Assert.IsTrue(TestHelpers.AreEqual(result.Data.First(), expected.Data.First())); + // Assert.That(TestHelpers.AreEqual(result.Data.First(), expected.Data.First())); //} //[TestCase("pn", BitfinexEventType.PositionNew)] @@ -470,7 +471,7 @@ public async Task SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() // rstEvent.WaitOne(1000); // // assert - // Assert.IsTrue(TestHelpers.AreEqual(result.Data.First(), expected.Data.First())); + // Assert.That(TestHelpers.AreEqual(result.Data.First(), expected.Data.First())); //} //[TestCase("fcn", BitfinexEventType.FundingCreditsNew)] @@ -499,7 +500,7 @@ public async Task SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() // rstEvent.WaitOne(1000); // // assert - // Assert.IsTrue(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); + // Assert.That(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); //} //[TestCase("fln", BitfinexEventType.FundingLoanNew)] @@ -528,7 +529,7 @@ public async Task SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() // rstEvent.WaitOne(1000); // // assert - // Assert.IsTrue(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); + // Assert.That(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); //} //[TestCase("fon", BitfinexEventType.FundingOfferNew)] @@ -557,11 +558,11 @@ public async Task SubscribingToTradeUpdates_Should_TriggerWithTradeUpdate() // rstEvent.WaitOne(1000); // // assert - // Assert.IsTrue(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); + // Assert.That(TestHelpers.AreEqual(result.Data.First(), expected.Data[0])); //} [Test] - public async Task PlacingAnOrder_Should_SucceedIfSuccessResponse() + public void PlacingAnOrder_Should_SucceedIfSuccessResponse() { // arrange var socket = new TestSocket(); @@ -580,18 +581,18 @@ public async Task PlacingAnOrder_Should_SucceedIfSuccessResponse() // act var placeTask = client.SpotApi.PlaceOrderAsync(OrderSide.Buy, OrderType.ExchangeLimit, "tBTCUSD", 1, price: 1, clientOrderId: 1234); - await socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); + socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); Thread.Sleep(100); - await socket.InvokeMessage($"[0, \"n\", [0, \"on-req\", 0, 0, {JsonConvert.SerializeObject(expected)}, 0, \"SUCCESS\", \"Submitted\"]]"); + socket.InvokeMessage($"[0, \"n\", [0, \"on-req\", 0, 0, {JsonConvert.SerializeObject(expected)}, 0, \"SUCCESS\", \"Submitted\"]]"); var result = placeTask.Result; // assert - Assert.IsTrue(result.Success); - Assert.IsTrue(TestHelpers.AreEqual(expected, result.Data)); + Assert.That(result.Success); + Assert.That(TestHelpers.AreEqual(expected, result.Data)); } [Test] - public async Task PlacingAnOrder_Should_FailIfErrorResponse() + public void PlacingAnOrder_Should_FailIfErrorResponse() { // arrange var socket = new TestSocket(); @@ -601,18 +602,18 @@ public async Task PlacingAnOrder_Should_FailIfErrorResponse() // act var placeTask = client.SpotApi.PlaceOrderAsync(OrderSide.Buy, OrderType.ExchangeLimit, "tBTCUSD", 1, price: 1, clientOrderId: 123); - await socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); + socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); Thread.Sleep(100); - await socket.InvokeMessage($"[0, \"n\", [0, \"on-req\", 0, 0, {JsonConvert.SerializeObject(order)}, 0, \"error\", \"order placing failed\"]]"); + socket.InvokeMessage($"[0, \"n\", [0, \"on-req\", 0, 0, {JsonConvert.SerializeObject(order)}, 0, \"error\", \"order placing failed\"]]"); var result = placeTask.Result; // assert - Assert.IsFalse(result.Success); - Assert.IsTrue(result.Error.Message.Contains("order placing failed")); + ClassicAssert.IsFalse(result.Success); + Assert.That(result.Error.Message.Contains("order placing failed")); } [Test] - public async Task PlacingAnOrder_Should_FailIfNoResponse() + public void PlacingAnOrder_Should_FailIfNoResponse() { // arrange var socket = new TestSocket(); @@ -625,15 +626,15 @@ public async Task PlacingAnOrder_Should_FailIfNoResponse() // act var placeTask = client.SpotApi.PlaceOrderAsync(OrderSide.Buy, OrderType.ExchangeLimit, "tBTCUSD", 1, price: 1, clientOrderId: 123); - await socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Message = "OK" }); + socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Message = "OK" }); var result = placeTask.Result; // assert - Assert.IsFalse(result.Success); + ClassicAssert.IsFalse(result.Success); } [Test] - public async Task PlacingAnMarketOrder_Should_SucceedIfSuccessResponse() + public void PlacingAnMarketOrder_Should_SucceedIfSuccessResponse() { // arrange var socket = new TestSocket(); @@ -652,18 +653,18 @@ public async Task PlacingAnMarketOrder_Should_SucceedIfSuccessResponse() // act var placeTask = client.SpotApi.PlaceOrderAsync(OrderSide.Buy, OrderType.ExchangeMarket, "tBTCUSD", 1, price: 1, clientOrderId: 1234); - await socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); + socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); Thread.Sleep(100); - await socket.InvokeMessage($"[0, \"n\", [0, \"on-req\", 0, 0, {JsonConvert.SerializeObject(expected)}, 0, \"SUCCESS\", \"Submitted\"]]"); + socket.InvokeMessage($"[0, \"n\", [0, \"on-req\", 0, 0, {JsonConvert.SerializeObject(expected)}, 0, \"SUCCESS\", \"Submitted\"]]"); var result = placeTask.Result; // assert - Assert.IsTrue(result.Success); - Assert.IsTrue(TestHelpers.AreEqual(expected, result.Data)); + Assert.That(result.Success); + Assert.That(TestHelpers.AreEqual(expected, result.Data)); } [Test] - public async Task PlacingAnFOKOrder_Should_SucceedIfSuccessResponse() + public void PlacingAnFOKOrder_Should_SucceedIfSuccessResponse() { // arrange var socket = new TestSocket(); @@ -682,18 +683,18 @@ public async Task PlacingAnFOKOrder_Should_SucceedIfSuccessResponse() // act var placeTask = client.SpotApi.PlaceOrderAsync(OrderSide.Buy, OrderType.ExchangeFillOrKill, "tBTCUSD", 1, price: 1, clientOrderId: 1234); - await socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); + socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); Thread.Sleep(100); - await socket.InvokeMessage($"[0, \"n\", [0, \"on-req\", 0, 0, {JsonConvert.SerializeObject(expected)}, 0, \"SUCCESS\", \"Submitted\"]]"); + socket.InvokeMessage($"[0, \"n\", [0, \"on-req\", 0, 0, {JsonConvert.SerializeObject(expected)}, 0, \"SUCCESS\", \"Submitted\"]]"); var result = placeTask.Result; // assert - Assert.IsTrue(result.Success); - Assert.IsTrue(TestHelpers.AreEqual(expected, result.Data)); + Assert.That(result.Success); + Assert.That(TestHelpers.AreEqual(expected, result.Data)); } [Test] - public async Task PlacingAnFundingOffer_Should_SucceedIfSuccessResponse() + public void PlacingAnFundingOffer_Should_SucceedIfSuccessResponse() { // arrange var socket = new TestSocket(); @@ -712,14 +713,14 @@ public async Task PlacingAnFundingOffer_Should_SucceedIfSuccessResponse() // act var placeTask = client.SpotApi.SubmitFundingOfferAsync(FundingOfferType.Limit, "fUSD", 1, 1, 1); - await socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); + socket.InvokeMessage(new BitfinexResponse() { Event = "auth", Status = "OK" }); Thread.Sleep(100); - await socket.InvokeMessage($"[0, \"n\", [0, \"fon-req\", 0, 0, {JsonConvert.SerializeObject(expected)}, 0, \"SUCCESS\", \"Submitted\"]]"); + socket.InvokeMessage($"[0, \"n\", [0, \"fon-req\", 0, 0, {JsonConvert.SerializeObject(expected)}, 0, \"SUCCESS\", \"Submitted\"]]"); var result = placeTask.Result; // assert - Assert.IsTrue(result.Success); - Assert.IsTrue(TestHelpers.AreEqual(expected, result.Data)); + Assert.That(result.Success); + Assert.That(TestHelpers.AreEqual(expected, result.Data)); } @@ -737,7 +738,7 @@ public async Task ReceivingAReconnectMessage_Should_ReconnectWebsocket() var rstEvent = new ManualResetEvent(false); var subTask = client.SpotApi.SubscribeToKlineUpdatesAsync("tBTCUSD", KlineInterval.FiveMinutes, data => { }); - await socket.InvokeMessage(new CandleSubscriptionResponse() + socket.InvokeMessage(new CandleSubscriptionResponse() { Channel = "candles", Event = "subscribed", @@ -749,9 +750,9 @@ await socket.InvokeMessage(new CandleSubscriptionResponse() subResult.Data.ConnectionRestored += (t) => rstEvent.Set(); // act - await socket.InvokeMessage("{\"event\":\"info\", \"code\": 20051}"); + socket.InvokeMessage("{\"event\":\"info\", \"code\": 20051}"); Thread.Sleep(100); - await socket.InvokeMessage(new CandleSubscriptionResponse() + socket.InvokeMessage(new CandleSubscriptionResponse() { Channel = "candles", Event = "subscribed", @@ -762,7 +763,7 @@ await socket.InvokeMessage(new CandleSubscriptionResponse() var triggered = rstEvent.WaitOne(1000); // assert - Assert.IsTrue(triggered); + Assert.That(triggered); } // TODO FIX TIMING ISSUE @@ -811,7 +812,7 @@ await socket.InvokeMessage(new CandleSubscriptionResponse() // rstEvent.WaitOne(1000); // // assert - // Assert.IsTrue(subResultWhenPaused?.Error?.Message.Contains("Socket is paused")); + // Assert.That(subResultWhenPaused?.Error?.Message.Contains("Socket is paused")); //} } } diff --git a/Bitfinex.Net.UnitTests/JsonToObjectComparer.cs b/Bitfinex.Net.UnitTests/JsonToObjectComparer.cs index a7ede63..995324d 100644 --- a/Bitfinex.Net.UnitTests/JsonToObjectComparer.cs +++ b/Bitfinex.Net.UnitTests/JsonToObjectComparer.cs @@ -1,9 +1,11 @@ using Bitfinex.Net.UnitTests.TestImplementations; using CryptoExchange.Net.Converters; +using CryptoExchange.Net.Converters.JsonNet; using CryptoExchange.Net.Objects; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NUnit.Framework; +using NUnit.Framework.Legacy; using System; using System.Collections; using System.Collections.Generic; @@ -82,7 +84,7 @@ public async Task ProcessSubject( var result = (CallResult)await TestHelpers.InvokeAsync(method, getSubject(client), input.ToArray()); // asset - Assert.Null(result.Error, method.Name); + ClassicAssert.Null(result.Error, method.Name); var resultData = result.GetType().GetProperty("Data", BindingFlags.Public | BindingFlags.Instance).GetValue(result); ProcessData(method.Name, resultData, json, parametersToSetNull, useNestedJsonPropertyForCompare, ignoreProperties, takeFirstItemForCompare); @@ -216,10 +218,8 @@ private static void CheckObject(string method, JProperty prop, object obj, Dicti // Property has a value var property = resultProperties.SingleOrDefault(p => p.Item2?.PropertyName == prop.Name).p; - if (property is null) - property = resultProperties.SingleOrDefault(p => p.p.Name == prop.Name).p; - if (property is null) - property = resultProperties.SingleOrDefault(p => p.p.Name.ToUpperInvariant() == prop.Name.ToUpperInvariant()).p; + property ??= resultProperties.SingleOrDefault(p => p.p.Name == prop.Name).p; + property ??= resultProperties.SingleOrDefault(p => p.p.Name.ToUpperInvariant() == prop.Name.ToUpperInvariant()).p; if (property is null) { @@ -331,7 +331,9 @@ private static void CheckPropertyValue(string method, JToken propValue, object p { if (info.GetCustomAttribute(true) == null && info.GetCustomAttribute(true)?.ItemConverterType == null) + { CheckValues(method, propertyName, (JValue)propValue, propertyValue); + } } } } @@ -370,7 +372,9 @@ private static void CheckValues(string method, string property, JValue jsonValue // timestamp, hard to check.. } else if (jsonValue.Value().ToLowerInvariant() != objectValue.ToString().ToLowerInvariant()) + { throw new Exception($"{method}: {property} not equal: {jsonValue.Value()} vs {objectValue.ToString()}"); + } } else if (jsonValue.Type == JTokenType.Integer) { diff --git a/Bitfinex.Net.UnitTests/TestImplementations/TestSocket.cs b/Bitfinex.Net.UnitTests/TestImplementations/TestSocket.cs index 4495d57..90227a7 100644 --- a/Bitfinex.Net.UnitTests/TestImplementations/TestSocket.cs +++ b/Bitfinex.Net.UnitTests/TestImplementations/TestSocket.cs @@ -21,7 +21,7 @@ public class TestSocket: IWebsocket public event Func OnReconnecting; #pragma warning restore 0067 public event Func OnRequestSent; - public event Func OnStreamMessage; + public event Action> OnStreamMessage; public event Func OnError; public event Func OnOpen; @@ -100,16 +100,14 @@ public void InvokeOpen() OnOpen?.Invoke(); } - public async Task InvokeMessage(string data) + public void InvokeMessage(string data) { - var stream = new MemoryStream(Encoding.UTF8.GetBytes(data)); - await OnStreamMessage?.Invoke(WebSocketMessageType.Text, stream); + OnStreamMessage?.Invoke(WebSocketMessageType.Text, new ReadOnlyMemory(Encoding.UTF8.GetBytes(data))); } - public async Task InvokeMessage(T data) + public void InvokeMessage(T data) { - var stream = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(data))); - await OnStreamMessage?.Invoke(WebSocketMessageType.Text, stream); + OnStreamMessage?.Invoke(WebSocketMessageType.Text, new ReadOnlyMemory(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(data)))); } public void InvokeError(Exception error) diff --git a/Bitfinex.Net/Bitfinex.Net.csproj b/Bitfinex.Net/Bitfinex.Net.csproj index f1e67ba..f0a2b6a 100644 --- a/Bitfinex.Net/Bitfinex.Net.csproj +++ b/Bitfinex.Net/Bitfinex.Net.csproj @@ -2,14 +2,14 @@ netstandard2.0;netstandard2.1 enable - 8.0 + 10.0 Bitfinex.Net JKorf - 7.1.0 - 7.1.0 - 7.1.0 + 7.2.0 + 7.2.0 + 7.2.0 Bitfinex.Net is a client library for accessing the Bitfinex REST and Websocket API. All data is mapped to readable models and enum values. Additional features include an implementation for maintaining a client side order book, easy integration with other exchange client libraries and more. false Bitfinex;Bitfinex.Net;Bitfinex Client;Bitfinex API;CryptoCurrency;CryptoCurrency Exchange @@ -47,14 +47,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - all runtime; build; native; contentfiles; analyzers; buildtransitive + \ No newline at end of file diff --git a/Bitfinex.Net/Bitfinex.Net.xml b/Bitfinex.Net/Bitfinex.Net.xml index d19a2c9..05b36f9 100644 --- a/Bitfinex.Net/Bitfinex.Net.xml +++ b/Bitfinex.Net/Bitfinex.Net.xml @@ -111,7 +111,7 @@ - + @@ -216,7 +216,7 @@ - + @@ -522,7 +522,7 @@ - + @@ -5356,10 +5356,10 @@ Spot API options - + - + diff --git a/Bitfinex.Net/BitfinexAuthenticationProvider.cs b/Bitfinex.Net/BitfinexAuthenticationProvider.cs index 7f4a3aa..adeb310 100644 --- a/Bitfinex.Net/BitfinexAuthenticationProvider.cs +++ b/Bitfinex.Net/BitfinexAuthenticationProvider.cs @@ -6,6 +6,7 @@ using Bitfinex.Net.Objects.Internal; using CryptoExchange.Net; using CryptoExchange.Net.Authentication; +using CryptoExchange.Net.Clients; using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Objects; using Newtonsoft.Json; @@ -27,7 +28,7 @@ public BitfinexAuthenticationProvider(ApiCredentials credentials, INonceProvider _nonceProvider = nonceProvider ?? new BitfinexNonceProvider(); } - public override void AuthenticateRequest(RestApiClient apiClient, Uri uri, HttpMethod method, Dictionary providedParameters, bool auth, ArrayParametersSerialization arraySerialization, HttpMethodParameterPosition parameterPosition, out SortedDictionary uriParameters, out SortedDictionary bodyParameters, out Dictionary headers) + public override void AuthenticateRequest(RestApiClient apiClient, Uri uri, HttpMethod method, Dictionary providedParameters, bool auth, ArrayParametersSerialization arraySerialization, HttpMethodParameterPosition parameterPosition, RequestBodyFormat bodyFormat, out SortedDictionary uriParameters, out SortedDictionary bodyParameters, out Dictionary headers) { uriParameters = parameterPosition == HttpMethodParameterPosition.InUri ? new SortedDictionary(providedParameters) : new SortedDictionary(); bodyParameters = parameterPosition == HttpMethodParameterPosition.InBody ? new SortedDictionary(providedParameters) : new SortedDictionary(); diff --git a/Bitfinex.Net/Clients/BitfinexRestClient.cs b/Bitfinex.Net/Clients/BitfinexRestClient.cs index b551086..1fbe54d 100644 --- a/Bitfinex.Net/Clients/BitfinexRestClient.cs +++ b/Bitfinex.Net/Clients/BitfinexRestClient.cs @@ -1,5 +1,4 @@ -using CryptoExchange.Net; -using System; +using System; using Bitfinex.Net.Interfaces.Clients; using Bitfinex.Net.Interfaces.Clients.SpotApi; using Bitfinex.Net.Interfaces.Clients.GeneralApi; @@ -10,6 +9,7 @@ using System.Net.Http; using Bitfinex.Net.Objects.Options; using Microsoft.Extensions.DependencyInjection; +using CryptoExchange.Net.Clients; namespace Bitfinex.Net.Clients { diff --git a/Bitfinex.Net/Clients/BitfinexSocketClient.cs b/Bitfinex.Net/Clients/BitfinexSocketClient.cs index 547e82a..c891e03 100644 --- a/Bitfinex.Net/Clients/BitfinexSocketClient.cs +++ b/Bitfinex.Net/Clients/BitfinexSocketClient.cs @@ -1,11 +1,11 @@ -using CryptoExchange.Net; -using System; +using System; using Microsoft.Extensions.Logging; using Bitfinex.Net.Interfaces.Clients; using Bitfinex.Net.Interfaces.Clients.SpotApi; using Bitfinex.Net.Clients.SpotApi; using CryptoExchange.Net.Authentication; using Bitfinex.Net.Objects.Options; +using CryptoExchange.Net.Clients; namespace Bitfinex.Net.Clients { diff --git a/Bitfinex.Net/Clients/GeneralApi/BitfinexRestClientGeneralApi.cs b/Bitfinex.Net/Clients/GeneralApi/BitfinexRestClientGeneralApi.cs index 865f445..b9216d7 100644 --- a/Bitfinex.Net/Clients/GeneralApi/BitfinexRestClientGeneralApi.cs +++ b/Bitfinex.Net/Clients/GeneralApi/BitfinexRestClientGeneralApi.cs @@ -3,6 +3,9 @@ using Bitfinex.Net.Objects.Options; using CryptoExchange.Net; using CryptoExchange.Net.Authentication; +using CryptoExchange.Net.Clients; +using CryptoExchange.Net.Converters.MessageParsing; +using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Objects; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; @@ -59,24 +62,35 @@ internal Uri GetUrl(string endpoint, string version) } /// - protected override Error ParseErrorResponse(int httpStatusCode, IEnumerable>> responseHeaders, string data) + protected override Error ParseErrorResponse(int httpStatusCode, IEnumerable>> responseHeaders, IMessageAccessor accessor) { - var errorData = ValidateJson(data); - if (!errorData) - return new ServerError(data); + if (!accessor.IsJson) + return new ServerError(accessor.GetOriginalString()); - if (!(errorData.Data is JArray)) + if (accessor.GetNodeType() != NodeType.Array) { - if (errorData.Data["error"] != null && errorData.Data["code"] != null && errorData.Data["error_description"] != null) - return new ServerError((int)errorData.Data["code"]!, errorData.Data["error"] + ": " + errorData.Data["error_description"]); - if (errorData.Data["message"] != null) - return new ServerError(errorData.Data["message"]!.ToString()); - else - return new ServerError(errorData.Data.ToString()); + var error = accessor.GetValue(MessagePath.Get().Property("error")); + var errorCode = accessor.GetValue(MessagePath.Get().Property("code")); + var errorDesc = accessor.GetValue(MessagePath.Get().Property("error_description")); + if (error != null && errorCode != null && errorDesc != null) + return new ServerError(errorCode.Value, $"{error}: {errorDesc}"); + + var message = accessor.GetValue(MessagePath.Get().Property("message")); + if (message != null) + return new ServerError(message); + + return new ServerError(accessor.GetOriginalString()); } - var error = errorData.Data.ToObject(); - return new ServerError(error!.ErrorCode, error.ErrorMessage); + var code = accessor.GetValue(MessagePath.Get().Index(1)); + var msg = accessor.GetValue(MessagePath.Get().Index(2)); + if (msg == null) + return new ServerError(accessor.GetOriginalString()); + + if (code == null) + return new ServerError(msg); + + return new ServerError(code.Value, msg); } /// diff --git a/Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApi.cs b/Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApi.cs index e3281f0..80d611c 100644 --- a/Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApi.cs +++ b/Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApi.cs @@ -4,7 +4,10 @@ using Bitfinex.Net.Objects.Options; using CryptoExchange.Net; using CryptoExchange.Net.Authentication; +using CryptoExchange.Net.Clients; using CryptoExchange.Net.CommonObjects; +using CryptoExchange.Net.Converters.MessageParsing; +using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Interfaces.CommonClients; using CryptoExchange.Net.Objects; using Microsoft.Extensions.Logging; @@ -419,24 +422,35 @@ async Task>> IBaseRestClient.GetBalancesAsync #endregion /// - protected override Error ParseErrorResponse(int httpStatusCode, IEnumerable>> responseHeaders, string data) + protected override Error ParseErrorResponse(int httpStatusCode, IEnumerable>> responseHeaders, IMessageAccessor accessor) { - var errorData = ValidateJson(data); - if (!errorData) - return new ServerError(data); + if (!accessor.IsJson) + return new ServerError(accessor.GetOriginalString()); - if (!(errorData.Data is JArray)) + if (accessor.GetNodeType() != NodeType.Array) { - if (errorData.Data["error"] != null && errorData.Data["code"] != null && errorData.Data["error_description"] != null) - return new ServerError((int)errorData.Data["code"]!, errorData.Data["error"] + ": " + errorData.Data["error_description"]); - if (errorData.Data["message"] != null) - return new ServerError(errorData.Data["message"]!.ToString()); - else - return new ServerError(errorData.Data.ToString()); + var error = accessor.GetValue(MessagePath.Get().Property("error")); + var errorCode = accessor.GetValue(MessagePath.Get().Property("code")); + var errorDesc = accessor.GetValue(MessagePath.Get().Property("error_description")); + if (error != null && errorCode != null && errorDesc != null) + return new ServerError(errorCode.Value, $"{error}: {errorDesc}"); + + var message = accessor.GetValue(MessagePath.Get().Property("message")); + if (message != null) + return new ServerError(message); + + return new ServerError(accessor.GetOriginalString()); } - var error = errorData.Data.ToObject(); - return new ServerError(error!.ErrorCode, error.ErrorMessage); + var code = accessor.GetValue(MessagePath.Get().Index(1)); + var msg = accessor.GetValue(MessagePath.Get().Index(2)); + if (msg == null) + return new ServerError(accessor.GetOriginalString()); + + if (code == null) + return new ServerError(msg); + + return new ServerError(code.Value, msg); } } } diff --git a/Bitfinex.Net/Clients/SpotApi/BitfinexSocketClientSpotApi.cs b/Bitfinex.Net/Clients/SpotApi/BitfinexSocketClientSpotApi.cs index 32961ac..20b16d7 100644 --- a/Bitfinex.Net/Clients/SpotApi/BitfinexSocketClientSpotApi.cs +++ b/Bitfinex.Net/Clients/SpotApi/BitfinexSocketClientSpotApi.cs @@ -21,9 +21,10 @@ using CryptoExchange.Net.Sockets; using System.Globalization; using Bitfinex.Net.Objects.Sockets.Queries; -using CryptoExchange.Net.Sockets.MessageParsing; -using CryptoExchange.Net.Sockets.MessageParsing.Interfaces; using Bitfinex.Net.ExtensionMethods; +using CryptoExchange.Net.Interfaces; +using CryptoExchange.Net.Converters.MessageParsing; +using CryptoExchange.Net.Clients; namespace Bitfinex.Net.Clients.SpotApi { diff --git a/Bitfinex.Net/Objects/Sockets/Queries/BitfinexAuthQuery.cs b/Bitfinex.Net/Objects/Sockets/Queries/BitfinexAuthQuery.cs index 65722c3..e521312 100644 --- a/Bitfinex.Net/Objects/Sockets/Queries/BitfinexAuthQuery.cs +++ b/Bitfinex.Net/Objects/Sockets/Queries/BitfinexAuthQuery.cs @@ -15,12 +15,12 @@ public BitfinexAuthQuery(BitfinexAuthentication authRequest) : base(authRequest, { } - public override Task> HandleMessageAsync(SocketConnection connection, DataEvent message) + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) { if (message.Data.Status != "OK") - return Task.FromResult(new CallResult(new ServerError(message.Data.Code!.Value, message.Data.Message!))); + return new CallResult(new ServerError(message.Data.Code!.Value, message.Data.Message!)); - return Task.FromResult(new CallResult(message.Data, message.OriginalData, null)); + return new CallResult(message.Data, message.OriginalData, null); } } } diff --git a/Bitfinex.Net/Objects/Sockets/Queries/BitfinexQuery.cs b/Bitfinex.Net/Objects/Sockets/Queries/BitfinexQuery.cs index 4845f72..d2612ec 100644 --- a/Bitfinex.Net/Objects/Sockets/Queries/BitfinexQuery.cs +++ b/Bitfinex.Net/Objects/Sockets/Queries/BitfinexQuery.cs @@ -1,10 +1,10 @@ using Bitfinex.Net.Objects.Internal; using Bitfinex.Net.Objects.Models.Socket; +using CryptoExchange.Net.Converters.MessageParsing; +using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Sockets; -using CryptoExchange.Net.Sockets.MessageParsing; -using CryptoExchange.Net.Sockets.MessageParsing.Interfaces; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -28,12 +28,12 @@ public BitfinexQuery(BitfinexSocketQuery request) : base(request, true, 1) return typeof(BitfinexSocketEvent>); } - public override Task>>> HandleMessageAsync(SocketConnection connection, DataEvent>> message) + public override CallResult>> HandleMessage(SocketConnection connection, DataEvent>> message) { if (message.Data.Data.Result != "SUCCESS") - return Task.FromResult(new CallResult>>(new ServerError(message.Data.Data.ErrorMessage!))); + return new CallResult>>(new ServerError(message.Data.Data.ErrorMessage!)); - return Task.FromResult(new CallResult>>(message.Data)); + return new CallResult>>(message.Data); } } } diff --git a/Bitfinex.Net/Objects/Sockets/Queries/BitfinexSubQuery.cs b/Bitfinex.Net/Objects/Sockets/Queries/BitfinexSubQuery.cs index 4e27a17..a80c1a3 100644 --- a/Bitfinex.Net/Objects/Sockets/Queries/BitfinexSubQuery.cs +++ b/Bitfinex.Net/Objects/Sockets/Queries/BitfinexSubQuery.cs @@ -31,12 +31,12 @@ public BitfinexSubQuery(string evnt, string channel, string? symbol, string? pre }; } - public override Task> HandleMessageAsync(SocketConnection connection, DataEvent message) + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) { if (message.Data.Event == "error") - return Task.FromResult(new CallResult(new ServerError(message.Data.Message!))); + return new CallResult(new ServerError(message.Data.Message!)); - return Task.FromResult(new CallResult(message.Data)); + return new CallResult(message.Data); } } } diff --git a/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexInfoSubscription.cs b/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexInfoSubscription.cs index 0047b7b..e03576f 100644 --- a/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexInfoSubscription.cs +++ b/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexInfoSubscription.cs @@ -16,13 +16,13 @@ public BitfinexInfoSubscription(ILogger logger) : base(logger, false) { } - public override Task HandleMessageAsync(SocketConnection connection, DataEvent message) + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) { if (message.Data.Code == null) { // welcome event, send a config message for receiving checsum updates for order book subscriptions _ = connection.SendAndWaitQueryAsync(new BitfinexConfQuery(131072)); - return Task.FromResult(new CallResult(null)); + return new CallResult(null); } var code = message.Data.Code; @@ -46,7 +46,7 @@ public override Task HandleMessageAsync(SocketConnection connection, break; } - return Task.FromResult(new CallResult(null)); + return new CallResult(null); } } } diff --git a/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexSubscription.cs b/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexSubscription.cs index 6573e96..68ea1f7 100644 --- a/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexSubscription.cs +++ b/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexSubscription.cs @@ -2,11 +2,11 @@ using Bitfinex.Net.Enums; using Bitfinex.Net.Objects.Internal; using Bitfinex.Net.Objects.Sockets.Queries; +using CryptoExchange.Net.Converters.MessageParsing; +using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Sockets; -using CryptoExchange.Net.Sockets.MessageParsing; -using CryptoExchange.Net.Sockets.MessageParsing.Interfaces; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using System; @@ -93,7 +93,7 @@ public override void HandleSubQueryResponse(BitfinexResponse message) return new BitfinexUnsubQuery(_channelId); } - public override Task DoHandleMessageAsync(SocketConnection connection, DataEvent message) + public override CallResult DoHandleMessage(SocketConnection connection, DataEvent message) { if (message.Data is BitfinexChecksum checksum) _checksumHandler?.Invoke(message.As(checksum.Checksum, _symbol)); @@ -107,7 +107,7 @@ public override Task DoHandleMessageAsync(SocketConnection connectio _handler?.Invoke(message.As>(new[] { single3Update.Data }, _symbol, _firstUpdate ? SocketUpdateType.Snapshot : SocketUpdateType.Update)); _firstUpdate = false; - return Task.FromResult(new CallResult(null)); + return new CallResult(null); } } } diff --git a/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexUserSubscription.cs b/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexUserSubscription.cs index c04c30c..0ca8d86 100644 --- a/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexUserSubscription.cs +++ b/Bitfinex.Net/Objects/Sockets/Subscriptions/BitfinexUserSubscription.cs @@ -1,10 +1,10 @@ using Bitfinex.Net.Objects.Models; using Bitfinex.Net.Objects.Models.Socket; +using CryptoExchange.Net.Converters.MessageParsing; +using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Sockets; -using CryptoExchange.Net.Sockets.MessageParsing; -using CryptoExchange.Net.Sockets.MessageParsing.Interfaces; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -129,7 +129,7 @@ public BitfinexUserSubscription(ILogger logger, public override Query? GetUnsubQuery() => null; - public override Task DoHandleMessageAsync(SocketConnection connection, DataEvent message) + public override CallResult DoHandleMessage(SocketConnection connection, DataEvent message) { if (message.Data is BitfinexSocketEvent> positionSnapshot) _positionHandler?.Invoke(message.As>(positionSnapshot.Data)); @@ -177,7 +177,7 @@ public override Task DoHandleMessageAsync(SocketConnection connectio else if (message.Data is BitfinexSocketEvent marginSymbolUpdate) _marginSymbolHandler?.Invoke(message.As(marginSymbolUpdate.Data)); - return Task.FromResult(new CallResult(null)); + return new CallResult(null); } } } diff --git a/Bitfinex.Net/Usings.cs b/Bitfinex.Net/Usings.cs new file mode 100644 index 0000000..7ef0a6f --- /dev/null +++ b/Bitfinex.Net/Usings.cs @@ -0,0 +1 @@ +global using CryptoExchange.Net.Converters.JsonNet; \ No newline at end of file diff --git a/README.md b/README.md index a35bbb9..e232a8c 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,10 @@ Make a one time donation in a crypto currency of your choice. If you prefer to d Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf). ## Release notes +* Version 7.2.0 - 16 Mar 2024 + * Updated CryptoExchange.Net to 7.1.0, see https://github.com/JKorf/CryptoExchange.Net?tab=readme-ov-file#release-notes for release notes + * Updated unit test package dependencies and updated tests accordingly + * Version 7.1.0 - 25 Feb 2024 * Updated CryptoExchange.Net and implemented reworked websocket message handling. For release notes for the CryptoExchange.Net base library see: https://github.com/JKorf/CryptoExchange.Net?tab=readme-ov-file#release-notes * Combined multiple private websocket subscriptions into single subscription