From 91a0d40cebffcb07af624faaa30dc0f4396ada72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Thor=C3=A9n?= Date: Mon, 20 Nov 2017 21:07:43 +0100 Subject: [PATCH] Integration tests: Basic Whisper version test and disable old --- test/cljs/status_im/test/protocol/core.cljs | 21 ++++++++++++++++++++- test/cljs/status_im/test/protocol/node.cljs | 10 +++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/test/cljs/status_im/test/protocol/core.cljs b/test/cljs/status_im/test/protocol/core.cljs index 1bbcd2e338..67aff540d0 100644 --- a/test/cljs/status_im/test/protocol/core.cljs +++ b/test/cljs/status_im/test/protocol/core.cljs @@ -1,12 +1,16 @@ (ns status-im.test.protocol.core (:require [cljs.test :refer-macros [deftest is testing run-tests async]] [cljs.nodejs :as nodejs] + [status-im.protocol.web3.utils :as web3.utils] [status-im.test.protocol.node :as node] [status-im.test.protocol.utils :as utils] [status-im.protocol.core :as protocol])) +;; NOTE(oskarth): All these tests are evaluated in NodeJS + (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") @@ -37,7 +41,10 @@ :contacts contacts :post-error-callback (post-error-callback id)}) -(deftest test-send-message! +;; 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 +;; TODO(oskarth): Fix this test, issue with private key not being persisted +#_(deftest test-send-message! (async done (node/start!) (let [web3 (make-web3) @@ -63,3 +70,15 @@ :content-type "text/plain" :content "123" :timestamp 1498723691404}}})))) + +;; TODO(oskarth): Add fixtures to start node before running tests against node +(deftest test-whisper-version! + (testing "Whisper version supported" + (async done + (node/start!) + (let [web3 (make-web3) + shh (web3.utils/shh web3)] + (.version shh + (fn [& args] + (is (= "5.0" (second args))) + (done))))))) diff --git a/test/cljs/status_im/test/protocol/node.cljs b/test/cljs/status_im/test/protocol/node.cljs index 86b67d710e..4a94344d2e 100644 --- a/test/cljs/status_im/test/protocol/node.cljs +++ b/test/cljs/status_im/test/protocol/node.cljs @@ -13,18 +13,18 @@ (let [dir (s/join "/" [build-dir "status-go"]) opts #js {:cwd dir}] (if-not (utils/exist? dir) - (utils/exec-sync "git clone https://github.com/status-im/status-go.git -b bug/whisper-on-geth1.6.1" #js {:cwd build-dir}) - (utils/exec-sync "git pull origin bug/whisper-on-geth1.6.1" opts)) + (utils/exec-sync "git clone https://github.com/status-im/status-go.git -b develop" #js {:cwd build-dir}) + (utils/exec-sync "git pull origin develop" opts)) (println "Compile statusgo...") (utils/exec-sync "make statusgo" opts) (println "Done."))) (defn start! [] (when-not @node-process - (println "Start wnode...") + (println "Start statusd...") (let [dir (s/join "/" [build-dir "status-go" "build" "bin"])] (let [proc (utils/spawn "./statusd" - ["wnode" "--http" "--httpport" "8645"] + ["--http" "--httpport" "8645" "-shh" "-logfile" "statusd.log"] {:cwd dir})] (reset! node-process proc) (utils/sleep 5) @@ -32,7 +32,7 @@ (defn stop! [] - (println "Stop wnode...") + (println "Stop statusd...") (.kill @node-process) (println "Done.") (reset! node-process nil))