1 | require "./test_helper"
|
2 | balance = require "../src/crypto-balance"
|
3 | _ = require("lodash")
|
4 |
|
5 |
|
6 | describe "Balance", ->
|
7 |
|
8 | it "gets something", (done) ->
|
9 | balance("DP15mU18LLcLMpULSpFm5R77FYjsjjRCPu").then (result) ->
|
10 | expect(result).to.be.an "array"
|
11 | expect(result).to.not.be.empty
|
12 | done()
|
13 |
|
14 | it "returns the number of burned DOGE for Dogeparty", (done) ->
|
15 | balance("DDogepartyxxxxxxxxxxxxxxxxxxw1dfzr").then (result) ->
|
16 | expect(result).to.have.length(1)
|
17 | expect(result[0].asset).to.be.eq "DOGE"
|
18 | expect(result[0].quantity).to.be.eq "1831619391.01419473"
|
19 | expect(result[0].address).to.be.eq "DDogepartyxxxxxxxxxxxxxxxxxxw1dfzr"
|
20 | done()
|
21 |
|
22 | it "has a custom Dogeparty asset", (done) ->
|
23 | balance("DCt8sxHX634ghqdDhWFtCPQUyZ3TEfLBCo").then (result) ->
|
24 | expect(result).to.not.be.empty
|
25 | dp = _.find(result, (item) -> item.asset == "XDP/DOGEPARTY")
|
26 | expect(dp).to.exist
|
27 | expect(dp.quantity).to.be.eq "1.00000000"
|
28 | done()
|
29 |
|
30 | it "has a MSC balance", (done) ->
|
31 | balance("1Po1oWkD2LmodfkBYiAktwh76vkF93LKnh").then (result) ->
|
32 | msc = _.find(result, (item) -> item.asset == "MSC")
|
33 | expect(msc).to.exist
|
34 | expect(msc.quantity).to.be.eq "1738.58121469"
|
35 | done()
|
36 |
|
37 | it "deals correctly with OmniWallet's API not being available", (done) ->
|
38 | balance("1MaStErt4XsYHPwfrN9TpgdURLhHTdMenH").then (result) ->
|
39 | msc = _.find(result, (item) -> _.contains(item.service, "omniwallet"))
|
40 | expect(msc).to.exist
|
41 | expect(msc.status).to.be.eq "error"
|
42 | done()
|
43 |
|
44 | it "has a MAID balance", (done) ->
|
45 | balance("1madYsPmALf1TCo1qttumTH7Hbbro5uQD").then (result) ->
|
46 | maid = _.find(result, (item) -> item.asset == "MAID")
|
47 | expect(maid).to.exist
|
48 | expect(maid.quantity).to.be.eq "47600.00000000"
|
49 | done()
|
50 |
|
51 | it "has a ETH balance", (done) ->
|
52 | balance("1ebacb7844fdc322f805904fbf1962802db1537c").then (result) ->
|
53 | eth = _.find(result, (item) -> item.asset == "ETH")
|
54 | expect(eth).to.exist
|
55 | expect(eth.quantity).to.be.eq "10000.00000000"
|
56 | done()
|
57 |
|
58 | it "has some Open Assets balances", (done) ->
|
59 | balance("1LUZHtvrHqaJ3jerhqQkQkcqrm9DzTaJop").then (result) ->
|
60 | debugger
|
61 | klippt = _.find(result, (item) -> item.asset == "OA/KLIPPT")
|
62 | expect(klippt).to.exist
|
63 | expect(klippt.quantity).to.be.eq "298599.00000000"
|
64 | gold = _.find(result, (item) -> item.asset == "OA/GOLD-COINS")
|
65 | expect(gold).to.exist
|
66 | expect(gold.quantity).to.be.eq "10000.00000000"
|
67 | cfs = _.find(result, (item) -> item.asset == "OA/CFS")
|
68 | expect(cfs).to.exist
|
69 | expect(cfs.quantity).to.be.eq "1.00000000"
|
70 | done()
|
71 |
|
72 | it "handles failing requests to one service correctly", (done) ->
|
73 | balance("DDAa254Jf99rLzmGe4wA3Shr7MaYBHDd1b").then (result) ->
|
74 | expect(result).to.have.length(2)
|
75 | success = _.find(result, (item) -> item.status == "success")
|
76 | expect(success).to.exist
|
77 |
|
78 | error = _.find(result, (item) -> item.status == "error")
|
79 | expect(error).to.exist
|
80 | expect(error.service).to.be.eq "https://wallet.dogeparty.io/_api"
|
81 | expect(error.message).to.be.eq "Server error. Code: -32000. Got call_jsonrpc_api request error: [Errno 111] Connection refused"
|
82 | done()
|
83 |
|
84 | it "handles counterparty testnet failure", (done) ->
|
85 | balance("13Dk4GmTdYfEjouL1x25PE5ztCMoVv6ipv").then (result) ->
|
86 | expect(result).to.have.length(2)
|
87 | error = _.find(result, (item) -> item.status == "error")
|
88 | expect(error).to.exist
|
89 | expect(error.service).to.be.eq "https://counterwallet.io/_t_api"
|
90 | expect(error.message).to.be.eq "Server error. Code: -32000. Server is not caught up. Please try again later."
|
91 | done()
|
92 |
|