public async Task MapsFilterLogToSearchDocument() { var index = new Index(); //for proper use, this index should have been prepopulated var mockSearchIndexClient = new SearchIndexClientMock <SearchDocument>(); var indexer = new AzureFilterLogIndexer <SearchDocument>( mockSearchIndexClient.SearchIndexClient, (tfr) => new SearchDocument(tfr.TransactionHash, tfr.LogIndex)); var log = TestData.Contracts.StandardContract.SampleTransferLog(); await indexer.IndexAsync(log); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); Assert.Equal(log.TransactionHash, firstIndexAction.Document.TransactionHash); Assert.Equal(log.LogIndex.Value.ToString(), firstIndexAction.Document.LogIndex); }
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()]); }