use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class BlocksBloomServiceTest method processFirstRange.
@Test
public void processFirstRange() {
World world = new World();
Blockchain blockchain = world.getBlockChain();
BlockChainBuilder.extend(blockchain, 8, false, false);
CompositeEthereumListener emitter = new CompositeEthereumListener();
KeyValueDataSource dataSource = new HashMapDB();
BlocksBloomStore blocksBloomStore = new BlocksBloomStore(4, 2, dataSource);
BlocksBloomService blocksBloomService = new BlocksBloomService(emitter, blocksBloomStore, world.getBlockStore());
blocksBloomService.processNewBlock(4);
blocksBloomService.processNewBlock(6);
Assert.assertFalse(dataSource.keys().isEmpty());
Assert.assertEquals(1, dataSource.keys().size());
Assert.assertNotNull(dataSource.get(longToKey(0)));
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class BlocksBloomProcessorTest method processBlocksInSecondRangeOnly.
@Test
public void processBlocksInSecondRangeOnly() {
World world = new World();
Blockchain blockchain = world.getBlockChain();
BlockChainBuilder.extend(blockchain, 8, false, false);
KeyValueDataSource dataSource = new HashMapDB();
BlocksBloomStore blocksBloomStore = new BlocksBloomStore(4, 2, dataSource);
BlocksBloomProcessor blocksBloomProcessor = new BlocksBloomProcessor(blocksBloomStore, world.getBlockStore());
blocksBloomProcessor.processNewBlockNumber(6);
blocksBloomProcessor.processNewBlockNumber(4);
BlocksBloom result = blocksBloomProcessor.getBlocksBloomInProcess();
Assert.assertNotNull(result);
Assert.assertEquals(4, result.fromBlock());
Assert.assertEquals(4, result.toBlock());
Assert.assertTrue(dataSource.keys().isEmpty());
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class BlocksBloomProcessorTest method processNewBlockTwice.
@Test
public void processNewBlockTwice() {
World world = new World();
Blockchain blockchain = world.getBlockChain();
BlockChainBuilder.extend(blockchain, 8, false, false);
KeyValueDataSource dataSource = new HashMapDB();
BlocksBloomStore blocksBloomStore = new BlocksBloomStore(4, 2, dataSource);
BlocksBloomProcessor blocksBloomProcessor = new BlocksBloomProcessor(blocksBloomStore, world.getBlockStore());
blocksBloomProcessor.processNewBlockNumber(4);
blocksBloomProcessor.processNewBlockNumber(4);
BlocksBloom result = blocksBloomProcessor.getBlocksBloomInProcess();
Assert.assertNotNull(result);
Assert.assertEquals(0, result.fromBlock());
Assert.assertEquals(2, result.toBlock());
Assert.assertTrue(dataSource.keys().isEmpty());
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class BlocksBloomProcessorTest method processBlocksToFillRangeAndStartTheNextOne.
@Test
public void processBlocksToFillRangeAndStartTheNextOne() {
World world = new World();
Blockchain blockchain = world.getBlockChain();
BlockChainBuilder.extend(blockchain, 8, false, false);
KeyValueDataSource dataSource = new HashMapDB();
BlocksBloomStore blocksBloomStore = new BlocksBloomStore(4, 2, dataSource);
BlocksBloomProcessor blocksBloomProcessor = new BlocksBloomProcessor(blocksBloomStore, world.getBlockStore());
blocksBloomProcessor.processNewBlockNumber(4);
blocksBloomProcessor.processNewBlockNumber(6);
BlocksBloom result = blocksBloomProcessor.getBlocksBloomInProcess();
Assert.assertNotNull(result);
Assert.assertEquals(4, result.fromBlock());
Assert.assertEquals(4, result.toBlock());
Assert.assertFalse(dataSource.keys().isEmpty());
Assert.assertEquals(1, dataSource.keys().size());
}
use of org.ethereum.datasource.HashMapDB in project rskj by rsksmart.
the class BlocksBloomProcessorTest method noBlocksBloomInProcessAtTheBeginning.
@Test
public void noBlocksBloomInProcessAtTheBeginning() {
KeyValueDataSource dataSource = new HashMapDB();
BlocksBloomStore blocksBloomStore = new BlocksBloomStore(64, 0, dataSource);
BlocksBloomProcessor blocksBloomProcessor = new BlocksBloomProcessor(blocksBloomStore, null);
Assert.assertNull(blocksBloomProcessor.getBlocksBloomInProcess());
}
Aggregations