public void GetFeeHistory_IfPendingBlockDoesNotExistAndLastBlockNumberGreaterThanHeadNumber_ReturnsError(long pendingBlockNumber, long lastBlockNumber)
        {
            IBlockFinder blockFinder = Substitute.For <IBlockFinder>();

            blockFinder.FindPendingBlock().Returns(Build.A.Block.WithNumber(pendingBlockNumber).TestObject);
            FeeHistoryOracle feeHistoryOracle          = GetSubstitutedFeeHistoryOracle(blockFinder: blockFinder);
            ResultWrapper <FeeHistoryResults> expected =
                ResultWrapper <FeeHistoryResults> .Fail("newestBlock: Block is not available",
                                                        ErrorCodes.ResourceUnavailable);

            ResultWrapper <FeeHistoryResults> resultWrapper =
                feeHistoryOracle.GetFeeHistory(1, new BlockParameter(lastBlockNumber));

            resultWrapper.Should().BeEquivalentTo(expected);
        }
Example #2
0
        public static Block GetBlock(this IBlockFinder blockFinder, FilterBlock blockFilter)
        {
            switch (blockFilter.Type)
            {
            case FilterBlockType.Pending:
                return(blockFinder.FindPendingBlock());

            case FilterBlockType.Latest:
                return(blockFinder.FindLatestBlock());

            case FilterBlockType.Earliest:
                return(blockFinder.FindEarliestBlock());

            case FilterBlockType.BlockNumber:
                return(blockFinder.FindBlock(blockFilter.BlockNumber));

            default:
                throw new ArgumentException($"{nameof(FilterBlockType)} not supported: {blockFilter.Type}");
            }
        }
Example #3
0
 public Block FindPendingBlock() => _blockFinder.FindPendingBlock();