Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(ns i2conomy.mint) | ||
|
||
(def transfers (ref ())) | ||
|
||
(defrecord Transfer [timestamp from to currency amount memo]) | ||
|
||
(defn pay | ||
"Makes a payment between accounts" | ||
[from to currency amount memo] | ||
(dosync | ||
(let [now (java.util.Date.)] | ||
(alter transfers conj (Transfer. now from to currency amount memo))))) | ||
|
||
(defn reset-all! | ||
"Reset all transfers, use with care" | ||
[] | ||
(dosync | ||
(ref-set transfers ()))) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(ns i2conomy.test.mint | ||
(:use [i2conomy.mint] :reload) | ||
(:use [clojure.test])) | ||
|
||
(deftest no-payments | ||
(do | ||
(reset-all!) | ||
(is (= 0 (count @transfers))))) | ||
|
||
(deftest single-payment | ||
(do | ||
(reset-all!) | ||
(pay "alice" "bob" "alice" 100 "groceries") | ||
(is (= 1 (count @transfers))))) |