Search in sources :

Example 86 with HashMapDB

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)));
}
Also used : CompositeEthereumListener(org.ethereum.listener.CompositeEthereumListener) Blockchain(org.ethereum.core.Blockchain) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) World(co.rsk.test.World) HashMapDB(org.ethereum.datasource.HashMapDB) Test(org.junit.Test)

Example 87 with HashMapDB

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());
}
Also used : Blockchain(org.ethereum.core.Blockchain) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) World(co.rsk.test.World) HashMapDB(org.ethereum.datasource.HashMapDB) Test(org.junit.Test)

Example 88 with HashMapDB

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());
}
Also used : Blockchain(org.ethereum.core.Blockchain) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) World(co.rsk.test.World) HashMapDB(org.ethereum.datasource.HashMapDB) Test(org.junit.Test)

Example 89 with HashMapDB

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());
}
Also used : Blockchain(org.ethereum.core.Blockchain) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) World(co.rsk.test.World) HashMapDB(org.ethereum.datasource.HashMapDB) Test(org.junit.Test)

Example 90 with HashMapDB

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());
}
Also used : KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) HashMapDB(org.ethereum.datasource.HashMapDB) Test(org.junit.Test)

Aggregations

HashMapDB (org.ethereum.datasource.HashMapDB)208 Test (org.junit.Test)181 World (co.rsk.test.World)45 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)34 ReceiptStore (org.ethereum.db.ReceiptStore)34 ReceiptStoreImpl (org.ethereum.db.ReceiptStoreImpl)34 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)29 KeyValueDataSource (org.ethereum.datasource.KeyValueDataSource)27 IndexedBlockStore (org.ethereum.db.IndexedBlockStore)27 TrieStore (co.rsk.trie.TrieStore)26 HashMapBlocksIndex (co.rsk.db.HashMapBlocksIndex)23 Trie (co.rsk.trie.Trie)21 Blockchain (org.ethereum.core.Blockchain)17 RskAddress (co.rsk.core.RskAddress)16 Transaction (org.ethereum.core.Transaction)16 DslParser (co.rsk.test.dsl.DslParser)15 WorldDslProcessor (co.rsk.test.dsl.WorldDslProcessor)15 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 BtcBlock (co.rsk.bitcoinj.core.BtcBlock)13 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)12