Skip to content

Add simple integration test between Channel and Router #2268

Closed
pm47 wants to merge 7 commits intomasterfrom
router-test-improvements
Closed

Add simple integration test between Channel and Router #2268
pm47 wants to merge 7 commits intomasterfrom
router-test-improvements

Conversation

@pm47
Copy link
Member

@pm47 pm47 commented May 13, 2022

In this PR we add a basic integration test between Channel and Router that checks the proper handling of local announcements.

This test found two bugs, fixed in two separate commits.

@pm47 pm47 requested a review from t-bast May 13, 2022 12:24
Comment on lines +62 to +67
// this allows overriding the default eventstream in tests
val eventStream = eventStream_opt.getOrElse(context.system.eventStream)

eventStream.subscribe(self, classOf[LocalChannelUpdate])
eventStream.subscribe(self, classOf[LocalChannelDown])
eventStream.subscribe(self, classOf[AvailableBalanceChanged])
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a bit dirty: we only override the event stream for subscriptions. It's enough for testing, and it was not possible to update all references in Validation, RouteCalculation, Syncing etc. due to how the handlers are implemented. We could migrate them to the same technique as what we used for the channel fsm.

@pm47 pm47 changed the title Improve Router tests Improve router tests May 13, 2022
@pm47 pm47 changed the title Improve router tests Add simple integration test between Channel and Router May 13, 2022
pm47 added 7 commits May 13, 2022 14:46
This a minimal change that keep tests passing, but there is a lot
of cleanup left to do.

The issue with this technique is that we must not forget to call
`this.eventStream` instead of `context.system.eventStream` from the
`Channel` actor. However this would only affect tests since we use
the default `eventStream` in production.
The test currently fails, which looks like a bug to me. When a local
channel graduates from private to public, we do not copy existing
known `channel_update`s. Current implementation guarantees that we
will process our local `channel_update` immediately, but what about our
peer?
We fix a second bug where gossip origin wasn't properly set for local
announcements
@pm47 pm47 force-pushed the router-test-improvements branch from a43aee8 to e09360e Compare May 13, 2022 13:35
Comment on lines +151 to +162
val front1 = {
implicit val system: ActorSystem = system1
TestFSMRef[FrontRouter.State, FrontRouter.Data, FrontRouter](new FrontRouter(nodeParams.routerConf, router))
}
val front2 = {
implicit val system: ActorSystem = system2
TestFSMRef[FrontRouter.State, FrontRouter.Data, FrontRouter](new FrontRouter(nodeParams.routerConf, router))
}
val front3 = {
implicit val system: ActorSystem = system3
TestFSMRef[FrontRouter.State, FrontRouter.Data, FrontRouter](new FrontRouter(nodeParams.routerConf, router))
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I just realized that this trick (providing a custom ActorSystem) would also make it possible to segregate event streams in tests. Should I do that instead of 40cc09f? I think I should 😅

@pm47
Copy link
Member Author

pm47 commented May 13, 2022

Superseded by #2270.

@pm47 pm47 closed this May 13, 2022
@pm47 pm47 deleted the router-test-improvements branch November 4, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant