                      :version 6
                      :payload wire-catalog}
 
-            hand-off-queue (java.util.concurrent.SynchronousQueue.)
-            storage-replace-catalog! scf-store/replace-catalog!]
+            latch (java.util.concurrent.CountDownLatch. 2)
+            orig-replace-existing-catalog scf-store/replace-existing-catalog]
 
         (jdbc/with-db-transaction []
           (scf-store/add-certname! certname)


        (with-redefs [quick-retry-count 0
                      command-delay-ms 1
                      scf-store/replace-catalog!
                      (fn [catalog timestamp]
                        (.put hand-off-queue "got the lock")
                        (.poll hand-off-queue 5 TimeUnit/SECONDS)
                        (storage-replace-catalog! catalog timestamp))]
          (let [first-message? (atom false)
                second-message? (atom false)
                fut (future
                      (handle-message (store-command' q command))
                      (reset! first-message? true))

                _ (.poll hand-off-queue 5 TimeUnit/SECONDS)

                new-wire-catalog (update wire-catalog :resources
                                         conj

            (handle-message (store-command' q new-catalog-cmd))
            (reset! second-message? true)

            @fut

            (is (empty? (fs/list-dir (:path dlo))))
            (let [failed-cmdref (take-with-timeout!! command-chan default-timeout-ms)]
              (is (= 1 (count (:attempts failed-cmdref))))
