 (s/defn do-probability :- s/Bool
   "'rand is inclusive of 0 and exclusive of 1, so our test should not have '=."
   [cutoff :- ProbabilitySchema]
-  (< (rand) cutoff))
+  (< (*rand*) cutoff))
 
 (s/defn forward-subscription :- [MessageEnvelopeSchema]
   "Take a node's 'downstream map and a new 'subscription.

  (if (empty? downstream)
    []
    [[:message-envelope
      (rand-nth (seq downstream))
      :forwarded-subscription
      subscription
      (get-envelope-id)]]))

  "TODO: replace with UUIDs"
  []
  (str (swap! envelope-id-counter inc)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Custom randomization (for predictable testing)
(def ^:dynamic *rand* rand)

(defn- ^Integer rand-int* [n]
  (int (*rand* n)))

(defn- rand-nth* [coll]
  (nth coll (rand-int* (count coll))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Schema definitions
