1
1
package io .iohk .ethereum .sync
2
2
3
3
import io .iohk .ethereum .FlatSpecBase
4
- import io .iohk .ethereum .sync .util .FakePeerRegularSync
5
- import io .iohk .ethereum .sync .util .SyncUtils . identityUpdate
4
+ import io .iohk .ethereum .sync .util .RegularSyncItSpecUtils . FakePeer
5
+ import io .iohk .ethereum .sync .util .SyncCommonItSpec . _
6
6
import monix .execution .Scheduler
7
7
import org .scalatest .BeforeAndAfter
8
8
import org .scalatest .matchers .should .Matchers
@@ -12,48 +12,48 @@ import scala.concurrent.duration._
12
12
class RegularSyncItSpec extends FlatSpecBase with Matchers with BeforeAndAfter {
13
13
implicit val testScheduler = Scheduler .fixedPool(" test" , 16 )
14
14
15
- it should " should sync blockchain with same best block" in customTestCaseResourceM(FakePeerRegularSync .start2FakePeersRes()) {
15
+ it should " should sync blockchain with same best block" in customTestCaseResourceM(FakePeer .start2FakePeersRes()) {
16
16
case (peer1, peer2) =>
17
17
val blockNumer : Int = 2000
18
18
for {
19
- _ <- peer2.importBlocksUntil(blockNumer)(identityUpdate )
19
+ _ <- peer2.importBlocksUntil(blockNumer)(IdentityUpdate )
20
20
_ <- peer1.connectToPeers(Set (peer2.node))
21
- _ <- peer1.start .delayExecution(50 .milliseconds)
22
- _ <- peer2.broadcastBlock()(identityUpdate ).delayExecution(500 .milliseconds)
21
+ _ <- peer1.startRegularSync() .delayExecution(50 .milliseconds)
22
+ _ <- peer2.broadcastBlock()(IdentityUpdate ).delayExecution(500 .milliseconds)
23
23
_ <- peer1.waitForRegularSyncLoadLastBlock(blockNumer)
24
24
} yield {
25
25
assert(peer1.bl.getBestBlockNumber() == peer2.bl.getBestBlockNumber())
26
26
}
27
27
}
28
28
29
- it should " should sync blockchain progressing forward in the same time" in customTestCaseResourceM(FakePeerRegularSync .start2FakePeersRes()) {
29
+ it should " should sync blockchain progressing forward in the same time" in customTestCaseResourceM(FakePeer .start2FakePeersRes()) {
30
30
case (peer1, peer2) =>
31
31
val blockNumer : Int = 2000
32
32
for {
33
- _ <- peer2.start .delayExecution(50 .milliseconds)
34
- _ <- peer2.importBlocksUntil(blockNumer)(identityUpdate )
33
+ _ <- peer2.startRegularSync() .delayExecution(50 .milliseconds)
34
+ _ <- peer2.importBlocksUntil(blockNumer)(IdentityUpdate )
35
35
_ <- peer1.connectToPeers(Set (peer2.node))
36
- _ <- peer1.start .delayExecution(500 .milliseconds)
37
- _ <- peer2.mineNewBlock()(identityUpdate ).delayExecution(50 .milliseconds)
36
+ _ <- peer1.startRegularSync() .delayExecution(500 .milliseconds)
37
+ _ <- peer2.mineNewBlock()(IdentityUpdate ).delayExecution(50 .milliseconds)
38
38
_ <- peer1.waitForRegularSyncLoadLastBlock(blockNumer + 1 )
39
39
} yield {
40
40
assert(peer1.bl.getBestBlockNumber() == peer2.bl.getBestBlockNumber())
41
41
}
42
42
}
43
43
44
- it should " should sync peers with divergent chains will be forced to resolve branches" in customTestCaseResourceM(FakePeerRegularSync .start2FakePeersRes()) {
44
+ it should " should sync peers with divergent chains will be forced to resolve branches" in customTestCaseResourceM(FakePeer .start2FakePeersRes()) {
45
45
case (peer1, peer2) =>
46
46
val blockNumer : Int = 2000
47
47
for {
48
- _ <- peer2.importBlocksUntil(blockNumer)(identityUpdate )
49
- _ <- peer2.start .delayExecution(50 .milliseconds)
50
- _ <- peer1.importBlocksUntil(blockNumer)(identityUpdate )
51
- _ <- peer1.start .delayExecution(50 .milliseconds)
52
- _ <- peer2.mineNewBlock(10 )(identityUpdate ).delayExecution(500 .milliseconds)
53
- _ <- peer2.mineNewBlock(10 )(identityUpdate ).delayExecution(500 .milliseconds)
54
- _ <- peer2.mineNewBlock(10 )(identityUpdate ).delayExecution(500 .milliseconds)
48
+ _ <- peer2.importBlocksUntil(blockNumer)(IdentityUpdate )
49
+ _ <- peer2.startRegularSync() .delayExecution(50 .milliseconds)
50
+ _ <- peer1.importBlocksUntil(blockNumer)(IdentityUpdate )
51
+ _ <- peer1.startRegularSync() .delayExecution(50 .milliseconds)
52
+ _ <- peer2.mineNewBlock(10 )(IdentityUpdate ).delayExecution(500 .milliseconds)
53
+ _ <- peer2.mineNewBlock(10 )(IdentityUpdate ).delayExecution(500 .milliseconds)
54
+ _ <- peer2.mineNewBlock(10 )(IdentityUpdate ).delayExecution(500 .milliseconds)
55
55
_ <- peer2.waitForRegularSyncLoadLastBlock(blockNumer + 3 )
56
- _ <- peer1.mineNewBlock()(identityUpdate ).delayExecution(500 .milliseconds)
56
+ _ <- peer1.mineNewBlock()(IdentityUpdate ).delayExecution(500 .milliseconds)
57
57
_ <- peer1.waitForRegularSyncLoadLastBlock(blockNumer + 1 )
58
58
_ <- peer1.connectToPeers(Set (peer2.node)).delayExecution(500 .milliseconds)
59
59
_ <- peer1.waitForRegularSyncLoadLastBlock(blockNumer + 3 )
0 commit comments