Unit test for deploying multisig

* clojure test for deploying multisig contract to blockchain
This commit is contained in:
Teemu Patja 2017-08-22 13:53:05 +03:00
parent 9cc524c432
commit c6f6afa461
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
(ns commiteth.test.multisig-wallet
(:require [clojure.test :refer :all]
[commiteth.eth.core :as eth]
[commiteth.eth.multisig-wallet :as multisig]))
(def OWNER_ADDRESS "0xa1cab91b36bea34487c5670bbd00a1aa8196aed8")
(defn wait-for [predicate]
(let [timeout-secs 30
end-time (+ (System/currentTimeMillis) (* timeout-secs 1000))]
(loop []
(if-let [result (predicate)]
result
(do
(Thread/sleep 1000)
(if (< (System/currentTimeMillis) end-time)
(recur)))))))
;; deploys a multisig and gets it's address. assumes test environment configured correctly (access to running geth, eth wallet, password etc)
(deftest test-deploy
(testing "Deploying a multisig"
(let [tx-id (multisig/deploy-multisig OWNER_ADDRESS)
tx-receipt (wait-for (fn [] (eth/get-transaction-receipt tx-id)))
addr (-> tx-receipt
(multisig/find-created-multisig-address))]
(println "Created multisig address" addr)
(is (not-empty addr)))))