Skip to content

Commit

Permalink
Add a test for if notifier stops unexpectedly
Browse files Browse the repository at this point in the history
  • Loading branch information
remyers committed Dec 5, 2022
1 parent 3ed6ee8 commit 026ea4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 026ea4e

Please sign in to comment.