Search in sources :

Example 1 with MockPeerConnection

use of org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection in project besu by hyperledger.

the class Istanbul99ProtocolManagerTest method setupPeer.

private MockPeerConnection setupPeer(final EthProtocolManager ethManager, final PeerSendHandler onSend) {
    final MockPeerConnection peer = setupPeerWithoutStatusExchange(ethManager, onSend);
    final StatusMessage statusMessage = StatusMessage.create(EthProtocol.EthVersion.V63, BigInteger.ONE, blockchain.getChainHead().getTotalDifficulty(), blockchain.getChainHeadHash(), blockchain.getBlockHeader(BlockHeader.GENESIS_BLOCK_NUMBER).get().getHash());
    ethManager.processMessage(Istanbul99Protocol.ISTANBUL99, new DefaultMessage(peer, statusMessage));
    return peer;
}
Also used : DefaultMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage) MockPeerConnection(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection) StatusMessage(org.hyperledger.besu.ethereum.eth.messages.StatusMessage)

Example 2 with MockPeerConnection

use of org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection in project besu by hyperledger.

the class Istanbul99ProtocolManagerTest method setupPeerWithoutStatusExchange.

private MockPeerConnection setupPeerWithoutStatusExchange(final EthProtocolManager ethManager, final PeerSendHandler onSend) {
    final Set<Capability> caps = new HashSet<>(Collections.singletonList(Istanbul99Protocol.ISTANBUL99));
    final MockPeerConnection peer = new MockPeerConnection(caps, onSend);
    ethManager.handleNewConnection(peer);
    return peer;
}
Also used : MockPeerConnection(org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection) Capability(org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability) HashSet(java.util.HashSet)

Aggregations

MockPeerConnection (org.hyperledger.besu.ethereum.eth.manager.MockPeerConnection)2 HashSet (java.util.HashSet)1 StatusMessage (org.hyperledger.besu.ethereum.eth.messages.StatusMessage)1 Capability (org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability)1 DefaultMessage (org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage)1