use of org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage in project besu by hyperledger.
the class QbftControllerTest method setupPrepare.
private void setupPrepare(final ConsensusRoundIdentifier roundIdentifier, final Address validator) {
when(prepare.getAuthor()).thenReturn(validator);
when(prepare.getRoundIdentifier()).thenReturn(roundIdentifier);
when(prepareMessageData.getCode()).thenReturn(QbftV1.PREPARE);
when(prepareMessageData.decode()).thenReturn(prepare);
prepareMessage = new DefaultMessage(null, prepareMessageData);
}
use of org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage in project besu by hyperledger.
the class QbftControllerTest method setupCommit.
private void setupCommit(final ConsensusRoundIdentifier roundIdentifier, final Address validator) {
when(commit.getAuthor()).thenReturn(validator);
when(commit.getRoundIdentifier()).thenReturn(roundIdentifier);
when(commitMessageData.getCode()).thenReturn(QbftV1.COMMIT);
when(commitMessageData.decode()).thenReturn(commit);
commitMessage = new DefaultMessage(null, commitMessageData);
}
use of org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage in project besu by hyperledger.
the class QbftControllerTest method setupProposal.
private void setupProposal(final ConsensusRoundIdentifier roundIdentifier, final Address validator) {
when(proposal.getAuthor()).thenReturn(validator);
when(proposal.getRoundIdentifier()).thenReturn(roundIdentifier);
when(proposalMessageData.getCode()).thenReturn(QbftV1.PROPOSAL);
when(proposalMessageData.decode(bftExtraDataCodec)).thenReturn(proposal);
proposalMessage = new DefaultMessage(null, proposalMessageData);
}
use of org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage in project besu by hyperledger.
the class Istanbul99ProtocolManagerTest method respondToEth65GetHeadersUsingIstanbul99.
@Test
public void respondToEth65GetHeadersUsingIstanbul99() throws ExecutionException, InterruptedException, TimeoutException {
final CompletableFuture<Void> done = new CompletableFuture<>();
final EthScheduler ethScheduler = new DeterministicEthScheduler(() -> false);
EthPeers peers = new EthPeers(Istanbul99Protocol.NAME, TestClock.fixed(), new NoOpMetricsSystem(), 25);
EthMessages messages = new EthMessages();
final BigInteger networkId = BigInteger.ONE;
try (final EthProtocolManager ethManager = new Istanbul99ProtocolManager(blockchain, networkId, protocolContext.getWorldStateArchive(), transactionPool, EthProtocolConfiguration.defaultConfig(), peers, messages, new EthContext(peers, messages, ethScheduler), Collections.emptyList(), false, ethScheduler)) {
final long startBlock = blockchain.getChainHeadBlockNumber() + 1;
final int blockCount = 5;
final MessageData messageData = GetBlockHeadersMessage.create(startBlock, blockCount, 0, false);
final PeerSendHandler onSend = (cap, message, conn) -> {
if (message.getCode() == EthPV62.STATUS) {
// Ignore status message
return;
}
assertThat(message.getCode()).isEqualTo(EthPV62.BLOCK_HEADERS);
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message);
final List<BlockHeader> headers = Lists.newArrayList(headersMsg.getHeaders(protocolSchedule));
assertThat(headers.size()).isEqualTo(0);
done.complete(null);
};
final PeerConnection peer = setupPeer(ethManager, onSend);
ethManager.processMessage(Istanbul99Protocol.ISTANBUL99, new DefaultMessage(peer, messageData));
done.get(10, TimeUnit.SECONDS);
}
}
use of org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage in project besu by hyperledger.
the class IbftControllerTest method setupPrepare.
private void setupPrepare(final ConsensusRoundIdentifier roundIdentifier, final Address validator) {
when(prepare.getAuthor()).thenReturn(validator);
when(prepare.getRoundIdentifier()).thenReturn(roundIdentifier);
when(prepareMessageData.getCode()).thenReturn(IbftV2.PREPARE);
when(prepareMessageData.decode()).thenReturn(prepare);
prepareMessage = new DefaultMessage(null, prepareMessageData);
}
Aggregations