elucidsoft / dotnet-stellar-sdk

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

Failure to decode transaction XDR #334

Closed avolkov-dev closed 2 years ago

avolkov-dev commented 2 years ago

Describe the bug Latest SDK (stellar-dotnet-sdk version 7.1.30) not able to decode ResultXdr

To Reproduce Run code:

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

namespace Tests
{
    public class DecodeFail
    {
        [Fact]
        public async Task FailsToDecodeTx()
        {
            var server = new Server("https://horizon-testnet.stellar.org/");
            var txPage = await server.Transactions
                .ForLedger(349089)
                .Limit(100)
                .IncludeFailed(true)
                .Execute();

            //http://testnet.stellarchain.io/tx/a6751fc111031c878041c781d7da8ceab06ebd2497d51d7bfe31106c8c22717d
            var tx = txPage.Records
                .Single(x=>x.Hash == "a6751fc111031c878041c781d7da8ceab06ebd2497d51d7bfe31106c8c22717d");
            var xdr = Convert.FromBase64String(tx.ResultXdr);
            TransactionResult.Decode(new XdrDataInputStream(xdr));
        }
    }
}

And receive error:

Tests.DecodeFail.FailsToDecodeTx

System.Exception: Unknown enum value: 1

System.Exception
Unknown enum value: 1
   at stellar_dotnet_sdk.xdr.PublicKeyType.Decode(XdrDataInputStream stream)
   at stellar_dotnet_sdk.xdr.PublicKey.Decode(XdrDataInputStream stream)
   at stellar_dotnet_sdk.xdr.AccountID.Decode(XdrDataInputStream stream)
   at stellar_dotnet_sdk.xdr.ClaimOfferAtom.Decode(XdrDataInputStream stream)
   at stellar_dotnet_sdk.xdr.ManageOfferSuccessResult.Decode(XdrDataInputStream stream)
   at stellar_dotnet_sdk.xdr.ManageBuyOfferResult.Decode(XdrDataInputStream stream)
   at stellar_dotnet_sdk.xdr.OperationResult.OperationResultTr.Decode(XdrDataInputStream stream)
   at stellar_dotnet_sdk.xdr.OperationResult.Decode(XdrDataInputStream stream)
   at stellar_dotnet_sdk.xdr.TransactionResult.TransactionResultResult.Decode(XdrDataInputStream stream)
   at stellar_dotnet_sdk.xdr.TransactionResult.Decode(XdrDataInputStream stream)
   at Tests.DecodeFail.FailsToDecodeTx() in D:\Projects\Swisschain\Sirius.Integrations.Stellar\tests\Tests\DecodeFail.cs:line 27
   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

Expected behavior No error occured

Kirbyrawr commented 2 years ago

Hi, i will check it tonight!

Kirbyrawr commented 2 years ago

Hi, i'm checking this but i can't seem to reproduce the bug, i literally copied your code and it decodes it properly.

Kirbyrawr commented 2 years ago

Test

avolkov-dev commented 2 years ago

Thanks, will double check on my end. Which version of stellar_dotnet_sdk are you checking at?

Kirbyrawr commented 2 years ago

Latest one, last commit of master.

avolkov-dev commented 2 years ago

I can't see the issue on latest commit https://github.com/elucidsoft/dotnet-stellar-sdk/commit/6a64c8d6ebfd70652932b4b91069df303336ce59, but it's possible to reproduce on https://github.com/elucidsoft/dotnet-stellar-sdk/releases/tag/7.1.30 (commit https://github.com/elucidsoft/dotnet-stellar-sdk/commit/b58d6b545a5e070627c4a2dc61b20ca6778df739), which, i think, is the the latest published version of nuget package (7.1.30). So, the question is: can we publish fresh nuget package, which includes latest changes?

Kirbyrawr commented 2 years ago

Thanks, i will notify @elucidsoft about it.

Kirbyrawr commented 2 years ago

Should be fixed, please confirm when you can.

avolkov-dev commented 2 years ago

The issue is fixed on nuget version 7.2.0. Thanks a lot!