Search in sources :

Example 1 with PeerScoringManager

use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.

the class NodeMessageHandlerUtil method createHandlerWithSyncProcessor.

public static NodeMessageHandler createHandlerWithSyncProcessor(Blockchain blockchain, SyncConfiguration syncConfiguration, ChannelManager channelManager) {
    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);
    ProofOfWorkRule blockValidationRule = new ProofOfWorkRule(config);
    PeerScoringManager peerScoringManager = mock(PeerScoringManager.class);
    Mockito.when(peerScoringManager.hasGoodReputation(isA(NodeID.class))).thenReturn(true);
    SyncProcessor syncProcessor = new SyncProcessor(config, blockchain, blockSyncService, peerScoringManager, channelManager, syncConfiguration, blockValidationRule, DIFFICULTY_CALCULATOR);
    return new NodeMessageHandler(config, processor, syncProcessor, channelManager, null, null, null, blockValidationRule);
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) ProofOfWorkRule(co.rsk.validators.ProofOfWorkRule)

Example 2 with PeerScoringManager

use of co.rsk.scoring.PeerScoringManager 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)

Example 3 with PeerScoringManager

use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.

the class Web3ImplScoringTest method getAddressListWithTwoElements.

@Test
public void getAddressListWithTwoElements() {
    PeerScoringManager peerScoringManager = createPeerScoringManager();
    Web3Impl web3 = createWeb3(peerScoringManager);
    web3.sco_banAddress("192.168.56.1");
    web3.sco_banAddress("192.168.56.2");
    String[] result = web3.sco_bannedAddresses();
    Assert.assertNotNull(result);
    Assert.assertEquals(2, result.length);
    Assert.assertTrue("192.168.56.1".equals(result[0]) || "192.168.56.1".equals(result[1]));
    Assert.assertTrue("192.168.56.2".equals(result[0]) || "192.168.56.2".equals(result[1]));
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) Test(org.junit.Test)

Example 4 with PeerScoringManager

use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.

the class Web3ImplScoringTest method getEmptyBannedAddressList.

@Test
public void getEmptyBannedAddressList() {
    PeerScoringManager peerScoringManager = createPeerScoringManager();
    Web3Impl web3 = createWeb3(peerScoringManager);
    String[] result = web3.sco_bannedAddresses();
    Assert.assertNotNull(result);
    Assert.assertEquals(0, result.length);
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) Test(org.junit.Test)

Example 5 with PeerScoringManager

use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.

the class Web3ImplScoringTest method getAddressListWithOneElementUsingMask.

@Test
public void getAddressListWithOneElementUsingMask() {
    PeerScoringManager peerScoringManager = createPeerScoringManager();
    Web3Impl web3 = createWeb3(peerScoringManager);
    web3.sco_banAddress("192.168.56.1/16");
    String[] result = web3.sco_bannedAddresses();
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.length);
    Assert.assertEquals("192.168.56.1/16", result[0]);
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) Test(org.junit.Test)

Aggregations

PeerScoringManager (co.rsk.scoring.PeerScoringManager)30 Test (org.junit.Test)21 SimplePeer (co.rsk.net.simples.SimplePeer)14 SimpleBlockProcessor (co.rsk.net.simples.SimpleBlockProcessor)11 PeerScoring (co.rsk.scoring.PeerScoring)11 RskSystemProperties (co.rsk.config.RskSystemProperties)5 NodeID (co.rsk.net.NodeID)5 BlockChainBuilder (co.rsk.test.builders.BlockChainBuilder)5 SimpleChannelManager (org.ethereum.rpc.Simples.SimpleChannelManager)4 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)3 InetSocketAddress (java.net.InetSocketAddress)3 Blockchain (org.ethereum.core.Blockchain)3 Genesis (org.ethereum.core.Genesis)3 BlockStore (org.ethereum.db.BlockStore)3 CompositeEthereumListener (org.ethereum.listener.CompositeEthereumListener)3 DifficultyCalculator (co.rsk.core.DifficultyCalculator)2 RskAddress (co.rsk.core.RskAddress)2 ConsensusValidationMainchainView (co.rsk.core.bc.ConsensusValidationMainchainView)2 PeersInformation (co.rsk.net.sync.PeersInformation)2 PunishmentParameters (co.rsk.scoring.PunishmentParameters)2