@@ -59,49 +59,53 @@ class FastSyncItSpec extends FlatSpecBase with Matchers with BeforeAndAfterAll {
59
59
60
60
it should " sync blockchain with state nodes when peer do not response with full responses" in
61
61
customTestCaseResourceM(
62
- FakePeer .start3FakePeersRes (
62
+ FakePeer .start4FakePeersRes (
63
63
fakePeerCustomConfig2 = FakePeerCustomConfig (HostConfig ()),
64
64
fakePeerCustomConfig3 = FakePeerCustomConfig (HostConfig ())
65
65
)
66
- ) { case (peer1, peer2, peer3) =>
66
+ ) { case (peer1, peer2, peer3, peer4 ) =>
67
67
for {
68
68
_ <- peer2.importBlocksUntil(1000 )(updateStateAtBlock(500 ))
69
69
_ <- 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))
71
73
_ <- peer1.startFastSync().delayExecution(50 .milliseconds)
72
74
_ <- peer1.waitForFastSyncFinish()
73
75
} yield {
74
76
val trie = peer1.getBestBlockTrie()
75
77
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
77
79
// state, so peer1 can get whole trie from both of them.
78
- assert(peer1.bl.getBestBlockNumber() == peer2.bl.getBestBlockNumber() - peer2.testSyncConfig.pivotBlockOffset)
79
80
assert(peer1.bl.getBestBlockNumber() == peer3.bl.getBestBlockNumber() - peer3.testSyncConfig.pivotBlockOffset)
81
+ assert(peer1.bl.getBestBlockNumber() == peer4.bl.getBestBlockNumber() - peer4.testSyncConfig.pivotBlockOffset)
80
82
assert(trie.isDefined)
81
83
assert(synchronizingPeerHaveAllData)
82
84
}
83
85
}
84
86
85
87
it should " sync blockchain with state nodes when one of the peers send empty state responses" in
86
88
customTestCaseResourceM(
87
- FakePeer .start3FakePeersRes (
89
+ FakePeer .start4FakePeersRes (
88
90
fakePeerCustomConfig2 = FakePeerCustomConfig (HostConfig ()),
89
91
fakePeerCustomConfig3 = FakePeerCustomConfig (HostConfig ().copy(maxMptComponentsPerMessage = 0 ))
90
92
)
91
- ) { case (peer1, peer2, peer3) =>
93
+ ) { case (peer1, peer2, peer3, peer4 ) =>
92
94
for {
93
95
_ <- peer2.importBlocksUntil(1000 )(updateStateAtBlock(500 ))
94
96
_ <- 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))
96
100
_ <- peer1.startFastSync().delayExecution(50 .milliseconds)
97
101
_ <- peer1.waitForFastSyncFinish()
98
102
} yield {
99
103
val trie = peer1.getBestBlockTrie()
100
104
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
102
106
// state, so peer1 can get whole trie from both of them.
103
- assert(peer1.bl.getBestBlockNumber() == peer2.bl.getBestBlockNumber() - peer2.testSyncConfig.pivotBlockOffset)
104
107
assert(peer1.bl.getBestBlockNumber() == peer3.bl.getBestBlockNumber() - peer3.testSyncConfig.pivotBlockOffset)
108
+ assert(peer1.bl.getBestBlockNumber() == peer4.bl.getBestBlockNumber() - peer4.testSyncConfig.pivotBlockOffset)
105
109
assert(trie.isDefined)
106
110
assert(synchronizingPeerHaveAllData)
107
111
}
0 commit comments