use of co.rsk.scoring.PeerScoringInformation in project rskj by rsksmart.
the class Web3ImplScoringTest method getPeerList.
@Test
public void getPeerList() throws UnknownHostException {
NodeID node = generateNodeID();
InetAddress address = generateNonLocalIPAddressV4();
PeerScoringManager peerScoringManager = createPeerScoringManager();
peerScoringManager.recordEvent(node, address, EventType.VALID_BLOCK);
peerScoringManager.recordEvent(node, address, EventType.VALID_TRANSACTION);
peerScoringManager.recordEvent(node, address, EventType.VALID_BLOCK);
Web3Impl web3 = createWeb3(peerScoringManager);
PeerScoringInformation[] result = web3.sco_peerList();
Assert.assertNotNull(result);
Assert.assertEquals(2, result.length);
PeerScoringInformation info = result[0];
Assert.assertEquals(Hex.toHexString(node.getID()).substring(0, 8), info.getId());
Assert.assertEquals(2, info.getValidBlocks());
Assert.assertEquals(0, info.getInvalidBlocks());
Assert.assertEquals(1, info.getValidTransactions());
Assert.assertEquals(0, info.getInvalidTransactions());
Assert.assertTrue(info.getScore() > 0);
info = result[1];
Assert.assertEquals(address.getHostAddress(), info.getId());
Assert.assertEquals(2, info.getValidBlocks());
Assert.assertEquals(0, info.getInvalidBlocks());
Assert.assertEquals(1, info.getValidTransactions());
Assert.assertEquals(0, info.getInvalidTransactions());
Assert.assertTrue(info.getScore() > 0);
}
use of co.rsk.scoring.PeerScoringInformation in project rskj by rsksmart.
the class Web3ImplScoringTest method getEmptyPeerList.
@Test
public void getEmptyPeerList() {
PeerScoringManager peerScoringManager = createPeerScoringManager();
Web3Impl web3 = createWeb3(peerScoringManager);
PeerScoringInformation[] result = web3.sco_peerList();
Assert.assertNotNull(result);
Assert.assertEquals(0, result.length);
}
Aggregations