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 MapsEventDtoToGenericSearchDocument() { var indexDefinition = new EventIndexDefinition <TransferEvent>(); var index = indexDefinition.ToAzureIndex(); var mockSearchIndexClient = new SearchIndexClientMock <GenericSearchDocument>(); var indexer = new AzureEventIndexer <TransferEvent>( mockSearchIndexClient.SearchIndexClient, indexDefinition); var eventLog = TestData.Contracts.StandardContract.SampleTransferEventLog(); await indexer.IndexAsync(eventLog); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); Assert.Equal(eventLog.Log.Key(), firstIndexAction.Document[PresetSearchFieldName.log_key.ToString()]); }
public async Task MapsSourceToSearchDocument() { var index = new Index(); //for proper use, this index should have been prepopulated var mockSearchIndexClient = new SearchIndexClientMock <SearchDocument>(); var mappedSearchDocument = new SearchDocument(); var indexer = new AzureIndexer <Source, SearchDocument>( mockSearchIndexClient.SearchIndexClient, (tfr) => mappedSearchDocument); var source = new Source(); await indexer.IndexAsync(source); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); Assert.Same(mappedSearchDocument, firstIndexAction.Document); }
public async Task MapsTransactionToSearchDocument() { var index = new Index(); var mockSearchIndexClient = new SearchIndexClientMock <SearchDocument>(); var indexer = new AzureTransactionReceiptVOIndexer <SearchDocument>( mockSearchIndexClient.SearchIndexClient, (tx) => new SearchDocument(tx)); TransactionReceiptVO transaction = IndexerTestData.CreateSampleTransaction(); await indexer.IndexAsync(transaction); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); var document = firstIndexAction.Document; //check mapping Assert.Same(transaction, document.TransactionReceiptVO); }
public async Task MapsTransactionToGenericSearchDocument() { var indexDefinition = new TransactionReceiptVOIndexDefinition("my-transactions"); var index = indexDefinition.ToAzureIndex(); var mockSearchIndexClient = new SearchIndexClientMock <GenericSearchDocument>(); var indexer = new AzureTransactionReceiptVOIndexer( mockSearchIndexClient.SearchIndexClient, indexDefinition); TransactionReceiptVO transaction = IndexerTestData.CreateSampleTransaction(); await indexer.IndexAsync(transaction); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); var document = firstIndexAction.Document; //check generic mapping Assert.Equal(transaction.Transaction.BlockNumber.ToString(), document[PresetSearchFieldName.tx_block_number.ToString()]); }
public async Task MapsFunctionDtoToSearchDocument() { var index = new Index(); var mockSearchIndexClient = new SearchIndexClientMock <SearchDocument>(); var indexer = new AzureFunctionIndexer <TransferFunction, SearchDocument>( mockSearchIndexClient.SearchIndexClient, (tx) => new SearchDocument(tx)); TransactionForFunctionVO <TransferFunction> transactionForFunction = IndexerTestData.CreateSampleTransactionForFunction(); await indexer.IndexAsync(transactionForFunction); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); var document = firstIndexAction.Document; //check function message mapping Assert.Equal(transactionForFunction.Transaction.TransactionHash, document.TransactionHash); Assert.Equal(transactionForFunction.FunctionMessage.To, document.To); Assert.Equal(transactionForFunction.FunctionMessage.Value.ToString(), document.Value); }
public async Task MapsFunctionDtoToGenericSearchDocument() { var indexDefinition = new FunctionIndexDefinition <TransferFunction>(); var index = indexDefinition.ToAzureIndex(); var mockSearchIndexClient = new SearchIndexClientMock <GenericSearchDocument>(); var indexer = new AzureFunctionIndexer <TransferFunction>( mockSearchIndexClient.SearchIndexClient, indexDefinition); TransactionForFunctionVO <TransferFunction> transactionForFunction = IndexerTestData.CreateSampleTransactionForFunction(); await indexer.IndexAsync(transactionForFunction); Assert.Single(mockSearchIndexClient.IndexedBatches); var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First(); var document = firstIndexAction.Document; //check generic mapping Assert.Equal(transactionForFunction.Transaction.BlockNumber.ToString(), document[PresetSearchFieldName.tx_block_number.ToString()]); //check function message mapping Assert.Equal(transactionForFunction.FunctionMessage.To, document["to"]); Assert.Equal(transactionForFunction.FunctionMessage.Value.ToString(), document["value"]); }
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()]); }