Skip to content

Commit 42c3609

Browse files
committed
[ETCM-313] Fix integration tests, format error messages
1 parent 9ee535e commit 42c3609

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/it/scala/io/iohk/ethereum/sync/FastSyncItSpec.scala

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,49 +59,53 @@ class FastSyncItSpec extends FlatSpecBase with Matchers with BeforeAndAfterAll {
5959

6060
it should "sync blockchain with state nodes when peer do not response with full responses" in
6161
customTestCaseResourceM(
62-
FakePeer.start3FakePeersRes(
62+
FakePeer.start4FakePeersRes(
6363
fakePeerCustomConfig2 = FakePeerCustomConfig(HostConfig()),
6464
fakePeerCustomConfig3 = FakePeerCustomConfig(HostConfig())
6565
)
66-
) { case (peer1, peer2, peer3) =>
66+
) { case (peer1, peer2, peer3, peer4) =>
6767
for {
6868
_ <- peer2.importBlocksUntil(1000)(updateStateAtBlock(500))
6969
_ <- peer3.importBlocksUntil(1000)(updateStateAtBlock(500))
70-
_ <- peer1.connectToPeers(Set(peer2.node, peer3.node))
70+
_ <- peer4.importBlocksUntil(1000)(updateStateAtBlock(500))
71+
72+
_ <- peer1.connectToPeers(Set(peer2.node, peer3.node, peer4.node))
7173
_ <- peer1.startFastSync().delayExecution(50.milliseconds)
7274
_ <- peer1.waitForFastSyncFinish()
7375
} yield {
7476
val trie = peer1.getBestBlockTrie()
7577
val synchronizingPeerHaveAllData = peer1.containsExpectedDataUpToAccountAtBlock(1000, 500)
76-
// due to the fact that function generating state is deterministic both peer2 and peer3 ends up with exactly same
78+
// due to the fact that function generating state is deterministic both peer3 and peer4 ends up with exactly same
7779
// state, so peer1 can get whole trie from both of them.
78-
assert(peer1.bl.getBestBlockNumber() == peer2.bl.getBestBlockNumber() - peer2.testSyncConfig.pivotBlockOffset)
7980
assert(peer1.bl.getBestBlockNumber() == peer3.bl.getBestBlockNumber() - peer3.testSyncConfig.pivotBlockOffset)
81+
assert(peer1.bl.getBestBlockNumber() == peer4.bl.getBestBlockNumber() - peer4.testSyncConfig.pivotBlockOffset)
8082
assert(trie.isDefined)
8183
assert(synchronizingPeerHaveAllData)
8284
}
8385
}
8486

8587
it should "sync blockchain with state nodes when one of the peers send empty state responses" in
8688
customTestCaseResourceM(
87-
FakePeer.start3FakePeersRes(
89+
FakePeer.start4FakePeersRes(
8890
fakePeerCustomConfig2 = FakePeerCustomConfig(HostConfig()),
8991
fakePeerCustomConfig3 = FakePeerCustomConfig(HostConfig().copy(maxMptComponentsPerMessage = 0))
9092
)
91-
) { case (peer1, peer2, peer3) =>
93+
) { case (peer1, peer2, peer3, peer4) =>
9294
for {
9395
_ <- peer2.importBlocksUntil(1000)(updateStateAtBlock(500))
9496
_ <- peer3.importBlocksUntil(1000)(updateStateAtBlock(500))
95-
_ <- peer1.connectToPeers(Set(peer2.node, peer3.node))
97+
_ <- peer4.importBlocksUntil(1000)(updateStateAtBlock(500))
98+
99+
_ <- peer1.connectToPeers(Set(peer2.node, peer3.node, peer4.node))
96100
_ <- peer1.startFastSync().delayExecution(50.milliseconds)
97101
_ <- peer1.waitForFastSyncFinish()
98102
} yield {
99103
val trie = peer1.getBestBlockTrie()
100104
val synchronizingPeerHaveAllData = peer1.containsExpectedDataUpToAccountAtBlock(1000, 500)
101-
// due to the fact that function generating state is deterministic both peer2 and peer3 ends up with exactly same
105+
// due to the fact that function generating state is deterministic both peer3 and peer4 ends up with exactly same
102106
// state, so peer1 can get whole trie from both of them.
103-
assert(peer1.bl.getBestBlockNumber() == peer2.bl.getBestBlockNumber() - peer2.testSyncConfig.pivotBlockOffset)
104107
assert(peer1.bl.getBestBlockNumber() == peer3.bl.getBestBlockNumber() - peer3.testSyncConfig.pivotBlockOffset)
108+
assert(peer1.bl.getBestBlockNumber() == peer4.bl.getBestBlockNumber() - peer4.testSyncConfig.pivotBlockOffset)
105109
assert(trie.isDefined)
106110
assert(synchronizingPeerHaveAllData)
107111
}

src/it/scala/io/iohk/ethereum/sync/util/CommonFakePeer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
222222
startRetryInterval = 50.milliseconds,
223223
nodesPerRequest = 200,
224224
maxTargetDifference = 1,
225-
syncRetryInterval = 50.milliseconds
225+
syncRetryInterval = 50.milliseconds,
226+
blacklistDuration = 100.seconds
226227
)
227228

228229
lazy val broadcaster = new BlockBroadcast(etcPeerManager)

src/main/scala/io/iohk/ethereum/blockchain/sync/fast/HeaderSkeleton.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,27 @@ object HeaderSkeleton {
171171
override def msg: String = s"Invalid downloaded total headers. Expected $expected but was $downloaded"
172172
}
173173
case class InvalidHeaderNumber(downloaded: Seq[BigInt], expected: Seq[BigInt]) extends HeaderSkeletonError {
174-
override def msg: String = s"Invalid sequence of skeleton headers. Expected $expected but was $downloaded"
174+
override def msg: String =
175+
s"Invalid sequence of skeleton headers. Expected [${expected.mkString(",")}] but was [${downloaded.mkString(",")}]"
175176
}
176177

177178
sealed trait HeaderBatchError extends HeaderSkeletonError
178179
case class InvalidBatchLastNumber(downloaded: BigInt, expected: Seq[BigInt]) extends HeaderBatchError {
179-
override def msg: String = s"Invalid batch last number. $downloaded wasn't found in $expected"
180+
override def msg: String = s"Invalid batch last number. $downloaded wasn't found in [${expected.mkString(",")}]"
180181
}
181182
case class InvalidBatchHash(downloaded: BlockHeader, expected: BlockHeader) extends HeaderBatchError {
182183
override def msg: String = s"Invalid batch last block hash. Expected $expected but was $downloaded"
183184
}
184185
case class EmptyDownloadedBatch(expected: Seq[BigInt]) extends HeaderBatchError {
185-
override def msg: String = s"Downloaded empty headers batch. Expected $expected"
186+
override def msg: String = s"Downloaded empty headers batch. Expected [${expected.mkString(",")}]"
186187
}
187188
case class InvalidPenultimateHeader(penultimateBatchHeader: BlockHeader, skeletonHeader: BlockHeader)
188189
extends HeaderBatchError {
189190
override def msg: String =
190191
s"Invalid batch penultimate header. $penultimateBatchHeader isn't parent of $skeletonHeader"
191192
}
192193
case class InvalidBatchFirstNumber(downloaded: BigInt, expected: Seq[BigInt]) extends HeaderBatchError {
193-
override def msg: String = s"Invalid batch first number. $downloaded wasn't found in $expected"
194+
override def msg: String = s"Invalid batch first number. $downloaded wasn't found in [${expected.mkString(",")}]"
194195
}
195196
case class InvalidDownloadedChain(downloaded: Seq[BlockHeader]) extends HeaderBatchError {
196197
override def msg: String = s"Invalid downloaded batch: ${downloaded.map(h => h.number -> h.hash).mkString(", ")}"

0 commit comments

Comments
 (0)