ln-accounting 10.0.7 → 10.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Versions
2
2
 
3
- ## Version 10.0.7
3
+ ## Version 10.0.8
4
4
 
5
5
  ### Breaking Changes
6
6
 
package/package.json CHANGED
@@ -4,19 +4,19 @@
4
4
  },
5
5
  "author": {
6
6
  "name": "Alex Bosworth",
7
- "url": "https://twitter.com/alexbosworth"
7
+ "url": "https://x.com/alexbosworth"
8
8
  },
9
9
  "bugs": {
10
10
  "url": "https://github.com/alexbosworth/ln-accounting/issues"
11
11
  },
12
12
  "dependencies": {
13
- "@alexbosworth/blockchain": "4.8.0",
14
- "@alexbosworth/formulas": "1.4.0",
13
+ "@alexbosworth/blockchain": "4.10.0",
14
+ "@alexbosworth/formulas": "1.5.0",
15
15
  "@json2csv/plainjs": "7.0.8",
16
16
  "async": "3.2.6",
17
17
  "asyncjs-util": "1.2.12",
18
- "goldengate": "16.0.7",
19
- "ln-service": "59.5.0"
18
+ "goldengate": "16.0.8",
19
+ "ln-service": "60.1.2"
20
20
  },
21
21
  "description": "lnd accounting reports",
22
22
  "engines": {
@@ -36,5 +36,5 @@
36
36
  "scripts": {
37
37
  "test": "node --experimental-test-coverage --test"
38
38
  },
39
- "version": "10.0.7"
39
+ "version": "10.0.8"
40
40
  }
@@ -1,4 +1,5 @@
1
1
  const {deepEqual} = require('node:assert').strict;
2
+ const {fail} = require('node:assert').strict;
2
3
  const {rejects} = require('node:assert').strict;
3
4
  const test = require('node:test');
4
5
 
@@ -28,6 +29,11 @@ const tests = [
28
29
  description: 'A currency is required',
29
30
  error: [400, 'UnsupportedCurrencyForCoingeckoFiatRateLookup'],
30
31
  },
32
+ {
33
+ args: makeArgs({currency: 'ETH'}),
34
+ description: 'Only BTC is supported as a currency',
35
+ error: [400, 'UnsupportedCurrencyForCoingeckoFiatRateLookup'],
36
+ },
31
37
  {
32
38
  args: makeArgs({date: undefined}),
33
39
  description: 'A date is required',
@@ -38,6 +44,11 @@ const tests = [
38
44
  description: 'A fiat type is required',
39
45
  error: [400, 'UnsupportedFiatTypeForCoingeckoFiatRateLookup'],
40
46
  },
47
+ {
48
+ args: makeArgs({fiat: 'EUR'}),
49
+ description: 'Only USD is supported as a fiat type',
50
+ error: [400, 'UnsupportedFiatTypeForCoingeckoFiatRateLookup'],
51
+ },
41
52
  {
42
53
  args: makeArgs({rates: undefined}),
43
54
  description: 'A rates object is required',
@@ -58,6 +69,16 @@ const tests = [
58
69
  description: 'A body is expected in response',
59
70
  error: [503, 'UnexpectedResponseInCoingeckoPastRateResponse'],
60
71
  },
72
+ {
73
+ args: makeArgs({request: ({}, cbk) => cbk(null, null, {})}),
74
+ description: 'Market data is expected in response',
75
+ error: [503, 'UnexpectedResponseInCoingeckoPastRateResponse'],
76
+ },
77
+ {
78
+ args: makeArgs({request: ({}, cbk) => cbk(null, null, {market_data: {}})}),
79
+ description: 'A current price is expected in market data',
80
+ error: [503, 'UnexpectedResponseInCoingeckoPastRateResponse'],
81
+ },
61
82
  {
62
83
  args: makeArgs({
63
84
  request: ({}, cbk) => cbk(null, null, {
@@ -72,6 +93,48 @@ const tests = [
72
93
  description: 'Get coingecko historic rate',
73
94
  expected: {cents: 1234},
74
95
  },
96
+ {
97
+ args: makeArgs({
98
+ date: '2020-01-02T03:04:05.000Z',
99
+ rates: {'2020-01-02T12:00:00.000Z': 5678},
100
+ request: ({}, cbk) => fail('Expected cached rate to be used'),
101
+ }),
102
+ description: 'A known rate for the same day is used instead of a request',
103
+ expected: {cents: 5678},
104
+ },
105
+ {
106
+ args: makeArgs({
107
+ date: '2020-01-02T03:04:05.000Z',
108
+ rates: {'2020-01-01T03:04:05.000Z': 5678},
109
+ }),
110
+ description: 'A known rate for a different day is not used',
111
+ expected: {cents: 1234},
112
+ },
113
+ {
114
+ args: makeArgs({
115
+ date: '2020-01-02T03:04:05.000Z',
116
+ rates: {'2020-01-02T03:04:05.000Z': 0},
117
+ }),
118
+ description: 'A falsy known rate falls back to a request',
119
+ expected: {cents: 1234},
120
+ },
121
+ {
122
+ args: makeArgs({
123
+ date: '2020-01-02T03:04:05.000Z',
124
+ request: (args, cbk) => {
125
+ deepEqual(args, {
126
+ json: true,
127
+ qs: {date: '02-01-2020', localization: false},
128
+ timeout: 30000,
129
+ url: 'https://api.coingecko.com/api/v3/coins/bitcoin/history',
130
+ });
131
+
132
+ return api(args, cbk);
133
+ },
134
+ }),
135
+ description: 'Request is made with the expected arguments',
136
+ expected: {cents: 1234},
137
+ },
75
138
  ];
76
139
 
77
140
  tests.forEach(({args, description, error, expected}) => {