public static Flowable<BigInteger> range( final BigInteger startValue, final BigInteger endValue) { return range(startValue, endValue, true); }
@Test(expected = IllegalArgumentException.class) public void testRangeFlowableIllegalBounds() throws InterruptedException { Flowables.range(BigInteger.TEN, BigInteger.ONE); } }
@Test(expected = IllegalArgumentException.class) public void testRangeFlowableIllegalLowerBound() throws InterruptedException { Flowables.range(BigInteger.valueOf(-1), BigInteger.ONE); }
@Test public void testRangeFlowable() throws InterruptedException { int count = 10; Flowable<BigInteger> flowable = Flowables.range( BigInteger.ZERO, BigInteger.valueOf(count - 1)); List<BigInteger> expected = new ArrayList<>(count); for (int i = 0; i < count; i++) { expected.add(BigInteger.valueOf(i)); } runRangeTest(flowable, expected); }
@Test public void testRangeDescendingFlowable() throws InterruptedException { int count = 10; Flowable<BigInteger> flowable = Flowables.range( BigInteger.ZERO, BigInteger.valueOf(count - 1), false); List<BigInteger> expected = new ArrayList<>(count); for (int i = count - 1; i >= 0; i--) { expected.add(BigInteger.valueOf(i)); } runRangeTest(flowable, expected); }
private Flowable<EthBlock> replayBlocksFlowableSync( DefaultBlockParameter startBlock, DefaultBlockParameter endBlock, boolean fullTransactionObjects, boolean ascending) { BigInteger startBlockNumber = null; BigInteger endBlockNumber = null; try { startBlockNumber = getBlockNumber(startBlock); endBlockNumber = getBlockNumber(endBlock); } catch (IOException e) { Flowable.error(e); } if (ascending) { return Flowables.range(startBlockNumber, endBlockNumber) .flatMap(i -> web3j.ethGetBlockByNumber( new DefaultBlockParameterNumber(i), fullTransactionObjects).flowable()); } else { return Flowables.range(startBlockNumber, endBlockNumber, false) .flatMap(i -> web3j.ethGetBlockByNumber( new DefaultBlockParameterNumber(i), fullTransactionObjects).flowable()); } }