Skip to content

Commit

Permalink
Fix watcher flaky test (#1883)
Browse files Browse the repository at this point in the history
This test sometimes fail when the `NewTransaction` events are delayed too
much because the CI machine is overloaded.
  • Loading branch information
t-bast committed Jul 16, 2021
1 parent adf36de commit 3f1c250
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind
probe.expectMsg(tx2.txid)
listener.expectNoMessage(1 second)

// We must unsubscribe the watcher from ZMQ tx subscriptions, otherwise this test has a race condition because
// bitcoind sends us a NewTransaction event for each transaction inside a new block. If these are delayed and are
// received after we registered our watch, we will receive the watch-triggered event twice.
system.eventStream.unsubscribe(watcher.ref.toClassic, classOf[NewTransaction])

system.eventStream.subscribe(probe.ref, classOf[CurrentBlockCount])
generateBlocks(1)
awaitCond(probe.expectMsgType[CurrentBlockCount].blockCount >= initialBlockCount + 2)
Expand Down

0 comments on commit 3f1c250

Please sign in to comment.