From 8fe9306caf0c51552ee657559de47ebbe01fe77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Thor=C3=A9n?= Date: Tue, 21 Nov 2017 13:13:25 +0100 Subject: [PATCH] Integration tests: use fixtures and abort indeterminate --- test/cljs/status_im/test/protocol/core.cljs | 41 ++++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/test/cljs/status_im/test/protocol/core.cljs b/test/cljs/status_im/test/protocol/core.cljs index 67aff540d0..4860d9479f 100644 --- a/test/cljs/status_im/test/protocol/core.cljs +++ b/test/cljs/status_im/test/protocol/core.cljs @@ -1,6 +1,9 @@ (ns status-im.test.protocol.core - (:require [cljs.test :refer-macros [deftest is testing run-tests async]] + (:require-macros [cljs.core.async.macros :as async]) + (:require [cljs.test :refer-macros [deftest is testing run-tests + async use-fixtures]] [cljs.nodejs :as nodejs] + [cljs.core.async :as async] [status-im.protocol.web3.utils :as web3.utils] [status-im.test.protocol.node :as node] [status-im.test.protocol.utils :as utils] @@ -10,14 +13,28 @@ (nodejs/enable-util-print!) -;; NOTE(oskarth): If status-go has already been built correctly, comment this out -(node/prepare-env!) - (def rpc-url "http://localhost:8645") (def Web3 (js/require "web3")) (defn make-web3 [] (Web3. (Web3.providers.HttpProvider. rpc-url))) +(defn setup [] + (println "Setup...") + + ;; NOTE(oskarth): If status-go has already been built correctly, comment this out + (println "Preparing environment...") + (node/prepare-env!) + + (println "Start node...") + (node/start!) + + (println "Setup done")) + +(defn teardown [] + (println "Teardown done")) + +(use-fixtures :once {:before setup :after teardown}) + (defn make-callback [identity done] (fn [& args] (is (contains? #{:sent :pending} (first args))) @@ -41,13 +58,17 @@ :contacts contacts :post-error-callback (post-error-callback id)}) -;; NOTE(oskarth): Test assumes callback is always called, otherwise it won't terminate -;; TODO(oskarth): Add a timeout async function where we fail test if it takes too long to finish +(defn ensure-test-terminates! [timeout done] + (async/go (async/