Search in sources :

Example 11 with PeerScoringManager

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

the class Web3ImplScoringTest method addBannedAddressUsingIPV6AndMask.

@Test
public void addBannedAddressUsingIPV6AndMask() throws UnknownHostException {
    PeerScoringManager peerScoringManager = createPeerScoringManager();
    Web3Impl web3 = createWeb3(peerScoringManager);
    InetAddress address = generateIPAddressV6();
    Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
    web3.sco_banAddress(address.getHostAddress() + "/64");
    Assert.assertFalse(peerScoringManager.hasGoodReputation(address));
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 12 with PeerScoringManager

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

the class Web3ImplScoringTest method addAndRemoveBannedAddressUsingIPV6AndMask.

@Test
public void addAndRemoveBannedAddressUsingIPV6AndMask() throws UnknownHostException {
    PeerScoringManager peerScoringManager = createPeerScoringManager();
    Web3Impl web3 = createWeb3(peerScoringManager);
    InetAddress address = generateIPAddressV6();
    Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
    web3.sco_banAddress(address.getHostAddress() + "/64");
    Assert.assertFalse(peerScoringManager.hasGoodReputation(address));
    web3.sco_unbanAddress(address.getHostAddress() + "/64");
    Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 13 with PeerScoringManager

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

the class Web3ImplScoringTest method addBannedAddressUsingIPV4AndMask.

@Test
public void addBannedAddressUsingIPV4AndMask() throws UnknownHostException {
    PeerScoringManager peerScoringManager = createPeerScoringManager();
    Web3Impl web3 = createWeb3(peerScoringManager);
    InetAddress address = generateNonLocalIPAddressV4();
    Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
    web3.sco_banAddress(address.getHostAddress() + "/8");
    Assert.assertFalse(peerScoringManager.hasGoodReputation(address));
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 14 with PeerScoringManager

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

the class Web3ImplScoringTest method addBannedAddressUsingIPV4.

@Test
public void addBannedAddressUsingIPV4() throws UnknownHostException {
    PeerScoringManager peerScoringManager = createPeerScoringManager();
    Web3Impl web3 = createWeb3(peerScoringManager);
    InetAddress address = generateNonLocalIPAddressV4();
    Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
    web3.sco_banAddress(address.getHostAddress());
    Assert.assertFalse(peerScoringManager.hasGoodReputation(address));
}
Also used : PeerScoringManager(co.rsk.scoring.PeerScoringManager) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 15 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)

Aggregations

PeerScoringManager (co.rsk.scoring.PeerScoringManager)31 Test (org.junit.Test)26 InetAddress (java.net.InetAddress)11 PeerScoring (co.rsk.scoring.PeerScoring)10 SimpleBlockProcessor (co.rsk.net.simples.SimpleBlockProcessor)9 SimpleMessageChannel (co.rsk.net.simples.SimpleMessageChannel)9 ProofOfWorkRule (co.rsk.validators.ProofOfWorkRule)7 DummyBlockValidationRule (co.rsk.validators.DummyBlockValidationRule)4 SimpleChannelManager (org.ethereum.rpc.Simples.SimpleChannelManager)4 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)3 TxHandler (co.rsk.net.handler.TxHandler)3 SimpleTransactionPool (co.rsk.net.simples.SimpleTransactionPool)3 NodeID (co.rsk.net.NodeID)2 PeerScoringInformation (co.rsk.scoring.PeerScoringInformation)2 JsonRpcInvalidParamException (org.ethereum.rpc.exception.JsonRpcInvalidParamException)2 DifficultyCalculator (co.rsk.core.DifficultyCalculator)1 RepositoryImpl (co.rsk.db.RepositoryImpl)1 TxHandlerImpl (co.rsk.net.handler.TxHandlerImpl)1 PunishmentParameters (co.rsk.scoring.PunishmentParameters)1 World (co.rsk.test.World)1