public async Task Should_Subscribe_For_Transactions_With_Address()
        {
            var keys = await _client.Crypto.GenerateRandomSignKeysAsync();

            var deployParams = new ParamsOfEncodeMessage
            {
                Abi       = TestClient.Abi("Hello"),
                DeploySet = new DeploySet
                {
                    Tvc = TestClient.Tvc("Hello")
                },
                Signer = new Signer.Keys
                {
                    KeysProperty = keys
                },
                CallSet = new CallSet
                {
                    FunctionName = "constructor"
                }
            };

            var msg = await _client.Abi.EncodeMessageAsync(deployParams);

            var address        = msg.Address;
            var transactionIds = new List <string>();

            var handle = await _client.Net.SubscribeCollectionAsync(new ParamsOfSubscribeCollection
            {
                Collection = "transactions",
                Filter     = new
                {
                    account_addr = new { eq = address },
                    status       = new { eq = 3 } // Finalized
                }.ToJson(),
                Result = "id account_addr"
            }, (json, result) =>
            {
                Assert.Equal(100, result);
                Assert.NotNull(json);
                Assert.NotNull(json["result"]);
                Assert.Equal(address, json.SelectToken("result.account_addr"));
                transactionIds.Add((string)json.SelectToken("result.id"));
                return(Task.CompletedTask);
            });

            await _client.DeployWithGiverAsync(deployParams);

            // give some time for subscription to receive all data
            await Task.Delay(TimeSpan.FromSeconds(1));

            Assert.Equal(2, transactionIds.Distinct().Count());

            await _client.Net.UnsubscribeAsync(handle);
        }
        public async Task Should_Get_Transaction_Tree()
        {
            var messages = await _client.Net.QueryCollectionAsync(new ParamsOfQueryCollection
            {
                Collection = "messages",
                Filter     = new
                {
                    msg_type = new { eq = 1 }
                }.ToJson(),
                Result = @"
            id dst
            dst_transaction { id aborted
              out_messages { id dst msg_type_name
                dst_transaction { id aborted
                  out_messages { id dst msg_type_name
                    dst_transaction { id aborted
                    }
                  }
                }
              }
            }
        "
            });

            var abiRegistry = new[]
            {
                TestClient.Abi("GiverV2"),
                TestClient.Abi("Subscription"),
                TestClient.Abi("Hello"),
                TestClient.Abi("testDebot"),
                TestClient.Abi("testDebotTarget")
            };

            var hasDecodedBodies = false;

            foreach (var message in messages.Result)
            {
                var result = await _client.Net.QueryTransactionTreeAsync(new ParamsOfQueryTransactionTree
                {
                    InMsg       = message["id"]?.ToString(),
                    AbiRegistry = abiRegistry
                });

                var refMessages     = new List <JToken>();
                var refTransactions = new List <JToken>();
                Collect(new[] { message }, refMessages, refTransactions);

                var refMessageIds = refMessages
                                    .Select(m => m["id"].ToString())
                                    .ToHashSet();

                var refTransactionIds = refTransactions
                                        .Select(t => t["id"].ToString())
                                        .ToHashSet();

                var actualMessageIds = result.Messages
                                       .Select(m => m.Id)
                                       .ToHashSet();

                var actualTransactionIds = result.Transactions
                                           .Select(t => t.Id)
                                           .ToHashSet();

                Assert.Equal(refMessageIds, actualMessageIds);
                Assert.Equal(refTransactionIds, actualTransactionIds);

                foreach (var msg in result.Messages)
                {
                    if (msg.DecodedBody != null)
                    {
                        hasDecodedBodies = true;
                    }
                }
            }

            Assert.True(hasDecodedBodies);
        }