Skip to content

Commit

Permalink
Fix flaky relay-htlc-add test (#1752)
Browse files Browse the repository at this point in the history
We need to wait for the channel relayer to be registered to the event stream
before publishing an event, otherwise the channel relayer will never receive it.

We send it a first message and wait for its response to ensure it had time
to correctly initialize.
  • Loading branch information
t-bast authored Apr 1, 2021
1 parent 936f36b commit ac2b784
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ class RelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("applicat
test("relay an htlc-add") { f =>
import f._

system.eventStream ! EventStream.Publish(LocalChannelUpdate(null, channelId_bc, channelUpdate_bc.shortChannelId, c, None, channelUpdate_bc, makeCommitments(channelId_bc)))

// We make sure the channel relayer is initialized
val sender = TestProbe[Relayer.OutgoingChannels]()
childActors.channelRelayer ! ChannelRelayer.GetOutgoingChannels(sender.ref.toClassic, GetOutgoingChannels())
assert(sender.expectMessageType[Relayer.OutgoingChannels].channels.isEmpty)

// We publish a channel update, that should be picked up by the channel relayer
system.eventStream ! EventStream.Publish(LocalChannelUpdate(null, channelId_bc, channelUpdate_bc.shortChannelId, c, None, channelUpdate_bc, makeCommitments(channelId_bc)))
eventually(PatienceConfiguration.Timeout(30 seconds), PatienceConfiguration.Interval(1 second)) {
childActors.channelRelayer ! ChannelRelayer.GetOutgoingChannels(sender.ref.toClassic, GetOutgoingChannels())
val channels = sender.expectMessageType[Relayer.OutgoingChannels].channels
Expand Down

0 comments on commit ac2b784

Please sign in to comment.