Search in sources :

Example 1 with StatusMessage

use of org.ethereum.net.eth.message.StatusMessage in project rskj by rsksmart.

the class StatusMessageTest method test1.

// Eth 60
@Test
public void test1() {
    byte[] payload = Hex.decode("f84927808425c60144a0832056d3c93ff2739ace7199952e5365aa29f18805be05634c4db125c5340216a0955f36d073ccb026b78ab3424c15cf966a7563aa270413859f78702b9e8e22cb");
    StatusMessage statusMessage = new StatusMessage(payload);
    logger.info(statusMessage.toString());
    assertEquals(39, statusMessage.getProtocolVersion());
    assertEquals("25c60144", ByteUtil.toHexString(statusMessage.getTotalDifficulty()));
    assertEquals("832056d3c93ff2739ace7199952e5365aa29f18805be05634c4db125c5340216", ByteUtil.toHexString(statusMessage.getBestHash()));
}
Also used : StatusMessage(org.ethereum.net.eth.message.StatusMessage) Test(org.junit.Test)

Example 2 with StatusMessage

use of org.ethereum.net.eth.message.StatusMessage in project rskj by rsksmart.

the class RskWireProtocolTest method channelRead0_old_status_unexpected_genesis.

@Test
public void channelRead0_old_status_unexpected_genesis() 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(EthVersion.V62.getCode(), 0x0, ByteUtil.bigIntegerToBytes(BigInteger.valueOf(10)), new byte[32], new byte[32]);
    target.channelRead0(ctx, message);
    verify(messageQueue).disconnect(eq(ReasonCode.UNEXPECTED_GENESIS));
}
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 3 with StatusMessage

use of org.ethereum.net.eth.message.StatusMessage in project rskj by rsksmart.

the class RskWireProtocolTest method channelRead0_old_status_invalid_network.

@Test
public void channelRead0_old_status_invalid_network() 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(EthVersion.V62.getCode(), 0x1, ByteUtil.bigIntegerToBytes(BigInteger.valueOf(10)), new byte[32], new byte[32]);
    target.channelRead0(ctx, message);
    verify(messageQueue).disconnect(eq(ReasonCode.NULL_IDENTITY));
}
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 4 with StatusMessage

use of org.ethereum.net.eth.message.StatusMessage 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)

Aggregations

StatusMessage (org.ethereum.net.eth.message.StatusMessage)4 Test (org.junit.Test)4 NodeStatistics (org.ethereum.net.NodeStatistics)3 EthMessage (org.ethereum.net.eth.message.EthMessage)3