elucidsoft / dotnet-stellar-sdk

Stellar API SDK for .NET 6.x
Apache License 2.0
116 stars 55 forks source link

Failed to load effects for ledger at block '717310' #343

Closed avolkov-dev closed 2 years ago

avolkov-dev commented 2 years ago

Failed to load effects for ledger at block '717310' at testnet using 7.2.8 sdk version

To Reproduce Run piece of code:

using System.Threading.Tasks;
using stellar_dotnet_sdk;
using Xunit;

namespace Tests
{
    public class Block717310Failure
    {
        [Fact]
        public async Task Exec()
        {
            await new Server("https://horizon-testnet.stellar.org/")
                .Effects.ForLedger(717310)
                .Limit(100)
                .Execute();
        }
    }
}

Expected behavior No exception thrown

Actual behaviour

Tests.Block717310Failure.Exec

System.ArgumentException: Accessed JArray values with invalid key value: "asset". Int32 array index expected.

System.ArgumentException
Accessed JArray values with invalid key value: "asset". Int32 array index expected.
   at Newtonsoft.Json.Linq.JArray.get_Item(Object key)
   at Newtonsoft.Json.Linq.JToken.Value[T](Object key)
   at stellar_dotnet_sdk.converters.LiquidityPoolClaimableAssetAmountJsonConverter.ReadJson(JsonReader reader, Type objectType, LiquidityPoolClaimableAssetAmount existingValue, Boolean hasExistingValue, JsonSerializer serializer)
   at Newtonsoft.Json.JsonConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerProxy.PopulateInternal(JsonReader reader, Object target)
   at Newtonsoft.Json.JsonSerializer.Populate(JsonReader reader, Object target)
   at stellar_dotnet_sdk.responses.EffectDeserializer.ReadJson(JsonReader reader, Type objectType, EffectResponse existingValue, Boolean hasExistingValue, JsonSerializer serializer)
   at Newtonsoft.Json.JsonConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonConverter[] converters)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonConverter[] converters)
   at stellar_dotnet_sdk.responses.JsonSingleton.GetInstance[T](String content)
   at stellar_dotnet_sdk.requests.ResponseHandler`1.HandleResponse(HttpResponseMessage response)
   at stellar_dotnet_sdk.requests.RequestBuilder`1.Execute[TZ](Uri uri)
   at stellar_dotnet_sdk.requests.RequestBuilderExecutePageable`2.Execute()
   at Tests.Block717310Failure.Exec() in D:\Projects\Swisschain\Sirius.Integrations.Stellar\tests\Tests\Block717310Failure.cs:line 12
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
--- End of stack trace from previous location ---
   at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90
Kirbyrawr commented 2 years ago

Thanks for the report i will check it after work.

Kirbyrawr commented 2 years ago

Fixed. The issue was that the variable was not set as an array, apologies and thanks for the reports it helps a lot to maintain the SDK.

I will make the PR and i will tell @elucidsoft to upload the new version to the nuget.