started the rest api
This commit is contained in:
1 parent
516cccf4cd
commit
ad924ca5c7
10 files changed
+320
-91
No files matched your search
@@ -0,0 +1,28 @@
|
||||
(ns book.exchange-test
|
||||
(:require [midje.sweet :refer :all]
|
||||
[book.exchange :refer :all]
|
||||
[book.match :refer [create-buy-book
|
||||
create-sell-book]]
|
||||
[clojure.core.async :refer [chan go >!! <!!]]))
|
||||
|
||||
(facts "the exchange as an whole"
|
||||
(fact "sell order followed by a buy order trivialities "
|
||||
(let [incoming-order-channel (chan)
|
||||
trades-channel (chan)
|
||||
new-book-order-channel (chan)
|
||||
master-book {:sell (create-sell-book) :buy (create-buy-book)}]
|
||||
(go (process-orders master-book incoming-order-channel trades-channel new-book-order-channel))
|
||||
(>!! incoming-order-channel {:type :sell :quantity 10 :price 2})
|
||||
(<!! new-book-order-channel) => {:type :sell :quantity 10 :price 2}
|
||||
(>!! incoming-order-channel {:type :buy :quantity 20 :price 2})
|
||||
(<!! trades-channel) => #:book.order{:book-id nil
|
||||
:order-id nil
|
||||
:price 2
|
||||
:quantity 10
|
||||
:type :sell}
|
||||
(<!! new-book-order-channel) => {:type :buy :quantity 10 :price 2})))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user