|
|
@ -22,6 +22,7 @@ import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Optional; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.TimeoutException; |
|
|
|
import java.util.concurrent.TimeoutException; |
|
|
|
import java.util.function.Predicate; |
|
|
|
import java.util.function.Predicate; |
|
|
@ -49,8 +50,7 @@ public class PeerTaskExecutorTest { |
|
|
|
@BeforeEach |
|
|
|
@BeforeEach |
|
|
|
public void beforeTest() { |
|
|
|
public void beforeTest() { |
|
|
|
mockCloser = MockitoAnnotations.openMocks(this); |
|
|
|
mockCloser = MockitoAnnotations.openMocks(this); |
|
|
|
peerTaskExecutor = |
|
|
|
peerTaskExecutor = new PeerTaskExecutor(peerSelector, requestSender, new NoOpMetricsSystem()); |
|
|
|
new PeerTaskExecutor(peerSelector, requestSender, new NoOpMetricsSystem()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@AfterEach |
|
|
|
@AfterEach |
|
|
@ -201,7 +201,8 @@ public class PeerTaskExecutorTest { |
|
|
|
InvalidPeerTaskResponseException { |
|
|
|
InvalidPeerTaskResponseException { |
|
|
|
Object responseObject = new Object(); |
|
|
|
Object responseObject = new Object(); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(peerSelector.getPeer(Mockito.any(Predicate.class))).thenReturn(ethPeer); |
|
|
|
Mockito.when(peerSelector.getPeer(Mockito.any(Predicate.class))) |
|
|
|
|
|
|
|
.thenReturn(Optional.of(ethPeer)); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(peerTask.getRequestMessage()).thenReturn(requestMessageData); |
|
|
|
Mockito.when(peerTask.getRequestMessage()).thenReturn(requestMessageData); |
|
|
|
Mockito.when(peerTask.getPeerTaskRetryBehaviors()).thenReturn(Collections.emptyList()); |
|
|
|
Mockito.when(peerTask.getPeerTaskRetryBehaviors()).thenReturn(Collections.emptyList()); |
|
|
@ -234,8 +235,8 @@ public class PeerTaskExecutorTest { |
|
|
|
EthPeer peer2 = Mockito.mock(EthPeer.class); |
|
|
|
EthPeer peer2 = Mockito.mock(EthPeer.class); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(peerSelector.getPeer(Mockito.any(Predicate.class))) |
|
|
|
Mockito.when(peerSelector.getPeer(Mockito.any(Predicate.class))) |
|
|
|
.thenReturn(ethPeer) |
|
|
|
.thenReturn(Optional.of(ethPeer)) |
|
|
|
.thenReturn(peer2); |
|
|
|
.thenReturn(Optional.of(peer2)); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(peerTask.getRequestMessage()).thenReturn(requestMessageData); |
|
|
|
Mockito.when(peerTask.getRequestMessage()).thenReturn(requestMessageData); |
|
|
|
Mockito.when(peerTask.getPeerTaskRetryBehaviors()) |
|
|
|
Mockito.when(peerTask.getPeerTaskRetryBehaviors()) |
|
|
|