Skip to content

Commit 13389bb

Browse files
Maximiliano Biandrattibiandratti
authored andcommitted
it - should sync peers with divergent chains will be forced to resolve branches
1 parent 4953406 commit 13389bb

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,33 @@ class RegularSyncItSpec extends FlatSpecBase with Matchers with BeforeAndAfter {
7373
_ <- peer2.startRegularSync().delayExecution(50.milliseconds)
7474
_ <- peer2.importBlocksUntil(blockNumer)(IdentityUpdate)
7575
_ <- peer1.connectToPeers(Set(peer2.node))
76-
_ <- peer1.startRegularSync().delayExecution(50.milliseconds)
76+
_ <- peer1.startRegularSync().delayExecution(500.milliseconds)
7777
_ <- peer2.mineNewBlock()(IdentityUpdate).delayExecution(50.milliseconds)
7878
_ <- peer1.waitForRegularSyncLoadLastBlock(blockNumerOnTop)
7979
} yield {
8080
assert(peer1.bl.getBestBlockNumber() == peer2.bl.getBestBlockNumber())
8181
}
8282
}
8383

84+
it should "should sync peers with divergent chains will be forced to resolve branches"in customTestCaseResourceM(FakePeer.start2FakePeersRes()) {
85+
case (peer1, peer2) =>
86+
val blockNumer: BigInt = 2000
87+
for {
88+
_ <- peer2.startRegularSync().delayExecution(50.milliseconds)
89+
_ <- peer2.importBlocksUntil(blockNumer)(IdentityUpdate)
90+
_ <- peer1.startRegularSync().delayExecution(50.milliseconds)
91+
_ <- peer1.importBlocksUntil(blockNumer)(IdentityUpdate)
92+
_ <- peer2.mineNewBlock()(IdentityUpdate).delayExecution(50.milliseconds)
93+
_ <- peer2.waitForRegularSyncLoadLastBlock(blockNumer + 1)
94+
_ <- peer1.mineNewBlock()(IdentityUpdate).delayExecution(50.milliseconds)
95+
_ <- peer1.waitForRegularSyncLoadLastBlock(blockNumer + 1)
96+
_ <- peer1.connectToPeers(Set(peer2.node)).delayExecution(50.milliseconds)
97+
_ <- peer2.connectToPeers(Set(peer1.node)).delayExecution(50.milliseconds)
98+
} yield {
99+
assert(peer1.bl.getBestBlockNumber() == peer2.bl.getBestBlockNumber())
100+
}
101+
}
102+
84103
}
85104

86105
object RegularSyncItSpec {

0 commit comments

Comments
 (0)