Search in sources :

Example 16 with Message

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

the class WriterMessageRecorderTest method recordRskMessageWithSender.

@Test
public void recordRskMessageWithSender() throws IOException {
    Message message = createRskMessage();
    StringWriter writer = new StringWriter();
    BufferedWriter bwriter = new BufferedWriter(writer);
    Random random = new Random();
    byte[] nodeId = new byte[10];
    random.nextBytes(nodeId);
    NodeID sender = new NodeID(nodeId);
    WriterMessageRecorder recorder = new WriterMessageRecorder(bwriter, null);
    recorder.recordMessage(sender, message);
    bwriter.close();
    String result = writer.toString();
    String encoded = Hex.toHexString(message.getEncoded());
    Assert.assertTrue(result.contains("," + encoded + "," + Hex.toHexString(nodeId)));
    Assert.assertTrue(result.contains(",0,RSK_MESSAGE,GET_BLOCK_MESSAGE,"));
}
Also used : Message(org.ethereum.net.message.Message) GetBlockMessage(co.rsk.net.messages.GetBlockMessage) TransactionsMessage(org.ethereum.net.eth.message.TransactionsMessage) StringWriter(java.io.StringWriter) Random(java.util.Random) NodeID(co.rsk.net.NodeID) BufferedWriter(java.io.BufferedWriter) Test(org.junit.Test)

Aggregations

Message (org.ethereum.net.message.Message)16 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)7 GetBlockMessage (co.rsk.net.messages.GetBlockMessage)4 BufferedWriter (java.io.BufferedWriter)4 StringWriter (java.io.StringWriter)4 TransactionsMessage (org.ethereum.net.eth.message.TransactionsMessage)4 DisconnectMessage (org.ethereum.net.p2p.DisconnectMessage)3 Frame (org.ethereum.net.rlpx.FrameCodec.Frame)3 NodeID (co.rsk.net.NodeID)2 Random (java.util.Random)2 EthMessage (org.ethereum.net.eth.message.EthMessage)2 PingMessage (org.ethereum.net.p2p.PingMessage)2 ByteBuf (io.netty.buffer.ByteBuf)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 HelloMessage (org.ethereum.net.p2p.HelloMessage)1 P2pMessageFactory (org.ethereum.net.p2p.P2pMessageFactory)1 InvalidCipherTextException (org.spongycastle.crypto.InvalidCipherTextException)1 ECPoint (org.spongycastle.math.ec.ECPoint)1