   (core/reset-envelope-ids!)
   (reset-rand-state!)
   (f))
+
+(deftest maybe-conj-test
+  (is (= #{"susan" "howatch" "louis" "sachar"}
+         (core/maybe-conj #{"susan" "howatch" "louis"} "vinge" "sachar")))
+  (is (= #{"susan" "howatch" "louis" "sachar"}
+         (core/maybe-conj #{"susan" "howatch" "louis" "sachar"} "vinge" "vinge"))))
 
 (deftest subscribe-new-node-test
   (scamp-test


(deftest receive-msg-new-upstream-node-test
  (scamp-test
   #(is (= (core/receive-msg :new-upstream-node
                             core/default-config
                             {:self {:id "canticle"}
                              :upstream #{}
                              :downstream #{}
                              :messages-seen {}}
                             "liebowitz"
                             "43")
           [{:self {:id "canticle"},
             :upstream #{"liebowitz"},
             :downstream #{}
             :messages-seen {}} []]))))

(deftest send-msg-new-upstream-node-test
  (scamp-test

                [:message-envelope "node-id23" :node-removal "node-id19" "293"]]
               ))))))

(deftest receive-msg-node-node-removal
  (scamp-test
   #(binding [scamp.core/*rand* testing-rand*]
      (let [rem (core/receive-msg :node-removal
                                  core/default-config
                                  {:self {:id "Braedee"}
                                   :upstream #{"Charon" "Centauri"}
                                   :downstream #{"Daric" "Centauri"}
                                   :messages-seen {}}
                                  "Centauri"
                                  "43")]
        (is (= rem
               [{:self {:id "Braedee"},
                 :upstream #{"Charon"},
                 :downstream #{"Daric"},
                 :messages-seen {}}
                []]))))))



(comment
