From 026ea4ed25c00b5c36da6f2b773a2004b69905d9 Mon Sep 17 00:00:00 2001 From: Richard Myers Date: Mon, 5 Dec 2022 17:11:18 +0100 Subject: [PATCH] Add a test for if notifier stops unexpectedly --- .../eclair/payment/relay/AsyncPaymentTriggerer.scala | 2 +- .../eclair/payment/relay/AsyncPaymentTriggererSpec.scala | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala b/eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala index 6423821db6..9f9aed81a9 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggerer.scala @@ -40,7 +40,7 @@ object AsyncPaymentTriggerer { sealed trait Command case class Start(switchboard: ActorRef[Switchboard.GetPeerInfo]) extends Command case class Watch(replyTo: ActorRef[Result], remoteNodeId: PublicKey, paymentHash: ByteVector32, timeout: BlockHeight) extends Command - private case class NotifierStopped(remoteNodeId: PublicKey) extends Command + private[relay] case class NotifierStopped(remoteNodeId: PublicKey) extends Command private case class WrappedPeerReadyResult(result: PeerReadyNotifier.Result) extends Command private case class WrappedCurrentBlockHeight(currentBlockHeight: CurrentBlockHeight) extends Command diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggererSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggererSpec.scala index c1ff56b309..c490316b86 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggererSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/AsyncPaymentTriggererSpec.scala @@ -157,4 +157,12 @@ class AsyncPaymentTriggererSpec extends ScalaTestWithActorTestKit(ConfigFactory. probe2.expectMessage(AsyncPaymentTriggered) } + test("triggerer treats an unexpected stop of the notifier as a timeout") { f => + import f._ + triggerer ! Watch(probe.ref, remoteNodeId, paymentHash = ByteVector32.Zeroes, timeout = BlockHeight(100)) + assert(switchboard.expectMessageType[GetPeerInfo].remoteNodeId == remoteNodeId) + + triggerer ! NotifierStopped(remoteNodeId) + probe.expectMessage(AsyncPaymentTimeout) + } }