Search in sources :

Example 6 with NodeStatistics

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));
}
Also used : BlockMessage(co.rsk.net.messages.BlockMessage) GetBlockMessage(co.rsk.net.messages.GetBlockMessage) Message(co.rsk.net.messages.Message) BlockMessage(co.rsk.net.messages.BlockMessage) EthMessage(org.ethereum.net.eth.message.EthMessage) StatusMessage(org.ethereum.net.eth.message.StatusMessage) GetBlockMessage(co.rsk.net.messages.GetBlockMessage) NodeStatistics(org.ethereum.net.NodeStatistics) EthMessage(org.ethereum.net.eth.message.EthMessage) Block(org.ethereum.core.Block) Keccak256(co.rsk.crypto.Keccak256) Test(org.junit.Test)

Example 7 with NodeStatistics

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));
}
Also used : NodeStatistics(org.ethereum.net.NodeStatistics) EthMessage(org.ethereum.net.eth.message.EthMessage) StatusMessage(org.ethereum.net.eth.message.StatusMessage) Test(org.junit.Test)

Example 8 with NodeStatistics

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));
}
Also used : Status(co.rsk.net.Status) Message(co.rsk.net.messages.Message) BlockMessage(co.rsk.net.messages.BlockMessage) EthMessage(org.ethereum.net.eth.message.EthMessage) StatusMessage(org.ethereum.net.eth.message.StatusMessage) GetBlockMessage(co.rsk.net.messages.GetBlockMessage) NodeStatistics(org.ethereum.net.NodeStatistics) EthMessage(org.ethereum.net.eth.message.EthMessage) StatusMessage(org.ethereum.net.eth.message.StatusMessage) Test(org.junit.Test)

Aggregations

NodeStatistics (org.ethereum.net.NodeStatistics)8 Test (org.junit.Test)7 EthMessage (org.ethereum.net.eth.message.EthMessage)6 StatusMessage (org.ethereum.net.eth.message.StatusMessage)6 BlockMessage (co.rsk.net.messages.BlockMessage)3 GetBlockMessage (co.rsk.net.messages.GetBlockMessage)3 Message (co.rsk.net.messages.Message)3 Keccak256 (co.rsk.crypto.Keccak256)2 Status (co.rsk.net.Status)2 RskSystemProperties (co.rsk.config.RskSystemProperties)1 TestSystemProperties (co.rsk.config.TestSystemProperties)1 BlockDifficulty (co.rsk.core.BlockDifficulty)1 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 Block (org.ethereum.core.Block)1 ConfigCapabilitiesImpl (org.ethereum.net.client.ConfigCapabilitiesImpl)1 Channel (org.ethereum.net.server.Channel)1 Before (org.junit.Before)1