use of org.aion.zero.impl.sync.msg.ResponseTrieData in project aion by aionnetwork.
the class RequestTrieDataHandlerTest method testReceive_correctMessage_limitZero_akaMaxBatchSize.
@Test
public void testReceive_correctMessage_limitZero_akaMaxBatchSize() {
Logger log = mock(Logger.class);
when(log.isDebugEnabled()).thenReturn(true);
IAionBlockchain chain = mock(AionBlockchainImpl.class);
when(chain.getTrieNode(nodeKey, STATE)).thenReturn(leafValue);
when(chain.getReferencedTrieNodes(leafValue, TRIE_DATA_REQUEST_MAXIMUM_BATCH_SIZE, STATE)).thenReturn(multipleReferences);
IP2pMgr p2p = mock(P2pMgr.class);
RequestTrieDataHandler handler = new RequestTrieDataHandler(log, chain, p2p);
// receive correct message
byte[] encoding = RLP.encodeList(RLP.encodeElement(nodeKey), RLP.encodeString(STATE.toString()), RLP.encodeInt(0));
handler.receive(peerId, displayId, encoding);
verify(log, times(1)).debug("<req-trie from-db={} key={} peer={}>", STATE, wrappedNodeKey, displayId);
verify(chain, times(1)).getTrieNode(nodeKey, STATE);
verify(chain, times(1)).getReferencedTrieNodes(leafValue, TRIE_DATA_REQUEST_MAXIMUM_BATCH_SIZE, STATE);
ResponseTrieData expectedResponse = new ResponseTrieData(wrappedNodeKey, leafValue, multipleReferences, STATE);
verify(p2p, times(1)).send(peerId, displayId, expectedResponse);
}
Aggregations