Exemplo n.º 1
0
        public async Task find_block_by_hash_should_invoke_blockchain_bridge_find_block_by_hash()
        {
            var block = Build.A.Block.TestObject;

            _blockFinder.FindBlock(block.Hash).Returns(block);
            var result = await _ndmBridge.FindBlockAsync(block.Hash);

            _blockFinder.Received().FindBlock(block.Hash);
            result.Should().Be(block);
        }
Exemplo n.º 2
0
        public void GetGasPricesFromRecentBlocks_IfEightBlocksWithTwoTransactions_CheckEightBlocks()
        {
            int            blockNumber        = 8;
            IBlockFinder   blockFinder        = BuildTree(blockNumber);
            ISpecProvider  specProvider       = Substitute.For <ISpecProvider>();
            GasPriceOracle testGasPriceOracle = new(blockFinder, specProvider);

            testGasPriceOracle.GetGasPriceEstimate();

            foreach (long receivedBlockNumber in Enumerable.Range(0, blockNumber + 1))
            {
                blockFinder.Received(1).FindBlock(Arg.Is <long>(l => l == receivedBlockNumber));
            }
        }
Exemplo n.º 3
0
        public void GetGasPricesFromRecentBlocks_IfLastFiveBlocksWithThreeTxAndFirstFourWithOne_CheckSixBlocks()
        {
            IBlockFinder   blockFinder        = GetBlockFinderForLastFiveBlocksWithThreeTxAndFirstFourWithOne();
            GasPriceOracle testGasPriceOracle = new(blockFinder, Substitute.For <ISpecProvider>())
            {
                IgnoreUnder = 1,
                BlockLimit  = 6
            };

            testGasPriceOracle.GetGasPriceEstimate();

            foreach (long receivedBlockNumber in Enumerable.Range(3, 5))
            {
                blockFinder.Received(1).FindBlock(Arg.Is <long>(l => l == receivedBlockNumber));
            }

            blockFinder.DidNotReceive().FindBlock(Arg.Is <long>(l => l <= 2));
        }