Search in sources :

Example 1 with Message

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

the class MessageFilterTest method rejectRskMessageIfMessageTypeDoesNotMatch.

@Test
public void rejectRskMessageIfMessageTypeDoesNotMatch() {
    List<String> commands = new ArrayList<>();
    commands.add("RSK_MESSAGE:GET_BLOCKS_MESSAGE");
    commands.add("TRANSACTIONS");
    commands.add("BLOCKS");
    MessageFilter filter = new MessageFilter(commands);
    Message rskMessage = WriterMessageRecorderTest.createRskMessage();
    Message ethMessage = WriterMessageRecorderTest.createEthMessage();
    Assert.assertFalse(filter.acceptMessage(rskMessage));
    Assert.assertTrue(filter.acceptMessage(ethMessage));
}
Also used : Message(org.ethereum.net.message.Message) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with Message

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

the class MessageFilterTest method filterAcceptRskMessageWhenCommandIsSpecified.

@Test
public void filterAcceptRskMessageWhenCommandIsSpecified() {
    List<String> commands = new ArrayList<>();
    commands.add("RSK_MESSAGE");
    MessageFilter filter = new MessageFilter(commands);
    Message rskMessage = WriterMessageRecorderTest.createRskMessage();
    Message ethMessage = WriterMessageRecorderTest.createEthMessage();
    Assert.assertTrue(filter.acceptMessage(rskMessage));
    Assert.assertFalse(filter.acceptMessage(ethMessage));
}
Also used : Message(org.ethereum.net.message.Message) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with Message

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

the class MessageFilterTest method filterMessagesWhenRskMessageTypeIsSpecified.

@Test
public void filterMessagesWhenRskMessageTypeIsSpecified() {
    List<String> commands = new ArrayList<>();
    commands.add("RSK_MESSAGE:GET_BLOCK_MESSAGE");
    commands.add("TRANSACTIONS");
    commands.add("BLOCKS");
    MessageFilter filter = new MessageFilter(commands);
    Message rskMessage = WriterMessageRecorderTest.createRskMessage();
    Message ethMessage = WriterMessageRecorderTest.createEthMessage();
    Assert.assertTrue(filter.acceptMessage(rskMessage));
    Assert.assertTrue(filter.acceptMessage(ethMessage));
}
Also used : Message(org.ethereum.net.message.Message) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with Message

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

the class MessageFilterTest method filterWithEmptyCommandsAcceptsAnyMessage.

@Test
public void filterWithEmptyCommandsAcceptsAnyMessage() {
    List<String> commands = new ArrayList<>();
    MessageFilter filter = new MessageFilter(commands);
    Message rskMessage = WriterMessageRecorderTest.createRskMessage();
    Message ethMessage = WriterMessageRecorderTest.createEthMessage();
    Assert.assertTrue(filter.acceptMessage(rskMessage));
    Assert.assertTrue(filter.acceptMessage(ethMessage));
}
Also used : Message(org.ethereum.net.message.Message) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with Message

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

the class MessageFilterTest method filterAcceptsEthMessageWhenCommandIsSpecified.

@Test
public void filterAcceptsEthMessageWhenCommandIsSpecified() {
    List<String> commands = new ArrayList<>();
    commands.add("TRANSACTIONS");
    MessageFilter filter = new MessageFilter(commands);
    Message rskMessage = WriterMessageRecorderTest.createRskMessage();
    Message ethMessage = WriterMessageRecorderTest.createEthMessage();
    Assert.assertFalse(filter.acceptMessage(rskMessage));
    Assert.assertTrue(filter.acceptMessage(ethMessage));
}
Also used : Message(org.ethereum.net.message.Message) ArrayList(java.util.ArrayList) 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