                                 (close-peer (:event @previous-peer-state)))))
    :real/command #'new-log-after-crash})
 
-
 (def add-to-log-espec
   {:model/args (fn [state]
                  [gen/int])
    :next-state (fn [state [arg] result]
                  (conj state arg))
    :real/command #'add-to-bookkeeper})
-
-(defn new-peer-log []
-  (reset! bookkeeper-peer-state {:ledger-ids []
-                                 :event-log []})
-  ;; must setup before new-pipeline so that ledger id is recorded
-  (swap! bookkeeper-peer-state assoc :event (new-pipeline)))
 
 (defn close-peer-cleanup [state]
   (close-peer (:event @bookkeeper-peer-state)))


(def peer-config (assoc (:peer-config config) 
                        :onyx/id id
                        :onyx.bookkeeper/write-batch-size 1
                        :onyx.bookkeeper/write-batch-timeout 10000000))

(def bookkeeper-peer-state (atom nil))

(defn add-to-bookkeeper [arg]
  (let [event (:event @bookkeeper-peer-state)
        state-log (:onyx.core/state-log event)
        ack-promise (promise)]
    (state-ext/store-log-entry state-log event (fn [] (deliver ack-promise :done)) arg)
    ;; Wait until it's acked
    @ack-promise))

(defn init-state [& args]
  [])

            [com.gfredericks.test.chuck :refer [times]]
            [com.gfredericks.test.chuck.clojure-test :refer [checking]]))

(def messenger (dummy-messenger {:onyx.peer/try-join-once? false}))

(def id (java.util.UUID/randomUUID))
