             [clojure.core.async :as casync :refer [chan >!! <!! close! alts!!]]
             [clojure.tools.logging :refer :all]))
 
-(defn base-replica [peer-config]
-  (merge replica/base-replica 
-         {:job-scheduler (:onyx.peer/job-scheduler peer-config)
-          :messaging (select-keys peer-config [:onyx.messaging/impl])}))
-
-(defn playback-log [peer-config peer-log-reads]
+(defn playback-log [{:keys [base-replica entries] :as m}]
   (reduce #(onyx.extensions/apply-log-entry %2 %1)
-          (base-replica peer-config)
-          peer-log-reads))
-
-(comment (playback-log (clojure.edn/read-string (slurp "resources/prod-peer-config.edn"))
-                       (clojure.edn/read-string (slurp "/Users/lucas/clojure/onyx-jepsen/store/onyx-aggregation-test/20160626T165221.000Z/log.edn"))))
+          base-replica
+          entries))
 
 (defn pulses [conn peer-config]
   (onyx.log.curator/children conn (onyx.log.zookeeper/pulse-path (:onyx/tenancy-id peer-config))))

                                           n-jobs))
                  :reads-correct-jobs? correct-jobs?
                  :all-added-triggered? all-added-triggered?
                  :all-added-read? all-added-read?}}))

;; TODO, check whether the jobs were even submitted, if not, nothing should be read back 

       last
       last))

(defn final-trigger-write 
  "Reads the results of a single trigger ledger write. 
   Assumes only one trigger call has been made"
  [trigger-ledger-reads]
  (let [job-triggers (vec (remove (comp empty? :results) 
                                  (get (:value trigger-ledger-reads) 0)))]
    ;; final trigger write may occur multiple times if job isn't sealed before a peer crashes
    ;; this checks that all the trigger writes are the same
    (->> (first job-triggers)
         :results
         last
