           :log []
           :peer-choices []}))]
     (standard-invariants replica)
+    (is (empty? (:accepted replica)))
+    (is (empty? (:prepared replica)))
     (is (or (= 2 (count (:peer-state replica)))
             (= 3 (count (:peer-state replica)))))
     (is (or (= 2 (count (:peers replica)))
             (= 3 (count (:peers replica)))))))
 
-
-(deftest peer-leave-still-running
-  (checking
-    "Checking peer leave is correctly performed"
+(deftest peer-spurious-notify
+  (checking
+    "Checking a spurious notify is handled correctly"
     (times 50)
     [{:keys [replica log peer-choices]}
      (log-gen/apply-entries-gen

                                       peer-config
                                       job-1
                                       (planning/discover-tasks (:catalog job-1) (:workflow job-1)))]})
              (assoc :spurious-notify {;:predicate (fn [replica entry]
                                       ;               (some #{:p5} (:peers replica)))
                                       :queue [{:fn :notify-join-cluster
                                                :args {:observer :p5}}]})
              (assoc :leave-1 {:queue [{:fn :leave-cluster :args {:id :p1}}]})
              (assoc :leave-2 {:queue [{:fn :leave-cluster :args {:id :p2}}]}))
          :log []
          :peer-choices []}))]
    (standard-invariants replica)
    ;; peers may have left before they joined, so there should be at LEAST 7 peers allocated
    ;; since there are enough peers to handle 2 peers leaving without a task being deallocated the
    ;; job must be able to go on
    (is (>= (apply + (map count (vals (get (:allocations replica) job-1-id)))) 7))))


;; Reproduce onyx-test scheduler issue
(def inner-job-id #uuid "f55c14f0-a847-42eb-81bb-0c0390a88608")

                                      :args {:id :p1}}]}))
          :log []
          :peer-choices []}))]
    (is (empty? (:accepted replica)))
    (is (empty? (:prepared replica)))
    (standard-invariants replica)
    (is (= 3 (count (:peer-state replica))))
    (is (= 3 (count (:peers replica))))))
