 (def rpc-msg-id (atom 100))
 (def rpc-deliver-map (atom {}))
 
-
 (s/defn rpc-call-2 :- s/Any
   [msg :- tsk/KeyMap]
   (let [rpc-msg-id     (swap! rpc-msg-id inc)
         msg            (glue msg {:attrs {:message-id rpc-msg-id
                                           :xmlns      "urn:ietf:params:xml:ns:netconf:base:1.0"}})
-        result-promise (promise) ]
+        result-promise (promise)]
     (swap! rpc-deliver-map glue {rpc-msg-id result-promise}) ;  #todo temp!
 
-    (future ; Simulate calling out to http server in another thread
+    (future         ; Simulate calling out to http server in another thread
       (try
         (Thread/sleep *rpc-delay-simulated-ms*) ; simulated network delay
         (let [rpc-result        (validate-parse-rpc rpc-schema msg)
               rpc-reply-msg-id  (fetch-in rpc-result [:attrs :message-id])
               fpc-reply-promise (grab rpc-reply-msg-id @rpc-deliver-map)]
           (deliver fpc-reply-promise rpc-result))
-       (catch Exception e
-         (deliver result-promise ; deliver any exception to caller
-           (RuntimeException. (str "rpc-call-2: failed  msg=" msg \newline
-                                "  caused by=" (.getMessage e)))))))
-
-    result-promise ; return promise to caller immediately
-  ))
+        (catch Exception e
+          (deliver result-promise ; deliver any exception to caller
+            (RuntimeException. (str "rpc-call-2: failed  msg=" msg \newline
+                                 "  caused by=" (.getMessage e)))))))
+
+    result-promise  ; return promise to caller immediately
+    ))
 
 (defn add-2 [x y]
   (let [result-promise (rpc-call-2



;*****************************************************************************
;*****************************************************************************

(dotest
  (let [abnf-src  (io/resource "yang3.abnf")

                             [:x (str x)]
                             [:y (str y)]]]))
        rpc-result     (deref result-promise *rpc-timeout-ms* :timeout-failure)
        _              (when (instance? Throwable rpc-result)
                         (throw (RuntimeException. (.getMessage rpc-result))))
        result         (get-leaf rpc-result [:rpc-reply :data])]
    (when (= :timeout-failure rpc-result)
      (throw (TimeoutException. (format "Timeout Exceed=%s  add: %s %s; " *rpc-timeout-ms* x y))))
    result))

(dotest
  (binding [*rpc-timeout-ms*         300
            *rpc-delay-simulated-ms* 10]
    (reset! rpc-msg-id 100)
    (is (rel= 5 (spyx (add-2 2 3)) :digits 9))
  ))

