use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class Web3ImplScoringTest method addAndRemoveBannedAddressUsingIPV4AndMask.
@Test
public void addAndRemoveBannedAddressUsingIPV4AndMask() throws UnknownHostException {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
// generate a random non-local IPv4 address
InetAddress address = generateNonLocalIPAddressV4();
Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
web3.sco_banAddress(address.getHostAddress() + "/8");
Assert.assertFalse(peerScoringManager.hasGoodReputation(address));
web3.sco_unbanAddress(address.getHostAddress() + "/8");
Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
}
use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class Web3ImplScoringTest method removeBannedAddressWithInvalidMask.
@Test
public void removeBannedAddressWithInvalidMask() throws UnknownHostException {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
try {
web3.sco_unbanAddress("192.168.56.1/a");
Assert.fail();
} catch (JsonRpcInvalidParamException ex) {
Assert.assertEquals("invalid banned address 192.168.56.1/a", ex.getMessage());
}
}
use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class Web3ImplScoringTest method addAndRemoveBannedAddressUsingIPV6.
@Test
public void addAndRemoveBannedAddressUsingIPV6() throws UnknownHostException {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
InetAddress address = generateIPAddressV6();
Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
web3.sco_banAddress(address.getHostAddress());
Assert.assertFalse(peerScoringManager.hasGoodReputation(address));
web3.sco_unbanAddress(address.getHostAddress());
Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
}
use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class Web3ImplScoringTest method getAddressListWithOneElement.
@Test
public void getAddressListWithOneElement() {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
web3.sco_banAddress("192.168.56.1");
String[] result = web3.sco_bannedAddresses();
Assert.assertNotNull(result);
Assert.assertEquals(1, result.length);
Assert.assertEquals("192.168.56.1", result[0]);
}
use of co.rsk.scoring.PeerScoringManager in project rskj by rsksmart.
the class Web3ImplScoringTest method addAndRemoveBannedAddressUsingIPV4.
@Test
public void addAndRemoveBannedAddressUsingIPV4() throws UnknownHostException {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
// generate a random non-local IPv4 address
InetAddress address = generateNonLocalIPAddressV4();
Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
web3.sco_banAddress(address.getHostAddress());
Assert.assertFalse(peerScoringManager.hasGoodReputation(address));
web3.sco_unbanAddress(address.getHostAddress());
Assert.assertTrue(peerScoringManager.hasGoodReputation(address));
}
Aggregations