public async Task GetMaturedBlocksAsyncReturnsDeposits() { List <ChainedHeader> headers = ChainedHeadersHelper.CreateConsecutiveHeaders(10, null, true); foreach (ChainedHeader chainedHeader in headers) { chainedHeader.Block = new Block(chainedHeader.Header); } var blocks = new List <ChainedHeaderBlock>(headers.Count); foreach (ChainedHeader chainedHeader in headers) { blocks.Add(new ChainedHeaderBlock(chainedHeader.Block, chainedHeader)); } ChainedHeader tip = headers.Last(); this.consensusManager.GetBlockDataAsync(Arg.Any <uint256>()).Returns(delegate(CallInfo info) { uint256 hash = (uint256)info[0]; ChainedHeaderBlock block = blocks.Single(x => x.ChainedHeader.HashBlock == hash); return(block); }); uint zero = 0; this.depositExtractor.MinimumDepositConfirmations.Returns(info => zero); this.depositExtractor.ExtractBlockDeposits(null).ReturnsForAnyArgs(new MaturedBlockDepositsModel(new MaturedBlockInfoModel(), new List <IDeposit>())); this.consensusManager.Tip.Returns(tip); // Makes every block a matured block. var maturedBlocksProvider = new MaturedBlocksProvider(this.loggerFactory, this.depositExtractor, this.consensusManager); List <MaturedBlockDepositsModel> deposits = await maturedBlocksProvider.GetMaturedDepositsAsync(0, 10); // Expect the number of matured deposits to equal the number of blocks. Assert.Equal(10, deposits.Count); }
public void GetMaturedBlocksAsyncReturnsDeposits() { var blocks = new List <Block>(); uint256 previous = 0; for (int i = 0; i < 10; i++) { blocks.Add(this.ChainedHeaderBuilder(i, previous).Block); previous = blocks.Last().GetHash(); } ChainedHeader tip = ChainedHeaderBuilder(10); this.chain.Tip.Returns(tip); this.blockRepository.GetBlocksAsync(Arg.Any <List <uint256> >()).Returns(blocks); var maturedBlocksProvider = new MaturedBlocksProvider(this.loggerFactory, this.chain, this.depositExtractor, this.blockRepository); List <IMaturedBlockDeposits> deposits = maturedBlocksProvider.GetMaturedDepositsAsync(0, 10).GetAwaiter().GetResult(); Assert.Equal(10, deposits.Count); }