use of org.ethereum.net.NodeStatistics in project rskj by rsksmart.
the class RskWireProtocolTest method channelRead0_block_message.
@Test
public void channelRead0_block_message() throws Exception {
NodeStatistics.StatHandler statHandler = mock(NodeStatistics.StatHandler.class);
NodeStatistics nodeStatistics = mock(NodeStatistics.class);
when(channel.getNodeStatistics()).thenReturn(nodeStatistics);
when(nodeStatistics.getEthInbound()).thenReturn(statHandler);
Block block = mock(Block.class);
when(block.getHash()).thenReturn(new Keccak256(new byte[32]));
Message message = new BlockMessage(block);
EthMessage rskMessage = new RskMessage(message);
target.channelRead0(ctx, rskMessage);
verify(messageHandler).postMessage(eq(channel), eq(message));
}
use of org.ethereum.net.NodeStatistics in project rskj by rsksmart.
the class RskWireProtocolTest method channelRead0_old_status_incompatible_protocol.
@Test
public void channelRead0_old_status_incompatible_protocol() throws Exception {
NodeStatistics.StatHandler statHandler = mock(NodeStatistics.StatHandler.class);
NodeStatistics nodeStatistics = mock(NodeStatistics.class);
when(channel.getNodeStatistics()).thenReturn(nodeStatistics);
when(nodeStatistics.getEthInbound()).thenReturn(statHandler);
EthMessage message = new StatusMessage((byte) 0x0, 0x0, ByteUtil.bigIntegerToBytes(BigInteger.valueOf(10)), new byte[32], new byte[32]);
target.channelRead0(ctx, message);
verify(messageQueue).disconnect(eq(ReasonCode.INCOMPATIBLE_PROTOCOL));
}
use of org.ethereum.net.NodeStatistics in project rskj by rsksmart.
the class RskWireProtocolTest method channelRead0_status_message.
@Test
public void channelRead0_status_message() throws Exception {
NodeStatistics.StatHandler statHandler = mock(NodeStatistics.StatHandler.class);
NodeStatistics nodeStatistics = mock(NodeStatistics.class);
when(channel.getNodeStatistics()).thenReturn(nodeStatistics);
when(nodeStatistics.getEthInbound()).thenReturn(statHandler);
Status status = mock(Status.class);
when(status.getBestBlockHash()).thenReturn(new byte[32]);
Message message = new co.rsk.net.messages.StatusMessage(status);
EthMessage rskMessage = new RskMessage(message);
target.channelRead0(ctx, rskMessage);
verify(messageHandler).postMessage(eq(channel), eq(message));
}
Aggregations