|
|
@ -66,7 +66,6 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; |
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage; |
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage; |
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; |
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; |
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage; |
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage; |
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason; |
|
|
|
|
|
|
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; |
|
|
|
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; |
|
|
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; |
|
|
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; |
|
|
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; |
|
|
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; |
|
|
@ -79,7 +78,6 @@ import java.util.Arrays; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
@ -203,101 +201,6 @@ public final class EthProtocolManagerTest { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void disconnectPoWPeersAfterTransition() { |
|
|
|
|
|
|
|
try (final EthProtocolManager ethManager = |
|
|
|
|
|
|
|
EthProtocolManagerTestUtil.create( |
|
|
|
|
|
|
|
blockchain, |
|
|
|
|
|
|
|
() -> false, |
|
|
|
|
|
|
|
protocolContext.getWorldStateArchive(), |
|
|
|
|
|
|
|
transactionPool, |
|
|
|
|
|
|
|
EthProtocolConfiguration.defaultConfig())) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final MockPeerConnection workPeer = setupPeer(ethManager, (cap, msg, conn) -> {}); |
|
|
|
|
|
|
|
final MockPeerConnection stakePeer = setupPeer(ethManager, (cap, msg, conn) -> {}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final StatusMessage workPeerStatus = |
|
|
|
|
|
|
|
StatusMessage.create( |
|
|
|
|
|
|
|
EthProtocol.EthVersion.V63, |
|
|
|
|
|
|
|
BigInteger.ONE, |
|
|
|
|
|
|
|
blockchain.getChainHead().getTotalDifficulty().add(20), |
|
|
|
|
|
|
|
blockchain.getChainHeadHash(), |
|
|
|
|
|
|
|
blockchain.getBlockHeader(BlockHeader.GENESIS_BLOCK_NUMBER).get().getHash()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final StatusMessage stakePeerStatus = |
|
|
|
|
|
|
|
StatusMessage.create( |
|
|
|
|
|
|
|
EthProtocol.EthVersion.V63, |
|
|
|
|
|
|
|
BigInteger.ONE, |
|
|
|
|
|
|
|
blockchain.getChainHead().getTotalDifficulty(), |
|
|
|
|
|
|
|
blockchain.getChainHeadHash(), |
|
|
|
|
|
|
|
blockchain.getBlockHeader(BlockHeader.GENESIS_BLOCK_NUMBER).get().getHash()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ethManager.processMessage(EthProtocol.ETH63, new DefaultMessage(workPeer, workPeerStatus)); |
|
|
|
|
|
|
|
ethManager.processMessage(EthProtocol.ETH63, new DefaultMessage(stakePeer, stakePeerStatus)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ethManager.onCrossingMergeBoundary( |
|
|
|
|
|
|
|
true, Optional.of(blockchain.getChainHead().getTotalDifficulty())); |
|
|
|
|
|
|
|
ethManager.onNewForkchoiceMessage( |
|
|
|
|
|
|
|
Hash.EMPTY, Optional.of(Hash.hash(Bytes.of(1))), Hash.EMPTY); |
|
|
|
|
|
|
|
ethManager.onNewForkchoiceMessage( |
|
|
|
|
|
|
|
Hash.EMPTY, Optional.of(Hash.hash(Bytes.of(2))), Hash.EMPTY); |
|
|
|
|
|
|
|
assertThat(workPeer.isDisconnected()).isTrue(); |
|
|
|
|
|
|
|
assertThat(workPeer.getDisconnectReason()).isPresent(); |
|
|
|
|
|
|
|
assertThat(workPeer.getDisconnectReason()) |
|
|
|
|
|
|
|
.get() |
|
|
|
|
|
|
|
.isEqualTo(DisconnectReason.SUBPROTOCOL_TRIGGERED); |
|
|
|
|
|
|
|
assertThat(stakePeer.isDisconnected()).isFalse(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void disconnectNewPoWPeers() { |
|
|
|
|
|
|
|
try (final EthProtocolManager ethManager = |
|
|
|
|
|
|
|
EthProtocolManagerTestUtil.create( |
|
|
|
|
|
|
|
blockchain, |
|
|
|
|
|
|
|
() -> false, |
|
|
|
|
|
|
|
protocolContext.getWorldStateArchive(), |
|
|
|
|
|
|
|
transactionPool, |
|
|
|
|
|
|
|
EthProtocolConfiguration.defaultConfig())) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final MockPeerConnection workPeer = setupPeer(ethManager, (cap, msg, conn) -> {}); |
|
|
|
|
|
|
|
final MockPeerConnection stakePeer = setupPeer(ethManager, (cap, msg, conn) -> {}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final StatusMessage workPeerStatus = |
|
|
|
|
|
|
|
StatusMessage.create( |
|
|
|
|
|
|
|
EthProtocol.EthVersion.V63, |
|
|
|
|
|
|
|
BigInteger.ONE, |
|
|
|
|
|
|
|
blockchain.getChainHead().getTotalDifficulty().add(20), |
|
|
|
|
|
|
|
blockchain.getChainHeadHash(), |
|
|
|
|
|
|
|
blockchain.getBlockHeader(BlockHeader.GENESIS_BLOCK_NUMBER).get().getHash()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final StatusMessage stakePeerStatus = |
|
|
|
|
|
|
|
StatusMessage.create( |
|
|
|
|
|
|
|
EthProtocol.EthVersion.V63, |
|
|
|
|
|
|
|
BigInteger.ONE, |
|
|
|
|
|
|
|
blockchain.getChainHead().getTotalDifficulty(), |
|
|
|
|
|
|
|
blockchain.getChainHeadHash(), |
|
|
|
|
|
|
|
blockchain.getBlockHeader(BlockHeader.GENESIS_BLOCK_NUMBER).get().getHash()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ethManager.processMessage(EthProtocol.ETH63, new DefaultMessage(stakePeer, stakePeerStatus)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ethManager.onCrossingMergeBoundary( |
|
|
|
|
|
|
|
true, Optional.of(blockchain.getChainHead().getTotalDifficulty())); |
|
|
|
|
|
|
|
ethManager.onNewForkchoiceMessage( |
|
|
|
|
|
|
|
Hash.EMPTY, Optional.of(Hash.hash(Bytes.of(1))), Hash.EMPTY); |
|
|
|
|
|
|
|
ethManager.onNewForkchoiceMessage( |
|
|
|
|
|
|
|
Hash.EMPTY, Optional.of(Hash.hash(Bytes.of(2))), Hash.EMPTY); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ethManager.processMessage(EthProtocol.ETH63, new DefaultMessage(workPeer, workPeerStatus)); |
|
|
|
|
|
|
|
assertThat(workPeer.isDisconnected()).isTrue(); |
|
|
|
|
|
|
|
assertThat(workPeer.getDisconnectReason()).isPresent(); |
|
|
|
|
|
|
|
assertThat(workPeer.getDisconnectReason()) |
|
|
|
|
|
|
|
.get() |
|
|
|
|
|
|
|
.isEqualTo(DisconnectReason.SUBPROTOCOL_TRIGGERED); |
|
|
|
|
|
|
|
assertThat(stakePeer.isDisconnected()).isFalse(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void disconnectOnVeryLargeMessage() { |
|
|
|
public void disconnectOnVeryLargeMessage() { |
|
|
|
try (final EthProtocolManager ethManager = |
|
|
|
try (final EthProtocolManager ethManager = |
|
|
@ -390,7 +293,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final List<BlockHeader> headers = |
|
|
|
final List<BlockHeader> headers = |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
assertThat(headers).hasSize(blockCount); |
|
|
|
assertThat(headers.size()).isEqualTo(blockCount); |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i); |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i); |
|
|
|
} |
|
|
|
} |
|
|
@ -427,7 +330,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final List<BlockHeader> headers = |
|
|
|
final List<BlockHeader> headers = |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
assertThat(headers).hasSize(limit); |
|
|
|
assertThat(headers.size()).isEqualTo(limit); |
|
|
|
for (int i = 0; i < limit; i++) { |
|
|
|
for (int i = 0; i < limit; i++) { |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i); |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i); |
|
|
|
} |
|
|
|
} |
|
|
@ -463,7 +366,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final List<BlockHeader> headers = |
|
|
|
final List<BlockHeader> headers = |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
assertThat(headers).hasSize(blockCount); |
|
|
|
assertThat(headers.size()).isEqualTo(blockCount); |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(endBlock - i); |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(endBlock - i); |
|
|
|
} |
|
|
|
} |
|
|
@ -501,7 +404,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final List<BlockHeader> headers = |
|
|
|
final List<BlockHeader> headers = |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
assertThat(headers).hasSize(blockCount); |
|
|
|
assertThat(headers.size()).isEqualTo(blockCount); |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i * (skip + 1)); |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i * (skip + 1)); |
|
|
|
} |
|
|
|
} |
|
|
@ -540,7 +443,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final List<BlockHeader> headers = |
|
|
|
final List<BlockHeader> headers = |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
assertThat(headers).hasSize(blockCount); |
|
|
|
assertThat(headers.size()).isEqualTo(blockCount); |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(endBlock - i * (skip + 1)); |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(endBlock - i * (skip + 1)); |
|
|
|
} |
|
|
|
} |
|
|
@ -599,7 +502,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final List<BlockHeader> headers = |
|
|
|
final List<BlockHeader> headers = |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
assertThat(headers).hasSize(2); |
|
|
|
assertThat(headers.size()).isEqualTo(2); |
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
for (int i = 0; i < 2; i++) { |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i); |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(startBlock + i); |
|
|
|
} |
|
|
|
} |
|
|
@ -636,7 +539,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final List<BlockHeader> headers = |
|
|
|
final List<BlockHeader> headers = |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
assertThat(headers).isEmpty(); |
|
|
|
assertThat(headers.size()).isEqualTo(0); |
|
|
|
done.complete(null); |
|
|
|
done.complete(null); |
|
|
|
}; |
|
|
|
}; |
|
|
|
final PeerConnection peer = setupPeer(ethManager, onSend); |
|
|
|
final PeerConnection peer = setupPeer(ethManager, onSend); |
|
|
@ -680,7 +583,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockBodiesMessage blocksMessage = BlockBodiesMessage.readFrom(message); |
|
|
|
final BlockBodiesMessage blocksMessage = BlockBodiesMessage.readFrom(message); |
|
|
|
final List<BlockBody> bodies = |
|
|
|
final List<BlockBody> bodies = |
|
|
|
Lists.newArrayList(blocksMessage.bodies(protocolSchedule)); |
|
|
|
Lists.newArrayList(blocksMessage.bodies(protocolSchedule)); |
|
|
|
assertThat(bodies).hasSize(blockCount); |
|
|
|
assertThat(bodies.size()).isEqualTo(blockCount); |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
assertThat(expectedBlocks[i].getBody()).isEqualTo(bodies.get(i)); |
|
|
|
assertThat(expectedBlocks[i].getBody()).isEqualTo(bodies.get(i)); |
|
|
|
} |
|
|
|
} |
|
|
@ -729,7 +632,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockBodiesMessage blocksMessage = BlockBodiesMessage.readFrom(message); |
|
|
|
final BlockBodiesMessage blocksMessage = BlockBodiesMessage.readFrom(message); |
|
|
|
final List<BlockBody> bodies = |
|
|
|
final List<BlockBody> bodies = |
|
|
|
Lists.newArrayList(blocksMessage.bodies(protocolSchedule)); |
|
|
|
Lists.newArrayList(blocksMessage.bodies(protocolSchedule)); |
|
|
|
assertThat(bodies).hasSize(limit); |
|
|
|
assertThat(bodies.size()).isEqualTo(limit); |
|
|
|
for (int i = 0; i < limit; i++) { |
|
|
|
for (int i = 0; i < limit; i++) { |
|
|
|
assertThat(expectedBlocks[i].getBody()).isEqualTo(bodies.get(i)); |
|
|
|
assertThat(expectedBlocks[i].getBody()).isEqualTo(bodies.get(i)); |
|
|
|
} |
|
|
|
} |
|
|
@ -773,7 +676,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockBodiesMessage blocksMessage = BlockBodiesMessage.readFrom(message); |
|
|
|
final BlockBodiesMessage blocksMessage = BlockBodiesMessage.readFrom(message); |
|
|
|
final List<BlockBody> bodies = |
|
|
|
final List<BlockBody> bodies = |
|
|
|
Lists.newArrayList(blocksMessage.bodies(protocolSchedule)); |
|
|
|
Lists.newArrayList(blocksMessage.bodies(protocolSchedule)); |
|
|
|
assertThat(bodies).hasSize(1); |
|
|
|
assertThat(bodies.size()).isEqualTo(1); |
|
|
|
assertThat(expectedBlock.getBody()).isEqualTo(bodies.get(0)); |
|
|
|
assertThat(expectedBlock.getBody()).isEqualTo(bodies.get(0)); |
|
|
|
done.complete(null); |
|
|
|
done.complete(null); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -818,7 +721,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final ReceiptsMessage receiptsMessage = ReceiptsMessage.readFrom(message); |
|
|
|
final ReceiptsMessage receiptsMessage = ReceiptsMessage.readFrom(message); |
|
|
|
final List<List<TransactionReceipt>> receipts = |
|
|
|
final List<List<TransactionReceipt>> receipts = |
|
|
|
Lists.newArrayList(receiptsMessage.receipts()); |
|
|
|
Lists.newArrayList(receiptsMessage.receipts()); |
|
|
|
assertThat(receipts).hasSize(blockCount); |
|
|
|
assertThat(receipts.size()).isEqualTo(blockCount); |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
assertThat(expectedReceipts.get(i)).isEqualTo(receipts.get(i)); |
|
|
|
assertThat(expectedReceipts.get(i)).isEqualTo(receipts.get(i)); |
|
|
|
} |
|
|
|
} |
|
|
@ -866,7 +769,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final ReceiptsMessage receiptsMessage = ReceiptsMessage.readFrom(message); |
|
|
|
final ReceiptsMessage receiptsMessage = ReceiptsMessage.readFrom(message); |
|
|
|
final List<List<TransactionReceipt>> receipts = |
|
|
|
final List<List<TransactionReceipt>> receipts = |
|
|
|
Lists.newArrayList(receiptsMessage.receipts()); |
|
|
|
Lists.newArrayList(receiptsMessage.receipts()); |
|
|
|
assertThat(receipts).hasSize(limit); |
|
|
|
assertThat(receipts.size()).isEqualTo(limit); |
|
|
|
for (int i = 0; i < limit; i++) { |
|
|
|
for (int i = 0; i < limit; i++) { |
|
|
|
assertThat(expectedReceipts.get(i)).isEqualTo(receipts.get(i)); |
|
|
|
assertThat(expectedReceipts.get(i)).isEqualTo(receipts.get(i)); |
|
|
|
} |
|
|
|
} |
|
|
@ -910,7 +813,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final ReceiptsMessage receiptsMessage = ReceiptsMessage.readFrom(message); |
|
|
|
final ReceiptsMessage receiptsMessage = ReceiptsMessage.readFrom(message); |
|
|
|
final List<List<TransactionReceipt>> receipts = |
|
|
|
final List<List<TransactionReceipt>> receipts = |
|
|
|
Lists.newArrayList(receiptsMessage.receipts()); |
|
|
|
Lists.newArrayList(receiptsMessage.receipts()); |
|
|
|
assertThat(receipts).hasSize(1); |
|
|
|
assertThat(receipts.size()).isEqualTo(1); |
|
|
|
assertThat(expectedReceipts).isEqualTo(receipts.get(0)); |
|
|
|
assertThat(expectedReceipts).isEqualTo(receipts.get(0)); |
|
|
|
done.complete(null); |
|
|
|
done.complete(null); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -958,7 +861,7 @@ public final class EthProtocolManagerTest { |
|
|
|
assertThat(message.getCode()).isEqualTo(EthPV63.NODE_DATA); |
|
|
|
assertThat(message.getCode()).isEqualTo(EthPV63.NODE_DATA); |
|
|
|
final NodeDataMessage receiptsMessage = NodeDataMessage.readFrom(message); |
|
|
|
final NodeDataMessage receiptsMessage = NodeDataMessage.readFrom(message); |
|
|
|
final List<Bytes> nodeData = receiptsMessage.nodeData(); |
|
|
|
final List<Bytes> nodeData = receiptsMessage.nodeData(); |
|
|
|
assertThat(nodeData).hasSize(blockCount); |
|
|
|
assertThat(nodeData.size()).isEqualTo(blockCount); |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
for (int i = 0; i < blockCount; i++) { |
|
|
|
assertThat(expectedResults.get(i)).isEqualTo(nodeData.get(i)); |
|
|
|
assertThat(expectedResults.get(i)).isEqualTo(nodeData.get(i)); |
|
|
|
} |
|
|
|
} |
|
|
@ -1025,7 +928,7 @@ public final class EthProtocolManagerTest { |
|
|
|
assertThat(msg.totalDifficulty(protocolSchdeule)).isEqualTo(expectedTotalDifficulty); |
|
|
|
assertThat(msg.totalDifficulty(protocolSchdeule)).isEqualTo(expectedTotalDifficulty); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
assertThat(receivingPeerCaptor.getAllValues()).containsAll(peers); |
|
|
|
assertThat(receivingPeerCaptor.getAllValues().containsAll(peers)).isTrue(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1067,7 +970,7 @@ public final class EthProtocolManagerTest { |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final BlockHeadersMessage headersMsg = BlockHeadersMessage.readFrom(message); |
|
|
|
final List<BlockHeader> headers = |
|
|
|
final List<BlockHeader> headers = |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
Lists.newArrayList(headersMsg.getHeaders(protocolSchedule)); |
|
|
|
assertThat(headers).hasSize(receivedBlockCount); |
|
|
|
assertThat(headers.size()).isEqualTo(receivedBlockCount); |
|
|
|
for (int i = 0; i < receivedBlockCount; i++) { |
|
|
|
for (int i = 0; i < receivedBlockCount; i++) { |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(receivedBlockCount - 1 - i); |
|
|
|
assertThat(headers.get(i).getNumber()).isEqualTo(receivedBlockCount - 1 - i); |
|
|
|
} |
|
|
|
} |
|
|
|