|
|
@ -25,6 +25,7 @@ import org.hyperledger.besu.ethereum.eth.messages.EthPV63; |
|
|
|
import org.hyperledger.besu.ethereum.eth.messages.GetReceiptsMessage; |
|
|
|
import org.hyperledger.besu.ethereum.eth.messages.GetReceiptsMessage; |
|
|
|
import org.hyperledger.besu.ethereum.eth.messages.ReceiptsMessage; |
|
|
|
import org.hyperledger.besu.ethereum.eth.messages.ReceiptsMessage; |
|
|
|
import org.hyperledger.besu.ethereum.mainnet.BodyValidator; |
|
|
|
import org.hyperledger.besu.ethereum.mainnet.BodyValidator; |
|
|
|
|
|
|
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; |
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; |
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -42,7 +43,8 @@ public class GetReceiptsFromPeerTaskTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testGetSubProtocol() { |
|
|
|
public void testGetSubProtocol() { |
|
|
|
GetReceiptsFromPeerTask task = new GetReceiptsFromPeerTask(Collections.emptyList(), null); |
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
|
|
|
|
new GetReceiptsFromPeerTask(Collections.emptyList(), null, () -> null); |
|
|
|
Assertions.assertEquals(EthProtocol.get(), task.getSubProtocol()); |
|
|
|
Assertions.assertEquals(EthProtocol.get(), task.getSubProtocol()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -50,7 +52,7 @@ public class GetReceiptsFromPeerTaskTest { |
|
|
|
public void testGetRequestMessage() { |
|
|
|
public void testGetRequestMessage() { |
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
new GetReceiptsFromPeerTask( |
|
|
|
new GetReceiptsFromPeerTask( |
|
|
|
List.of(mockBlockHeader(1), mockBlockHeader(2), mockBlockHeader(3)), null); |
|
|
|
List.of(mockBlockHeader(1), mockBlockHeader(2), mockBlockHeader(3)), null, () -> null); |
|
|
|
|
|
|
|
|
|
|
|
MessageData messageData = task.getRequestMessage(); |
|
|
|
MessageData messageData = task.getRequestMessage(); |
|
|
|
GetReceiptsMessage getReceiptsMessage = GetReceiptsMessage.readFrom(messageData); |
|
|
|
GetReceiptsMessage getReceiptsMessage = GetReceiptsMessage.readFrom(messageData); |
|
|
@ -72,7 +74,8 @@ public class GetReceiptsFromPeerTaskTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testParseResponseWithNullResponseMessage() { |
|
|
|
public void testParseResponseWithNullResponseMessage() { |
|
|
|
GetReceiptsFromPeerTask task = new GetReceiptsFromPeerTask(Collections.emptyList(), null); |
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
|
|
|
|
new GetReceiptsFromPeerTask(Collections.emptyList(), null, () -> null); |
|
|
|
Assertions.assertThrows(InvalidPeerTaskResponseException.class, () -> task.parseResponse(null)); |
|
|
|
Assertions.assertThrows(InvalidPeerTaskResponseException.class, () -> task.parseResponse(null)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -80,7 +83,7 @@ public class GetReceiptsFromPeerTaskTest { |
|
|
|
public void testParseResponseForInvalidResponse() { |
|
|
|
public void testParseResponseForInvalidResponse() { |
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
new GetReceiptsFromPeerTask( |
|
|
|
new GetReceiptsFromPeerTask( |
|
|
|
List.of(mockBlockHeader(1), mockBlockHeader(2), mockBlockHeader(3)), null); |
|
|
|
List.of(mockBlockHeader(1), mockBlockHeader(2), mockBlockHeader(3)), null, () -> null); |
|
|
|
ReceiptsMessage receiptsMessage = |
|
|
|
ReceiptsMessage receiptsMessage = |
|
|
|
ReceiptsMessage.create( |
|
|
|
ReceiptsMessage.create( |
|
|
|
List.of( |
|
|
|
List.of( |
|
|
@ -103,7 +106,7 @@ public class GetReceiptsFromPeerTaskTest { |
|
|
|
|
|
|
|
|
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
new GetReceiptsFromPeerTask( |
|
|
|
new GetReceiptsFromPeerTask( |
|
|
|
List.of(blockHeader1, blockHeader2, blockHeader3), bodyValidator); |
|
|
|
List.of(blockHeader1, blockHeader2, blockHeader3), bodyValidator, () -> null); |
|
|
|
|
|
|
|
|
|
|
|
TransactionReceipt receiptForBlock1 = |
|
|
|
TransactionReceipt receiptForBlock1 = |
|
|
|
new TransactionReceipt(1, 123, Collections.emptyList(), Optional.empty()); |
|
|
|
new TransactionReceipt(1, 123, Collections.emptyList(), Optional.empty()); |
|
|
@ -137,8 +140,12 @@ public class GetReceiptsFromPeerTaskTest { |
|
|
|
BlockHeader blockHeader2 = mockBlockHeader(2); |
|
|
|
BlockHeader blockHeader2 = mockBlockHeader(2); |
|
|
|
BlockHeader blockHeader3 = mockBlockHeader(3); |
|
|
|
BlockHeader blockHeader3 = mockBlockHeader(3); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProtocolSpec protocolSpec = Mockito.mock(ProtocolSpec.class); |
|
|
|
|
|
|
|
Mockito.when(protocolSpec.isPoS()).thenReturn(false); |
|
|
|
|
|
|
|
|
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
GetReceiptsFromPeerTask task = |
|
|
|
new GetReceiptsFromPeerTask(List.of(blockHeader1, blockHeader2, blockHeader3), null); |
|
|
|
new GetReceiptsFromPeerTask( |
|
|
|
|
|
|
|
List.of(blockHeader1, blockHeader2, blockHeader3), null, () -> protocolSpec); |
|
|
|
|
|
|
|
|
|
|
|
EthPeer failForIncorrectProtocol = mockPeer("incorrectProtocol", 5); |
|
|
|
EthPeer failForIncorrectProtocol = mockPeer("incorrectProtocol", 5); |
|
|
|
EthPeer failForShortChainHeight = mockPeer("incorrectProtocol", 1); |
|
|
|
EthPeer failForShortChainHeight = mockPeer("incorrectProtocol", 1); |
|
|
|