Skip to content

Commit 3f1c250

Browse files
authored
Fix watcher flaky test (#1883)
This test sometimes fail when the `NewTransaction` events are delayed too much because the CI machine is overloaded.
1 parent adf36de commit 3f1c250

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/ZmqWatcherSpec.scala

+5
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind
243243
probe.expectMsg(tx2.txid)
244244
listener.expectNoMessage(1 second)
245245

246+
// We must unsubscribe the watcher from ZMQ tx subscriptions, otherwise this test has a race condition because
247+
// bitcoind sends us a NewTransaction event for each transaction inside a new block. If these are delayed and are
248+
// received after we registered our watch, we will receive the watch-triggered event twice.
249+
system.eventStream.unsubscribe(watcher.ref.toClassic, classOf[NewTransaction])
250+
246251
system.eventStream.subscribe(probe.ref, classOf[CurrentBlockCount])
247252
generateBlocks(1)
248253
awaitCond(probe.expectMsgType[CurrentBlockCount].blockCount >= initialBlockCount + 2)

0 commit comments

Comments
 (0)