Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class RegularSyncSpec
def sync[T <: Fixture](test: => T): Future[Assertion] =
Future {
test
// this makes sure that actors are all done after the test (believe me, afterEach does not work with mocks)
TestKit.shutdownActorSystem(testSystem)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 'fixture' pretty weird... are there any other tests with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's custom to this test, haven't seen it any other place.

succeed
}

Expand Down Expand Up @@ -475,7 +477,7 @@ class RegularSyncSpec
peersClient.setAutoPilot(new PeersClientAutoPilot)
override lazy val branchResolution: BranchResolution = stub[BranchResolution]
(blockchainReader.getBestBlockNumber _).when().returns(0)
(branchResolution.resolveBranch _).when(*).returns(NewBetterBranch(Nil)).repeat(10)
(branchResolution.resolveBranch _).when(*).returns(NewBetterBranch(Nil)).atLeastOnce()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not convinced if this is required but the repeat(10) seems arbitrary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, atLeastOnce or anyNumberOf Times seems more appropriate. I just always wonder why does a method needs to be called so many times. Is it a recursive one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the logic in RegularSync will run a retry on failure. the failure is the missing node (vide a bit lower) which should result in some logic and a retry. the 10 used to be 1 a long time ago.

(blockImport
.importBlock(_: Block)(_: Scheduler))
.when(*, *)
Expand Down