Search in sources :

Example 6 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class NodeBlockProcessorTest method processBlockHashRequestMessageUsingOutOfBoundsHeight.

@Test
public void processBlockHashRequestMessageUsingOutOfBoundsHeight() throws UnknownHostException {
    final Blockchain blockchain = BlockChainBuilder.ofSize(10);
    final BlockStore store = new BlockStore();
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    RskSystemProperties config = new RskSystemProperties();
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    final SimpleMessageChannel sender = new SimpleMessageChannel();
    processor.processBlockHashRequest(sender, 100, 99999);
    Assert.assertTrue(sender.getMessages().isEmpty());
}
Also used : SimpleMessageChannel(co.rsk.net.simples.SimpleMessageChannel) Blockchain(org.ethereum.core.Blockchain) RskSystemProperties(co.rsk.config.RskSystemProperties) SyncConfiguration(co.rsk.net.sync.SyncConfiguration) Test(org.junit.Test)

Example 7 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class NodeBlockProcessorTest method processTwoBlockListsAddingToBlockchainWithFork.

@Test
public void processTwoBlockListsAddingToBlockchainWithFork() {
    BlockStore store = new BlockStore();
    Blockchain blockchain = BlockChainBuilder.ofSize(0);
    Block genesis = blockchain.getBestBlock();
    BlockGenerator blockGenerator = new BlockGenerator();
    List<Block> blocks = blockGenerator.getBlockChain(genesis, 10);
    List<Block> blocks2 = blockGenerator.getBlockChain(blocks.get(4), 20);
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    RskSystemProperties config = new RskSystemProperties();
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    processor.processBlock(null, genesis);
    Assert.assertEquals(0, store.size());
    for (Block b : blocks) processor.processBlock(null, b);
    for (Block b : blocks2) processor.processBlock(null, b);
    Assert.assertEquals(25, blockchain.getBestBlock().getNumber());
    Assert.assertEquals(0, store.size());
}
Also used : Blockchain(org.ethereum.core.Blockchain) Block(org.ethereum.core.Block) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) RskSystemProperties(co.rsk.config.RskSystemProperties) SyncConfiguration(co.rsk.net.sync.SyncConfiguration) Test(org.junit.Test)

Example 8 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class NodeBlockProcessorTest method processGetBlockHeaderMessageUsingEmptyStore.

@Test
public void processGetBlockHeaderMessageUsingEmptyStore() throws UnknownHostException {
    final Block block = new BlockGenerator().getBlock(3);
    final BlockStore store = new BlockStore();
    final Blockchain blockchain = BlockChainBuilder.ofSize(0);
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    RskSystemProperties config = new RskSystemProperties();
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    final SimpleMessageChannel sender = new SimpleMessageChannel();
    Assert.assertTrue(nodeInformation.getBlocksByNode(sender.getPeerNodeID()).isEmpty());
    processor.processBlockHeadersRequest(sender, 1, block.getHash().getBytes(), 1);
    Assert.assertTrue(nodeInformation.getBlocksByNode(sender.getPeerNodeID()).isEmpty());
    Assert.assertTrue(sender.getMessages().isEmpty());
}
Also used : SimpleMessageChannel(co.rsk.net.simples.SimpleMessageChannel) Blockchain(org.ethereum.core.Blockchain) Block(org.ethereum.core.Block) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) RskSystemProperties(co.rsk.config.RskSystemProperties) SyncConfiguration(co.rsk.net.sync.SyncConfiguration) Test(org.junit.Test)

Example 9 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class NodeBlockProcessorTest method processTenBlocksAddingToBlockchain.

@Test
public void processTenBlocksAddingToBlockchain() {
    Blockchain blockchain = BlockChainBuilder.ofSize(0);
    BlockStore store = new BlockStore();
    Block genesis = blockchain.getBestBlock();
    List<Block> blocks = new BlockGenerator().getBlockChain(genesis, 10);
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    RskSystemProperties config = new RskSystemProperties();
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    processor.processBlock(null, genesis);
    Assert.assertEquals(0, store.size());
    for (Block b : blocks) processor.processBlock(null, b);
    Assert.assertEquals(10, blockchain.getBestBlock().getNumber());
    Assert.assertEquals(0, store.size());
}
Also used : Blockchain(org.ethereum.core.Blockchain) Block(org.ethereum.core.Block) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) RskSystemProperties(co.rsk.config.RskSystemProperties) SyncConfiguration(co.rsk.net.sync.SyncConfiguration) Test(org.junit.Test)

Example 10 with RskSystemProperties

use of co.rsk.config.RskSystemProperties in project rskj by rsksmart.

the class NodeBlockProcessorTest method processTenBlocksGenesisAtLastAddingToBlockchain.

@Test
public void processTenBlocksGenesisAtLastAddingToBlockchain() {
    BlockStore store = new BlockStore();
    Blockchain blockchain = BlockChainBuilder.ofSize(0);
    Block genesis = blockchain.getBestBlock();
    List<Block> blocks = new BlockGenerator().getBlockChain(genesis, 10);
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    RskSystemProperties config = new RskSystemProperties();
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    final NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    for (Block b : blocks) processor.processBlock(null, b);
    processor.processBlock(null, genesis);
    Assert.assertEquals(10, blockchain.getBestBlock().getNumber());
    Assert.assertEquals(0, store.size());
}
Also used : Blockchain(org.ethereum.core.Blockchain) Block(org.ethereum.core.Block) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) RskSystemProperties(co.rsk.config.RskSystemProperties) SyncConfiguration(co.rsk.net.sync.SyncConfiguration) Test(org.junit.Test)

Aggregations

RskSystemProperties (co.rsk.config.RskSystemProperties)112 Test (org.junit.Test)81 SyncConfiguration (co.rsk.net.sync.SyncConfiguration)48 SimpleMessageChannel (co.rsk.net.simples.SimpleMessageChannel)45 Blockchain (org.ethereum.core.Blockchain)45 Block (org.ethereum.core.Block)41 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)35 ProofOfWorkRule (co.rsk.validators.ProofOfWorkRule)20 Ignore (org.junit.Ignore)10 Keccak256 (co.rsk.crypto.Keccak256)8 RegTestConfig (org.ethereum.config.blockchain.RegTestConfig)8 Repository (org.ethereum.core.Repository)8 SimpleChannelManager (org.ethereum.rpc.Simples.SimpleChannelManager)8 Channel (org.ethereum.net.server.Channel)7 ChannelManager (org.ethereum.net.server.ChannelManager)7 InvocationOnMock (org.mockito.invocation.InvocationOnMock)7 BlockDifficulty (co.rsk.core.BlockDifficulty)6 RskAddress (co.rsk.core.RskAddress)6 PersonalModule (co.rsk.rpc.modules.personal.PersonalModule)6 BeforeClass (org.junit.BeforeClass)6