public void RetrievableFields()
        {
            var index = FilterLogIndexUtil.Create("my-index");

            var allFieldCount = Enum.GetNames(typeof(PresetSearchFieldName)).Where(n => n.StartsWith("log_")).Count();

            Assert.Equal(allFieldCount, index.Fields.Count(f => f.IsRetrievable ?? false));
        }
        public void CreatesExpectedKeyField()
        {
            var index     = FilterLogIndexUtil.Create("my-index");
            var keyFields = index.Fields.Where(f => f.IsKey ?? false).ToArray();

            Assert.Single(keyFields);
            Assert.Contains(keyFields, f => f.Name == PresetSearchFieldName.log_key.ToString());
        }
        public void CreatesAnAzureIndexDefinitionContainingAllFilterLogFields()
        {
            var index = FilterLogIndexUtil.Create("my-index");

            foreach (var fieldName in Enum.GetNames(typeof(PresetSearchFieldName)).Where(n => n.StartsWith("log_")))
            {
                Assert.Contains(index.Fields, f => f.Name == fieldName);
            }
        }
        public void SearchableFields()
        {
            var index            = FilterLogIndexUtil.Create("my-index");
            var searchableFields = index.Fields.Where(f => f.IsSearchable ?? false).ToArray();

            var expectedFields = new[]
            {
                PresetSearchFieldName.log_address,
                PresetSearchFieldName.log_block_number,
                PresetSearchFieldName.log_transaction_hash,
                PresetSearchFieldName.log_topics
            };

            CheckFields(searchableFields, expectedFields);
        }
示例#5
0
        public void FilterableFields()
        {
            var index            = FilterLogIndexUtil.Create("my-index");
            var filterableFields = index.Fields.Where(f => f.IsFilterable).ToArray();

            var expectedFields = new[]
            {
                PresetSearchFieldName.log_removed,
                PresetSearchFieldName.log_type,
                PresetSearchFieldName.log_log_index,
                PresetSearchFieldName.log_transaction_hash,
                PresetSearchFieldName.log_transaction_index,
                PresetSearchFieldName.log_block_number,
                PresetSearchFieldName.log_address,
                PresetSearchFieldName.log_topics
            };

            CheckFields(filterableFields, expectedFields);
        }
        public async Task MapsFilterLogToGenericSearchDocument()
        {
            var searchIndexClientMock = new SearchIndexClientMock <GenericSearchDocument>();

            var index = FilterLogIndexUtil.Create("my-logs");

            var indexer = new AzureFilterLogIndexer(searchIndexClientMock.SearchIndexClient);

            var filterLog = new FilterLog {
                BlockNumber     = new Hex.HexTypes.HexBigInteger(4309),
                TransactionHash = "0x3C81039C578811A85742F2476DA90E363A88CA93763DB4A194E35367D9A72FD8",
                LogIndex        = new Hex.HexTypes.HexBigInteger(9)
            };

            await indexer.IndexAsync(filterLog);

            var indexedBatch = searchIndexClientMock.IndexedBatches.FirstOrDefault();

            Assert.Single(indexedBatch.Actions);
            var action = indexedBatch.Actions.First();

            Assert.Equal(IndexActionType.MergeOrUpload, action.ActionType);
            Assert.Equal(filterLog.Key(), action.Document[PresetSearchFieldName.log_key.ToString()]);
        }