                     [advance redefs] (fake-timeout)]
                 (with-redefs-fn redefs
                   (fn []
-                    (let [c (execute step)]
+                    (let [s (execute step)]
                       (assert (still-open?) "before adding callback")
-                      (take! c (fn [_] (reset! state false)))
+                      (md/chain (ms/take! s) (fn [_] (reset! state false)))
                       (assert (still-open?) "after adding callback")
                       (advance 5)
                       (assert (still-open?) "before trigger")

(ns icecap.handlers.delay-test
  (:require [schema.core :as s]
            [icecap.handlers.core :refer [execute get-schema]]
            [clojure.core.async :refer [take! chan close!]]
            [icecap.handlers.delay :refer :all]
            [clojure.test :refer :all])
  (:import (java.lang Thread)))

(defn fake-clock

  []
  (let [{:keys [advance add-waiter]} (fake-clock)
        timeout (fn [^long ms]
                  (let [c (async/chan)]
                    (add-waiter ms false #(async/close! c))
                    c))]
    [advance {#'clojure.core.async/timeout timeout}]))

