remove protocol name (#7922)

Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
pull/7945/head
Stefan Pingel 1 week ago committed by GitHub
parent 58fbbe3c37
commit 126debbd92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  2. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/PeerResult.java
  3. 3
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AdminJsonRpcHttpServiceTest.java
  4. 1
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminPeersTest.java
  5. 39
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeer.java
  6. 7
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java
  7. 5
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/task/GetReceiptsFromPeerTask.java
  8. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthPeerTest.java
  9. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTestUtil.java
  10. 1
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/RequestManagerTest.java
  11. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java
  12. 1
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/PeerMessageTaskTest.java
  13. 9
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/peertask/task/GetReceiptsFromPeerTaskTest.java
  14. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/AbstractBlockPropagationManagerTest.java
  15. 1
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java
  16. 1
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java

@ -625,7 +625,6 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
ethereumWireProtocolConfiguration.isLegacyEth64ForkIdEnabled()); ethereumWireProtocolConfiguration.isLegacyEth64ForkIdEnabled());
final EthPeers ethPeers = final EthPeers ethPeers =
new EthPeers( new EthPeers(
EthProtocol.NAME,
currentProtocolSpecSupplier, currentProtocolSpecSupplier,
clock, clock,
metricsSystem, metricsSystem,

@ -14,6 +14,7 @@
*/ */
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.manager.EthPeer; import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability;
@ -52,7 +53,7 @@ public interface PeerResult {
connection.inboundInitiated())) connection.inboundInitiated()))
.port(Quantity.create(peerInfo.getPort())) .port(Quantity.create(peerInfo.getPort()))
.id(peerInfo.getNodeId().toString()) .id(peerInfo.getNodeId().toString())
.protocols(Map.of(peer.getProtocolName(), ProtocolsResult.fromEthPeer(peer))) .protocols(Map.of(EthProtocol.NAME, ProtocolsResult.fromEthPeer(peer)))
.enode(connection.getRemoteEnode().toString()) .enode(connection.getRemoteEnode().toString())
.build(); .build();
} }

@ -74,7 +74,6 @@ public class AdminJsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
peerList.add( peerList.add(
new EthPeer( new EthPeer(
MockPeerConnection.create(info1, addr60301, addr30302), MockPeerConnection.create(info1, addr60301, addr30302),
"eth",
c -> {}, c -> {},
List.of(), List.of(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE, EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
@ -84,7 +83,6 @@ public class AdminJsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
peerList.add( peerList.add(
new EthPeer( new EthPeer(
MockPeerConnection.create(info2, addr30301, addr60302), MockPeerConnection.create(info2, addr30301, addr60302),
"eth",
c -> {}, c -> {},
List.of(), List.of(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE, EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
@ -94,7 +92,6 @@ public class AdminJsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
peerList.add( peerList.add(
new EthPeer( new EthPeer(
MockPeerConnection.create(info3, addr30301, addr60303), MockPeerConnection.create(info3, addr30301, addr60303),
"eth",
c -> {}, c -> {},
List.of(), List.of(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE, EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

@ -120,7 +120,6 @@ public class AdminPeersTest {
final EthPeer ethPeer = final EthPeer ethPeer =
new EthPeer( new EthPeer(
p, p,
"eth",
c -> {}, c -> {},
List.of(), List.of(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE, EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

@ -85,7 +85,6 @@ public class EthPeer implements Comparable<EthPeer> {
private Optional<BlockHeader> checkpointHeader = Optional.empty(); private Optional<BlockHeader> checkpointHeader = Optional.empty();
private final String protocolName;
private final int maxMessageSize; private final int maxMessageSize;
private final Clock clock; private final Clock clock;
private final List<NodeMessagePermissioningProvider> permissioningProviders; private final List<NodeMessagePermissioningProvider> permissioningProviders;
@ -124,7 +123,6 @@ public class EthPeer implements Comparable<EthPeer> {
@VisibleForTesting @VisibleForTesting
public EthPeer( public EthPeer(
final PeerConnection connection, final PeerConnection connection,
final String protocolName,
final Consumer<EthPeer> onStatusesExchanged, final Consumer<EthPeer> onStatusesExchanged,
final List<PeerValidator> peerValidators, final List<PeerValidator> peerValidators,
final int maxMessageSize, final int maxMessageSize,
@ -132,7 +130,6 @@ public class EthPeer implements Comparable<EthPeer> {
final List<NodeMessagePermissioningProvider> permissioningProviders, final List<NodeMessagePermissioningProvider> permissioningProviders,
final Bytes localNodeId) { final Bytes localNodeId) {
this.connection = connection; this.connection = connection;
this.protocolName = protocolName;
this.maxMessageSize = maxMessageSize; this.maxMessageSize = maxMessageSize;
this.clock = clock; this.clock = clock;
this.permissioningProviders = permissioningProviders; this.permissioningProviders = permissioningProviders;
@ -153,21 +150,23 @@ public class EthPeer implements Comparable<EthPeer> {
getAgreedCapabilities().stream().anyMatch(EthProtocol::isEth66Compatible); getAgreedCapabilities().stream().anyMatch(EthProtocol::isEth66Compatible);
// eth protocol // eth protocol
requestManagers.put( requestManagers.put(
protocolName, EthProtocol.NAME,
Map.ofEntries( Map.ofEntries(
Map.entry( Map.entry(
EthPV62.GET_BLOCK_HEADERS, EthPV62.GET_BLOCK_HEADERS,
new RequestManager(this, supportsRequestId, protocolName)), new RequestManager(this, supportsRequestId, EthProtocol.NAME)),
Map.entry( Map.entry(
EthPV62.GET_BLOCK_BODIES, EthPV62.GET_BLOCK_BODIES,
new RequestManager(this, supportsRequestId, protocolName)), new RequestManager(this, supportsRequestId, EthProtocol.NAME)),
Map.entry( Map.entry(
EthPV63.GET_RECEIPTS, new RequestManager(this, supportsRequestId, protocolName)), EthPV63.GET_RECEIPTS,
new RequestManager(this, supportsRequestId, EthProtocol.NAME)),
Map.entry( Map.entry(
EthPV63.GET_NODE_DATA, new RequestManager(this, supportsRequestId, protocolName)), EthPV63.GET_NODE_DATA,
new RequestManager(this, supportsRequestId, EthProtocol.NAME)),
Map.entry( Map.entry(
EthPV65.GET_POOLED_TRANSACTIONS, EthPV65.GET_POOLED_TRANSACTIONS,
new RequestManager(this, supportsRequestId, protocolName)))); new RequestManager(this, supportsRequestId, EthProtocol.NAME))));
} }
private void initSnapRequestManagers() { private void initSnapRequestManagers() {
@ -237,7 +236,7 @@ public class EthPeer implements Comparable<EthPeer> {
} }
public RequestManager.ResponseStream send(final MessageData messageData) throws PeerNotConnected { public RequestManager.ResponseStream send(final MessageData messageData) throws PeerNotConnected {
return send(messageData, this.protocolName); return send(messageData, EthProtocol.NAME);
} }
public RequestManager.ResponseStream send( public RequestManager.ResponseStream send(
@ -317,7 +316,7 @@ public class EthPeer implements Comparable<EthPeer> {
final GetBlockHeadersMessage message = final GetBlockHeadersMessage message =
GetBlockHeadersMessage.create(hash, maxHeaders, skip, reverse); GetBlockHeadersMessage.create(hash, maxHeaders, skip, reverse);
final RequestManager requestManager = final RequestManager requestManager =
requestManagers.get(protocolName).get(EthPV62.GET_BLOCK_HEADERS); requestManagers.get(EthProtocol.NAME).get(EthPV62.GET_BLOCK_HEADERS);
return sendRequest(requestManager, message); return sendRequest(requestManager, message);
} }
@ -326,32 +325,34 @@ public class EthPeer implements Comparable<EthPeer> {
throws PeerNotConnected { throws PeerNotConnected {
final GetBlockHeadersMessage message = final GetBlockHeadersMessage message =
GetBlockHeadersMessage.create(blockNumber, maxHeaders, skip, reverse); GetBlockHeadersMessage.create(blockNumber, maxHeaders, skip, reverse);
return sendRequest(requestManagers.get(protocolName).get(EthPV62.GET_BLOCK_HEADERS), message); return sendRequest(
requestManagers.get(EthProtocol.NAME).get(EthPV62.GET_BLOCK_HEADERS), message);
} }
public RequestManager.ResponseStream getBodies(final List<Hash> blockHashes) public RequestManager.ResponseStream getBodies(final List<Hash> blockHashes)
throws PeerNotConnected { throws PeerNotConnected {
final GetBlockBodiesMessage message = GetBlockBodiesMessage.create(blockHashes); final GetBlockBodiesMessage message = GetBlockBodiesMessage.create(blockHashes);
return sendRequest(requestManagers.get(protocolName).get(EthPV62.GET_BLOCK_BODIES), message); return sendRequest(
requestManagers.get(EthProtocol.NAME).get(EthPV62.GET_BLOCK_BODIES), message);
} }
public RequestManager.ResponseStream getReceipts(final List<Hash> blockHashes) public RequestManager.ResponseStream getReceipts(final List<Hash> blockHashes)
throws PeerNotConnected { throws PeerNotConnected {
final GetReceiptsMessage message = GetReceiptsMessage.create(blockHashes); final GetReceiptsMessage message = GetReceiptsMessage.create(blockHashes);
return sendRequest(requestManagers.get(protocolName).get(EthPV63.GET_RECEIPTS), message); return sendRequest(requestManagers.get(EthProtocol.NAME).get(EthPV63.GET_RECEIPTS), message);
} }
public RequestManager.ResponseStream getNodeData(final Iterable<Hash> nodeHashes) public RequestManager.ResponseStream getNodeData(final Iterable<Hash> nodeHashes)
throws PeerNotConnected { throws PeerNotConnected {
final GetNodeDataMessage message = GetNodeDataMessage.create(nodeHashes); final GetNodeDataMessage message = GetNodeDataMessage.create(nodeHashes);
return sendRequest(requestManagers.get(protocolName).get(EthPV63.GET_NODE_DATA), message); return sendRequest(requestManagers.get(EthProtocol.NAME).get(EthPV63.GET_NODE_DATA), message);
} }
public RequestManager.ResponseStream getPooledTransactions(final List<Hash> hashes) public RequestManager.ResponseStream getPooledTransactions(final List<Hash> hashes)
throws PeerNotConnected { throws PeerNotConnected {
final GetPooledTransactionsMessage message = GetPooledTransactionsMessage.create(hashes); final GetPooledTransactionsMessage message = GetPooledTransactionsMessage.create(hashes);
return sendRequest( return sendRequest(
requestManagers.get(protocolName).get(EthPV65.GET_POOLED_TRANSACTIONS), message); requestManagers.get(EthProtocol.NAME).get(EthPV65.GET_POOLED_TRANSACTIONS), message);
} }
public RequestManager.ResponseStream getSnapAccountRange( public RequestManager.ResponseStream getSnapAccountRange(
@ -461,7 +462,7 @@ public class EthPeer implements Comparable<EthPeer> {
* @param ethMessage the Eth message to dispatch * @param ethMessage the Eth message to dispatch
*/ */
void dispatch(final EthMessage ethMessage) { void dispatch(final EthMessage ethMessage) {
dispatch(ethMessage, protocolName); dispatch(ethMessage, EthProtocol.NAME);
} }
/** /**
@ -587,10 +588,6 @@ public class EthPeer implements Comparable<EthPeer> {
return lastProtocolVersion.get(); return lastProtocolVersion.get();
} }
public String getProtocolName() {
return protocolName;
}
/** /**
* Return A read-only snapshot of this peer's current {@code chainState} * Return A read-only snapshot of this peer's current {@code chainState}
* *

@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.eth.manager; package org.hyperledger.besu.ethereum.eth.manager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.SnapProtocol; import org.hyperledger.besu.ethereum.eth.SnapProtocol;
import org.hyperledger.besu.ethereum.eth.manager.EthPeer.DisconnectCallback; import org.hyperledger.besu.ethereum.eth.manager.EthPeer.DisconnectCallback;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerSelector; import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerSelector;
@ -92,7 +93,6 @@ public class EthPeers implements PeerSelector {
.concurrencyLevel(1) .concurrencyLevel(1)
.removalListener(this::onCacheRemoval) .removalListener(this::onCacheRemoval)
.build(); .build();
private final String protocolName;
private final Clock clock; private final Clock clock;
private final List<NodeMessagePermissioningProvider> permissioningProviders; private final List<NodeMessagePermissioningProvider> permissioningProviders;
private final int maxMessageSize; private final int maxMessageSize;
@ -122,7 +122,6 @@ public class EthPeers implements PeerSelector {
() -> TrailingPeerRequirements.UNRESTRICTED; () -> TrailingPeerRequirements.UNRESTRICTED;
public EthPeers( public EthPeers(
final String protocolName,
final Supplier<ProtocolSpec> currentProtocolSpecSupplier, final Supplier<ProtocolSpec> currentProtocolSpecSupplier,
final Clock clock, final Clock clock,
final MetricsSystem metricsSystem, final MetricsSystem metricsSystem,
@ -134,7 +133,6 @@ public class EthPeers implements PeerSelector {
final Boolean randomPeerPriority, final Boolean randomPeerPriority,
final SyncMode syncMode, final SyncMode syncMode,
final ForkIdManager forkIdManager) { final ForkIdManager forkIdManager) {
this.protocolName = protocolName;
this.currentProtocolSpecSupplier = currentProtocolSpecSupplier; this.currentProtocolSpecSupplier = currentProtocolSpecSupplier;
this.clock = clock; this.clock = clock;
this.permissioningProviders = permissioningProviders; this.permissioningProviders = permissioningProviders;
@ -191,7 +189,6 @@ public class EthPeers implements PeerSelector {
peerInList.orElse( peerInList.orElse(
new EthPeer( new EthPeer(
newConnection, newConnection,
protocolName,
this::ethPeerStatusExchanged, this::ethPeerStatusExchanged,
peerValidators, peerValidators,
maxMessageSize, maxMessageSize,
@ -294,7 +291,7 @@ public class EthPeers implements PeerSelector {
} }
public void dispatchMessage(final EthPeer peer, final EthMessage ethMessage) { public void dispatchMessage(final EthPeer peer, final EthMessage ethMessage) {
dispatchMessage(peer, ethMessage, protocolName); dispatchMessage(peer, ethMessage, EthProtocol.NAME);
} }
@VisibleForTesting @VisibleForTesting

@ -123,9 +123,8 @@ public class GetReceiptsFromPeerTask
@Override @Override
public Predicate<EthPeer> getPeerRequirementFilter() { public Predicate<EthPeer> getPeerRequirementFilter() {
return (ethPeer) -> return (ethPeer) ->
ethPeer.getProtocolName().equals(getSubProtocol().getName()) (protocolSchedule.anyMatch((ps) -> ps.spec().isPoS())
&& (protocolSchedule.anyMatch((ps) -> ps.spec().isPoS()) || ethPeer.chainState().getEstimatedHeight() >= requiredBlockchainHeight);
|| ethPeer.chainState().getEstimatedHeight() >= requiredBlockchainHeight);
} }
@Override @Override

@ -477,7 +477,6 @@ public class EthPeerTest {
final Consumer<EthPeer> onPeerReady = (peer) -> {}; final Consumer<EthPeer> onPeerReady = (peer) -> {};
return new EthPeer( return new EthPeer(
peerConnection, peerConnection,
"foo",
onPeerReady, onPeerReady,
Collections.emptyList(), Collections.emptyList(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE, EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,
@ -513,7 +512,6 @@ public class EthPeerTest {
// that extend the sub-protocol work correctly // that extend the sub-protocol work correctly
return new EthPeer( return new EthPeer(
peerConnection, peerConnection,
"foo",
onPeerReady, onPeerReady,
peerValidators, peerValidators,
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE, EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

@ -84,7 +84,6 @@ public class EthProtocolManagerTestUtil {
final EthPeers peers = final EthPeers peers =
new EthPeers( new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()), () -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(), TestClock.fixed(),
new NoOpMetricsSystem(), new NoOpMetricsSystem(),
@ -211,7 +210,6 @@ public class EthProtocolManagerTestUtil {
final EthPeers peers = final EthPeers peers =
new EthPeers( new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()), () -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(), TestClock.fixed(),
new NoOpMetricsSystem(), new NoOpMetricsSystem(),
@ -262,7 +260,6 @@ public class EthProtocolManagerTestUtil {
final EthPeers peers = final EthPeers peers =
new EthPeers( new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()), () -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(), TestClock.fixed(),
new NoOpMetricsSystem(), new NoOpMetricsSystem(),
@ -294,7 +291,6 @@ public class EthProtocolManagerTestUtil {
final EthScheduler ethScheduler) { final EthScheduler ethScheduler) {
final EthPeers ethPeers = final EthPeers ethPeers =
new EthPeers( new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()), () -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(), TestClock.fixed(),
new NoOpMetricsSystem(), new NoOpMetricsSystem(),

@ -303,7 +303,6 @@ public class RequestManagerTest {
final Consumer<EthPeer> onPeerReady = (peer) -> {}; final Consumer<EthPeer> onPeerReady = (peer) -> {};
return new EthPeer( return new EthPeer(
peerConnection, peerConnection,
EthProtocol.NAME,
onPeerReady, onPeerReady,
Collections.emptyList(), Collections.emptyList(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE, EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

@ -27,7 +27,6 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthMessages; import org.hyperledger.besu.ethereum.eth.manager.EthMessages;
@ -114,7 +113,6 @@ public abstract class AbstractMessageTaskTest<T, R> {
ethPeers = ethPeers =
spy( spy(
new EthPeers( new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()), () -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(), TestClock.fixed(),
metricsSystem, metricsSystem,

@ -162,7 +162,6 @@ public abstract class PeerMessageTaskTest<T>
final Consumer<EthPeer> onPeerReady = (peer) -> {}; final Consumer<EthPeer> onPeerReady = (peer) -> {};
return new EthPeer( return new EthPeer(
peerConnection, peerConnection,
EthProtocol.NAME,
onPeerReady, onPeerReady,
Collections.emptyList(), Collections.emptyList(),
EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE, EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE,

@ -214,11 +214,9 @@ public class GetReceiptsFromPeerTaskTest {
new GetReceiptsFromPeerTask( new GetReceiptsFromPeerTask(
List.of(blockHeader1, blockHeader2, blockHeader3), protocolSchedule); List.of(blockHeader1, blockHeader2, blockHeader3), protocolSchedule);
EthPeer failForIncorrectProtocol = mockPeer("incorrectProtocol", 5); EthPeer failForShortChainHeight = mockPeer(1);
EthPeer failForShortChainHeight = mockPeer("incorrectProtocol", 1); EthPeer successfulCandidate = mockPeer(5);
EthPeer successfulCandidate = mockPeer(EthProtocol.NAME, 5);
Assertions.assertFalse(task.getPeerRequirementFilter().test(failForIncorrectProtocol));
Assertions.assertFalse(task.getPeerRequirementFilter().test(failForShortChainHeight)); Assertions.assertFalse(task.getPeerRequirementFilter().test(failForShortChainHeight));
Assertions.assertTrue(task.getPeerRequirementFilter().test(successfulCandidate)); Assertions.assertTrue(task.getPeerRequirementFilter().test(successfulCandidate));
} }
@ -251,11 +249,10 @@ public class GetReceiptsFromPeerTaskTest {
return blockHeader; return blockHeader;
} }
private EthPeer mockPeer(final String protocol, final long chainHeight) { private EthPeer mockPeer(final long chainHeight) {
EthPeer ethPeer = Mockito.mock(EthPeer.class); EthPeer ethPeer = Mockito.mock(EthPeer.class);
ChainState chainState = Mockito.mock(ChainState.class); ChainState chainState = Mockito.mock(ChainState.class);
Mockito.when(ethPeer.getProtocolName()).thenReturn(protocol);
Mockito.when(ethPeer.chainState()).thenReturn(chainState); Mockito.when(ethPeer.chainState()).thenReturn(chainState);
Mockito.when(chainState.getEstimatedHeight()).thenReturn(chainHeight); Mockito.when(chainState.getEstimatedHeight()).thenReturn(chainHeight);

@ -641,7 +641,6 @@ public abstract class AbstractBlockPropagationManagerTest {
final EthContext ethContext = final EthContext ethContext =
new EthContext( new EthContext(
new EthPeers( new EthPeers(
"eth",
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()), () -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(), TestClock.fixed(),
metricsSystem, metricsSystem,
@ -783,7 +782,6 @@ public abstract class AbstractBlockPropagationManagerTest {
final EthContext ethContext = final EthContext ethContext =
new EthContext( new EthContext(
new EthPeers( new EthPeers(
"eth",
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()), () -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(), TestClock.fixed(),
metricsSystem, metricsSystem,

@ -154,7 +154,6 @@ public class TestNode implements Closeable {
}; };
final EthPeers ethPeers = final EthPeers ethPeers =
new EthPeers( new EthPeers(
EthProtocol.NAME,
() -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()), () -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()),
TestClock.fixed(), TestClock.fixed(),
metricsSystem, metricsSystem,

@ -112,7 +112,6 @@ public class TransactionPoolFactoryTest {
final NodeMessagePermissioningProvider nmpp = (destinationEnode, code) -> true; final NodeMessagePermissioningProvider nmpp = (destinationEnode, code) -> true;
ethPeers = ethPeers =
new EthPeers( new EthPeers(
"ETH",
() -> protocolSpec, () -> protocolSpec,
TestClock.fixed(), TestClock.fixed(),
new NoOpMetricsSystem(), new NoOpMetricsSystem(),

Loading…
Cancel
Save