Search in sources :

Example 1 with DummyBlockValidationRule

use of co.rsk.validators.DummyBlockValidationRule in project rskj by rsksmart.

the class NodeMessageHandlerTest method processGetBlockHeaderMessageUsingEmptyStore.

@Test
public void processGetBlockHeaderMessageUsingEmptyStore() throws UnknownHostException {
    final Block block = new BlockGenerator().getBlock(3);
    final World world = new World();
    final Blockchain blockchain = world.getBlockChain();
    final BlockStore store = new BlockStore();
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    final NodeBlockProcessor bp = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    final NodeMessageHandler handler = new NodeMessageHandler(config, bp, null, null, null, null, null, new DummyBlockValidationRule());
    final SimpleMessageChannel sender = new SimpleMessageChannel();
    handler.processMessage(sender, new GetBlockHeadersMessage(block.getHash().getBytes(), 1));
    Assert.assertTrue(sender.getMessages().isEmpty());
}
Also used : SimpleMessageChannel(co.rsk.net.simples.SimpleMessageChannel) DummyBlockValidationRule(co.rsk.validators.DummyBlockValidationRule) World(co.rsk.test.World) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator) SyncConfiguration(co.rsk.net.sync.SyncConfiguration) Test(org.junit.Test)

Example 2 with DummyBlockValidationRule

use of co.rsk.validators.DummyBlockValidationRule in project rskj by rsksmart.

the class NodeMessageHandlerUtil method createHandler.

public static NodeMessageHandler createHandler(BlockValidationRule validationRule) {
    final World world = new World();
    final BlockStore store = new BlockStore();
    final Blockchain blockchain = world.getBlockChain();
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    SyncConfiguration syncConfiguration = SyncConfiguration.IMMEDIATE_FOR_TESTING;
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    SyncProcessor syncProcessor = new SyncProcessor(config, blockchain, blockSyncService, RskMockFactory.getPeerScoringManager(), RskMockFactory.getChannelManager(), syncConfiguration, new DummyBlockValidationRule(), DIFFICULTY_CALCULATOR);
    NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    return new NodeMessageHandler(config, processor, syncProcessor, new SimpleChannelManager(), null, null, RskMockFactory.getPeerScoringManager(), validationRule);
}
Also used : SimpleChannelManager(org.ethereum.rpc.Simples.SimpleChannelManager) DummyBlockValidationRule(co.rsk.validators.DummyBlockValidationRule) Blockchain(org.ethereum.core.Blockchain) World(co.rsk.test.World) SyncConfiguration(co.rsk.net.sync.SyncConfiguration)

Example 3 with DummyBlockValidationRule

use of co.rsk.validators.DummyBlockValidationRule in project rskj by rsksmart.

the class SimpleAsyncNode method createNode.

public static SimpleAsyncNode createNode(Blockchain blockchain, SyncConfiguration syncConfiguration) {
    final BlockStore store = new BlockStore();
    BlockNodeInformation nodeInformation = new BlockNodeInformation();
    BlockSyncService blockSyncService = new BlockSyncService(config, store, blockchain, nodeInformation, syncConfiguration);
    NodeBlockProcessor processor = new NodeBlockProcessor(store, blockchain, nodeInformation, blockSyncService, syncConfiguration);
    DummyBlockValidationRule blockValidationRule = new DummyBlockValidationRule();
    PeerScoringManager peerScoringManager = RskMockFactory.getPeerScoringManager();
    SimpleChannelManager channelManager = new SimpleChannelManager();
    SyncProcessor syncProcessor = new SyncProcessor(config, blockchain, blockSyncService, peerScoringManager, channelManager, syncConfiguration, blockValidationRule, new DifficultyCalculator(config));
    NodeMessageHandler handler = new NodeMessageHandler(config, processor, syncProcessor, channelManager, null, null, peerScoringManager, blockValidationRule);
    return new SimpleAsyncNode(handler, syncProcessor, channelManager);
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) SimpleChannelManager(org.ethereum.rpc.Simples.SimpleChannelManager) DifficultyCalculator(co.rsk.core.DifficultyCalculator) DummyBlockValidationRule(co.rsk.validators.DummyBlockValidationRule)

Aggregations

DummyBlockValidationRule (co.rsk.validators.DummyBlockValidationRule)3 SyncConfiguration (co.rsk.net.sync.SyncConfiguration)2 World (co.rsk.test.World)2 SimpleChannelManager (org.ethereum.rpc.Simples.SimpleChannelManager)2 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)1 DifficultyCalculator (co.rsk.core.DifficultyCalculator)1 SimpleMessageChannel (co.rsk.net.simples.SimpleMessageChannel)1 PeerScoringManager (co.rsk.scoring.PeerScoringManager)1 Blockchain (org.ethereum.core.Blockchain)1 Test (org.junit.Test)1