Search in sources :

Example 6 with TrieNodeWrapper

use of org.aion.zero.impl.sync.TrieNodeWrapper in project aion by aionnetwork.

the class ResponseTrieDataHandlerTest method testReceive_incorrectMessage.

@Test
public void testReceive_incorrectMessage() {
    Logger log = mock(Logger.class);
    when(log.isTraceEnabled()).thenReturn(false);
    BlockingQueue<TrieNodeWrapper> receivedQueue = mock(LinkedBlockingQueue.class);
    ResponseTrieDataHandler handler = new ResponseTrieDataHandler(log, receivedQueue);
    // receive incorrect message
    byte[] outOfOderEncoding = RLP.encodeList(RLP.encodeList(RLP.encodeList(RLP.encodeElement(nodeKey), RLP.encodeElement(leafValue)), RLP.encodeList(RLP.encodeElement(altNodeKey), RLP.encodeElement(leafValue))), RLP.encodeElement(nodeKey), RLP.encodeElement(leafValue), RLP.encodeString(STATE.toString()));
    handler.receive(peerId, displayId, outOfOderEncoding);
    verify(log, times(1)).error("<res-trie decode-error msg-bytes={} peer={}>", outOfOderEncoding.length, displayId);
    verifyZeroInteractions(receivedQueue);
}
Also used : TrieNodeWrapper(org.aion.zero.impl.sync.TrieNodeWrapper) Logger(org.slf4j.Logger) Test(org.junit.Test)

Aggregations

TrieNodeWrapper (org.aion.zero.impl.sync.TrieNodeWrapper)6 Test (org.junit.Test)6 Logger (org.slf4j.Logger)6 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ResponseTrieData (org.aion.zero.impl.sync.msg.ResponseTrieData)1