public async Task StartHere() { using (var processor = new AzureEventIndexingProcessor(AzureSearchServiceName, _azureSearchApiKey, BlockchainUrl)) { #region test preparation await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion await processor.AddEventAsync <TransferEvent_ERC20>(AzureTransferIndexName); var blocksProcessed = await processor.ProcessAsync(3146684, 3146694); Assert.Equal((ulong)11, blocksProcessed); Assert.Equal(1, processor.Indexers.Count); Assert.Equal(6, processor.Indexers[0].Indexed); #region test clean up await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion } }
private static async Task ClearDown(AzureEventIndexingProcessor processor) { #region test preparation await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(TransferEventIndexName); await processor.SearchService.DeleteIndexAsync(TransferFunctionIndexName); await processor.SearchService.DeleteIndexAsync(TransferFromFunctionIndexName); #endregion }
public async Task RunContinually() { var web3 = new Web3.Web3(BlockchainUrl); var currentBlockNumber = (ulong)(await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync()).Value; var startingBlock = currentBlockNumber - 10; var maxBlock = currentBlockNumber + 1; const ulong expectedBlocks = 12; // current block + 10 + 1 using (var processor = new AzureEventIndexingProcessor( AzureSearchServiceName, _azureSearchApiKey, BlockchainUrl, maxBlocksPerBatch: 1, minBlockConfirmations: 0)) { #region test preparation await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion await processor.AddEventAsync <TransferEvent_ERC20>(AzureTransferIndexName); var cancellationToken = new CancellationTokenSource(); var escapeHatch = new Action <uint, BlockRange>((rangesProcessed, lastRange) => { if (lastRange.To >= maxBlock) // escape hatch! { cancellationToken.Cancel(); } }); var blocksProcessed = await processor.ProcessAsync(startingBlock, ctx : cancellationToken, rangeProcessedCallback : escapeHatch); Assert.Equal(expectedBlocks, blocksProcessed); #region test clean up await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion } }
public async Task IndexingTransferEventsWithDifferingSignatures() { using (var processor = new AzureEventIndexingProcessor(AzureSearchServiceName, _azureSearchApiKey, BlockchainUrl)) { #region test preparation await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion await processor.AddEventAsync <TransferEvent_With3Indexes>(AzureTransferIndexName); await processor.AddEventAsync <TransferEvent_ERC20>(AzureTransferIndexName); var blocksProcessed = await processor.ProcessAsync(3146684, 3146694); Assert.Equal((ulong)11, blocksProcessed); Assert.Equal(2, processor.Indexers.Count); Assert.Equal(6, processor.Indexers[0].Indexed); Assert.Equal(19, processor.Indexers[1].Indexed); await Task.Delay(5000); // leave time for index var customIndexer = processor.Indexers[0] as IAzureSearchIndex; var erc20Indexer = processor.Indexers[1] as IAzureSearchIndex; //the indexers wrap the same underlying azure index //this azure index should have documents for both transfer event types Assert.Equal(25, await erc20Indexer.DocumentCountAsync()); Assert.Equal(25, await customIndexer.DocumentCountAsync()); #region test clean up await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion } }
public async Task IndexingAdditionalInformationPerEvent() { using (var processor = new AzureEventIndexingProcessor(AzureSearchServiceName, _azureSearchApiKey, BlockchainUrl)) { #region test preparation await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion await processor.AddEventAsync <TransferEvent_Extended>(AzureTransferIndexName); await processor.ProcessAsync(3146684, 3146694); await Task.Delay(5000); // leave time for index var customIndexer = processor.Indexers[0] as IAzureSearchIndex; var query = "0x90df9bcd9608696df90c0baf5faefd2399bba0d2"; var searchResult = await customIndexer.SearchAsync(query, new List <string>()); Assert.Equal(1, searchResult.Count); //all should have our custom metadata which is not provided by the blockchain foreach (var result in searchResult.Results) { Assert.Equal(Environment.MachineName, result.Document["metadata_indexingmachinename"]); } #region test clean up await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion } }
public async Task WithAFilter() { var filter = new NewFilterInputBuilder <TransferEvent_ERC20>() .AddTopic(tfr => tfr.To, "0xdfa70b70b41d77a7cdd8b878f57521d47c064d8c") .Build(contractAddress: "0x3678FbEFC663FC28336b93A1FA397B67ae42114d", blockRange: new BlockRange(3860820, 3860820)); using (var processor = new AzureEventIndexingProcessor( AzureSearchServiceName, _azureSearchApiKey, BlockchainUrl, filters: new[] { filter })) { #region test preparation await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion await processor.AddEventAsync <TransferEvent_ERC20>(AzureTransferIndexName); var blocksProcessed = await processor.ProcessAsync(3860820, 3860820); Assert.Equal((ulong)1, blocksProcessed); Assert.Equal(1, processor.Indexers[0].Indexed); #region test clean up await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); #endregion } }
private static async Task ClearDown(AzureEventIndexingProcessor processor) { await processor.ClearProgress(); await processor.SearchService.DeleteIndexAsync(AzureTransferIndexName); }