 (defrecord TestNPRStreamRequest [stream-request]
   NPRStreamRequest
   (stream-request-snapshot-beg-msg [this snapshot]
-    (println "snapshot-beg-msg" snapshot)
     (merge stream-request {:status :part :sub-status :snapshot-beg
                            :snapshot snapshot}))
   (stream-request-snapshot-end-msg [this snapshot]
-    (println "snapshot-end-msg" snapshot)
     (merge stream-request {:status :part :sub-status :snapshot-end
                            :snapshot snapshot}))
   (stream-request-snapshot-item-msg [this snapshot item]
-    (println "snapshot-item-msg" snapshot item)
     (merge stream-request {:status :part :sub-status :snapshot-item
                            :snapshot snapshot
                            :item item}))
   (stream-request-rollback-msg [this rollback-info]
-    (println "snapshot-rollback-msg" rollback-info)
     (merge stream-request {:status :rollback
                            :rollback-info rollback-info}))
   (stream-request-start-sq [this]

(defrecord TestNPRServer [server]
  NPRServer
  (server-take-snapshot [this actx stream-request prev-snapshot]
    (println "server-take-snapshot" stream-request prev-snapshot)
    (let [start-sq (max (cbfg.npr/stream-request-start-sq stream-request)
                        (if prev-snapshot
                          (cbfg.npr/snapshot-next-sq prev-snapshot)
                          -1))]
      (println "server-take-snapshot start-sq" start-sq)
      (when (< start-sq (count (:items @server)))
        (let [items (nthnext (:items @server) start-sq)]
          (when (> (count items) 0)
            (println "server-take-snapshot2 start-sq" start-sq "items" items)
            (TestNPRSnapshot. {:items items
                               :next-sq (+ start-sq (count items))})))))))


    (TestNPRStreamRequest. (merge token {:op :stream-request
                                         :start-sq (count (:items @catom))})))
  (client-rollback [client actx stream-request rollback-msg]
    (swap! client #(update-in % [:hist] conj {:stream-request stream-request
                                              :rollback-msg rollback-msg}))
    nil)
  (client-snapshot-beg [client actx stream-request snapshot-beg]
    (swap! client #(update-in % [:hist] conj {:stream-request stream-request
                                              :snapshot-beg snapshot-beg}))
    nil)
  (client-snapshot-end [client actx stream-request snapshot-beg snapshot-end]
    (swap! client #(update-in % [:hist] conj {:stream-request stream-request
                                              :snapshot-beg snapshot-beg
                                              :snapshot-end snapshot-end}))
    nil)
  (client-snapshot-item [client actx stream-request snapshot-beg snapshot-item]
    (swap! client #(update-in % [:hist] conj {:stream-request stream-request
                                              :snapshot-beg snapshot-beg
                                              :snapshot-item snapshot-item}))
