             [block-chain.http :as server]
             [block-chain.db :as db]
             [block-chain.queries :as q]
+            [block-chain.peer-client :as pc]
             [block-chain.blocks :as blocks]
-            [clojure.math.numeric-tower :as math]
             [block-chain.wallet :as wallet]
             [block-chain.miner :as miner]
             [block-chain.utils :refer :all]

          (:body (get-req "/blocks")))))

(deftest test-submitting-invalid-block-returns-validation-errors
  (with-redefs [target/default easy-difficulty]
    (let [resp (post-req "/blocks" (update-in next-block [:transactions 0 :outputs 0 :amount] inc))]
      (is (= "block-rejected" (:message (:body resp))))
      (is (= 400 (:status resp)))
      (is (= (sort ["Block's coinbase transaction is malformed or has incorrect amount."])
             (sort (:payload (:body resp))))))))

(deftest test-getting-blocks-since-height
  (miner/mine-and-commit-db)
  (miner/mine-and-commit-db)
  (is (= (map q/bhash (drop 1 (reverse (q/longest-chain @db/db))))
         (->> @db/db
              q/longest-chain
              last
              q/bhash
              (str "/blocks_since/")
              get-req
              :body
              :payload))))

           (:body r)))))

(deftest test-get-peers
  (q/add-peer! db/db {:host "127.0.0.1" :port "9999"})
  (is (= {:message "peers" :payload [{:host "127.0.0.1" :port "9999"}]}
         (:body (get-req "/peers")))))

(deftest test-get-balance
  (is (= {:message "balance" :payload {:address "pizza" :balance 0} } (:body (post-req "/balance" {:address "pizza"})))))

(deftest test-get-blocks
  (is  (= {:message "blocks" :payload (vec (reverse (q/longest-chain @db/db)))}
          (:body (get-req "/blocks")))))

(deftest test-get-transaction-pool
