ln-accounting 10.0.8 → 10.0.9
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 +4 -1
- package/esplora/get_esplora_vout.js +0 -1
- package/package.json +21 -6
- package/report/get_accounting_report.js +4 -1
- package/.gitattributes +0 -1
- package/.tm_properties +0 -1
- package/.travis.yml +0 -15
- package/blockstream/get_blockstream_tx.js +0 -94
- package/blockstream/get_blockstream_vout.js +0 -80
- package/blockstream/index.js +0 -4
- package/test/blockstream/test_get_blockstream_tx.js +0 -111
- package/test/fiat/test_get_coincap_historic_rate.js +0 -86
- package/test/fiat/test_get_coindesk_historic_rate.js +0 -80
- package/test/fiat/test_get_coingecko_historic_rate.js +0 -152
- package/test/fiat/test_get_fiat_values.js +0 -74
- package/test/fiat/test_get_historic_rate.js +0 -77
- package/test/harmony/test_categorize_records.js +0 -156
- package/test/harmony/test_chain_fees_as_records.js +0 -40
- package/test/harmony/test_chain_receives_as_records.js +0 -73
- package/test/harmony/test_chain_sends_as_records.js +0 -55
- package/test/harmony/test_formatted_notes.js +0 -32
- package/test/harmony/test_forwards_as_records.js +0 -52
- package/test/harmony/test_harmonize.js +0 -24
- package/test/harmony/test_invoices_as_records.js +0 -77
- package/test/harmony/test_notes_for_chain_transaction.js +0 -43
- package/test/harmony/test_payments_as_records.js +0 -159
- package/test/harmony/test_records_with_fiat.js +0 -112
- package/test/records/test_get_all_invoices.js +0 -105
- package/test/records/test_get_all_payments.js +0 -274
- package/test/report/test_parse_amount.js +0 -57
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
const {deepEqual} = require('node:assert').strict;
|
|
2
|
-
const {fail} = require('node:assert').strict;
|
|
3
|
-
const {rejects} = require('node:assert').strict;
|
|
4
|
-
const test = require('node:test');
|
|
5
|
-
|
|
6
|
-
const method = require('./../../fiat/get_coingecko_historic_rate');
|
|
7
|
-
|
|
8
|
-
const makeArgs = overrides => {
|
|
9
|
-
const args = {
|
|
10
|
-
date: new Date().toISOString(),
|
|
11
|
-
currency: 'BTC',
|
|
12
|
-
fiat: 'USD',
|
|
13
|
-
rates: {},
|
|
14
|
-
request: ({qs}, cbk) => api({qs}, cbk),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
Object.keys(overrides).forEach(k => args[k] = overrides[k]);
|
|
18
|
-
|
|
19
|
-
return args;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const api = ({qs}, cbk) => {
|
|
23
|
-
return cbk(null, null, {market_data: {current_price: {usd: 12.34}}});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const tests = [
|
|
27
|
-
{
|
|
28
|
-
args: makeArgs({currency: undefined}),
|
|
29
|
-
description: 'A currency is required',
|
|
30
|
-
error: [400, 'UnsupportedCurrencyForCoingeckoFiatRateLookup'],
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
args: makeArgs({currency: 'ETH'}),
|
|
34
|
-
description: 'Only BTC is supported as a currency',
|
|
35
|
-
error: [400, 'UnsupportedCurrencyForCoingeckoFiatRateLookup'],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
args: makeArgs({date: undefined}),
|
|
39
|
-
description: 'A date is required',
|
|
40
|
-
error: [400, 'ExpectedDateForCoingeckoRateLookup'],
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
args: makeArgs({fiat: undefined}),
|
|
44
|
-
description: 'A fiat type is required',
|
|
45
|
-
error: [400, 'UnsupportedFiatTypeForCoingeckoFiatRateLookup'],
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
args: makeArgs({fiat: 'EUR'}),
|
|
49
|
-
description: 'Only USD is supported as a fiat type',
|
|
50
|
-
error: [400, 'UnsupportedFiatTypeForCoingeckoFiatRateLookup'],
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
args: makeArgs({rates: undefined}),
|
|
54
|
-
description: 'A rates object is required',
|
|
55
|
-
error: [400, 'ExpectedKnownRatesForCoingeckoFiatRateLookup'],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
args: makeArgs({request: undefined}),
|
|
59
|
-
description: 'A request method is required',
|
|
60
|
-
error: [400, 'ExpectedRequestMethodForCoingeckoFiatRateLookup'],
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
args: makeArgs({request: ({}, cbk) => cbk('err')}),
|
|
64
|
-
description: 'Errors returned from request',
|
|
65
|
-
error: [503, 'UnexpectedErrGettingCoingeckoPastRate', {err: 'err'}],
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
args: makeArgs({request: ({}, cbk) => cbk()}),
|
|
69
|
-
description: 'A body is expected in response',
|
|
70
|
-
error: [503, 'UnexpectedResponseInCoingeckoPastRateResponse'],
|
|
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
|
-
},
|
|
82
|
-
{
|
|
83
|
-
args: makeArgs({
|
|
84
|
-
request: ({}, cbk) => cbk(null, null, {
|
|
85
|
-
market_data: {current_price: {}},
|
|
86
|
-
}),
|
|
87
|
-
}),
|
|
88
|
-
description: 'A price is expected in response',
|
|
89
|
-
error: [503, 'ExpectedCoingeckoCurrentPriceForFiat'],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
args: makeArgs({}),
|
|
93
|
-
description: 'Get coingecko historic rate',
|
|
94
|
-
expected: {cents: 1234},
|
|
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
|
-
},
|
|
138
|
-
];
|
|
139
|
-
|
|
140
|
-
tests.forEach(({args, description, error, expected}) => {
|
|
141
|
-
return test(description, async () => {
|
|
142
|
-
if (!!error) {
|
|
143
|
-
await rejects(method(args), error, 'Got expected error');
|
|
144
|
-
} else {
|
|
145
|
-
const res = await method(args);
|
|
146
|
-
|
|
147
|
-
deepEqual(res, expected, 'Got expected return value');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return;
|
|
151
|
-
});
|
|
152
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
const {deepEqual} = require('node:assert').strict;
|
|
2
|
-
const {rejects} = require('node:assert').strict;
|
|
3
|
-
const test = require('node:test');
|
|
4
|
-
|
|
5
|
-
const {getFiatValues} = require('./../../fiat/');
|
|
6
|
-
|
|
7
|
-
const date = new Date().toISOString();
|
|
8
|
-
|
|
9
|
-
const tests = [
|
|
10
|
-
{
|
|
11
|
-
args: {},
|
|
12
|
-
description: 'Currency code is required',
|
|
13
|
-
error: [400, 'ExpectedCurrencyToGetFiatValues'],
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
args: {currency: 'BTC'},
|
|
17
|
-
description: 'Dates are required',
|
|
18
|
-
error: [400, 'ExpectedDatesToGetFiatValues'],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
args: {currency: 'BTC', dates: [date]},
|
|
22
|
-
description: 'Fiat type is required',
|
|
23
|
-
error: [400, 'ExpectedFiatTypeToGetFiatValues'],
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
args: {currency: 'BTC', dates: [date], fiat: 'USD'},
|
|
27
|
-
description: 'Rate method or request function is required',
|
|
28
|
-
error: [400, 'ExpectedRateMethodOrRequestMethodToGetFiat'],
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
args: {
|
|
32
|
-
currency: 'BTC',
|
|
33
|
-
dates: [date],
|
|
34
|
-
fiat: 'USD',
|
|
35
|
-
rate: ({}, cbk) => cbk(['err']),
|
|
36
|
-
},
|
|
37
|
-
description: 'Rate method errors are passed back',
|
|
38
|
-
error: ['err'],
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
args: {
|
|
42
|
-
currency: 'BTC',
|
|
43
|
-
dates: [date],
|
|
44
|
-
fiat: 'USD',
|
|
45
|
-
rate: ({}, cbk) => cbk(null, {cents: 123456}),
|
|
46
|
-
},
|
|
47
|
-
description: 'Get historic fiat rates',
|
|
48
|
-
expected: {rates: [{date, cents: 123456}]},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
args: {
|
|
52
|
-
currency: 'BTC',
|
|
53
|
-
dates: [date, date],
|
|
54
|
-
fiat: 'USD',
|
|
55
|
-
rate: ({}, cbk) => cbk(null, {cents: 123456}),
|
|
56
|
-
},
|
|
57
|
-
description: 'Get historic fiat rates when the rate is already got',
|
|
58
|
-
expected: {rates: [{date, cents: 123456}, {date, cents: 123456}]},
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
tests.forEach(({args, description, error, expected}) => {
|
|
63
|
-
return test(description, async () => {
|
|
64
|
-
if (!!error) {
|
|
65
|
-
await rejects(getFiatValues(args), error, 'Got expected error');
|
|
66
|
-
} else {
|
|
67
|
-
const {rates} = await getFiatValues(args);
|
|
68
|
-
|
|
69
|
-
deepEqual(rates, expected.rates, 'Rates returned');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return;
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
const {equal} = require('node:assert').strict;
|
|
2
|
-
const {rejects} = require('node:assert').strict;
|
|
3
|
-
const test = require('node:test');
|
|
4
|
-
|
|
5
|
-
const getHistoricRate = require('./../../fiat/get_historic_rate');
|
|
6
|
-
|
|
7
|
-
const date = new Date().toISOString();
|
|
8
|
-
|
|
9
|
-
const api = ({}, cbk) => {
|
|
10
|
-
return cbk(null, null, {market_data: {current_price: {usd: 12.34}}});
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const makeArgs = overrides => {
|
|
14
|
-
const args = {
|
|
15
|
-
date: new Date().toISOString(),
|
|
16
|
-
currency: 'BTC',
|
|
17
|
-
fiat: 'USD',
|
|
18
|
-
rates: {},
|
|
19
|
-
request: ({qs}, cbk) => api({qs}, cbk),
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
Object.keys(overrides).forEach(k => args[k] = overrides[k]);
|
|
23
|
-
|
|
24
|
-
return args;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const tests = [
|
|
28
|
-
{
|
|
29
|
-
args: makeArgs({currency: undefined}),
|
|
30
|
-
description: 'A currency code is required',
|
|
31
|
-
error: [400, 'ExpectedCurrencyToGetHistoricRate'],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
args: makeArgs({date: undefined}),
|
|
35
|
-
description: 'A date is required',
|
|
36
|
-
error: [400, 'ExpectedDateToGetHistoricRate'],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
args: makeArgs({fiat: undefined}),
|
|
40
|
-
description: 'A fiat type is required to get historic rate',
|
|
41
|
-
error: [400, 'ExpectedFiatToGetHistoricRate'],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
args: makeArgs({rates: undefined}),
|
|
45
|
-
description: 'Past rates are required to get historic rate',
|
|
46
|
-
error: [400, 'ExpectedRatesToGetHistoricRate'],
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
args: makeArgs({request: undefined}),
|
|
50
|
-
description: 'A request function is required to get historic rate',
|
|
51
|
-
error: [400, 'ExpectedRequestFunctionToGetHistoricRate'],
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
args: makeArgs({provider: 'provider'}),
|
|
55
|
-
description: 'A known rate provider is required to get historic rate',
|
|
56
|
-
error: [400, 'ExpectedKnownRateProviderToGetHistoricRate'],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
args: makeArgs({}),
|
|
60
|
-
description: 'Get historic fiat rates',
|
|
61
|
-
expected: {cents: 1234},
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
tests.forEach(({args, description, error, expected}) => {
|
|
66
|
-
return test(description, async () => {
|
|
67
|
-
if (!!error) {
|
|
68
|
-
await rejects(getHistoricRate(args), error, 'Gote expected error');
|
|
69
|
-
} else {
|
|
70
|
-
const {cents} = await getHistoricRate(args);
|
|
71
|
-
|
|
72
|
-
equal(cents, expected.cents, 'Rate returned');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return;
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
const {deepEqual} = require('node:assert').strict;
|
|
2
|
-
const {equal} = require('node:assert').strict;
|
|
3
|
-
const test = require('node:test');
|
|
4
|
-
const {throws} = require('node:assert').strict;
|
|
5
|
-
|
|
6
|
-
const {categorizeRecords} = require('./../../harmony');
|
|
7
|
-
|
|
8
|
-
const tests = [
|
|
9
|
-
{
|
|
10
|
-
args: {
|
|
11
|
-
records: [
|
|
12
|
-
{
|
|
13
|
-
amount: 1,
|
|
14
|
-
asset: 'BTC',
|
|
15
|
-
category: 'payments',
|
|
16
|
-
created_at: '2019-07-19T03:31:39.916Z',
|
|
17
|
-
external_id: 'external_id',
|
|
18
|
-
from_id: 'from_id',
|
|
19
|
-
id: 'id',
|
|
20
|
-
notes: 'notes',
|
|
21
|
-
to_id: 'to_id',
|
|
22
|
-
type: 'spend',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
amount: 1,
|
|
26
|
-
asset: 'BTC',
|
|
27
|
-
category: 'payments',
|
|
28
|
-
created_at: '2019-07-20T03:31:39.916Z',
|
|
29
|
-
external_id: 'external_id',
|
|
30
|
-
from_id: 'from_id',
|
|
31
|
-
id: 'id',
|
|
32
|
-
notes: 'notes',
|
|
33
|
-
to_id: 'to_id',
|
|
34
|
-
type: 'spend',
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
description: 'Categorize records',
|
|
39
|
-
expected: {
|
|
40
|
-
payments: [
|
|
41
|
-
{
|
|
42
|
-
amount: 1,
|
|
43
|
-
asset: 'BTC',
|
|
44
|
-
category: 'payments',
|
|
45
|
-
created_at: '2019-07-19T03:31:39.916Z',
|
|
46
|
-
external_id: 'external_id',
|
|
47
|
-
from_id: 'from_id',
|
|
48
|
-
id: 'id',
|
|
49
|
-
notes: 'notes',
|
|
50
|
-
to_id: 'to_id',
|
|
51
|
-
type: 'spend',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
amount: 1,
|
|
55
|
-
asset: 'BTC',
|
|
56
|
-
category: 'payments',
|
|
57
|
-
created_at: '2019-07-20T03:31:39.916Z',
|
|
58
|
-
external_id: 'external_id',
|
|
59
|
-
from_id: 'from_id',
|
|
60
|
-
id: 'id',
|
|
61
|
-
notes: 'notes',
|
|
62
|
-
to_id: 'to_id',
|
|
63
|
-
type: 'spend',
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
payments_csv: [
|
|
67
|
-
'"Amount","Asset","Date & Time","Fiat Amount","From ID","Network ID","Notes","To ID","Transaction ID","Type"',
|
|
68
|
-
'1,"BTC","2019-07-19T03:31:39.916Z",,"from_id","external_id","notes","to_id","id","spend"',
|
|
69
|
-
'1,"BTC","2019-07-20T03:31:39.916Z",,"from_id","external_id","notes","to_id","id","spend"',
|
|
70
|
-
].join('\n'),
|
|
71
|
-
},
|
|
72
|
-
}, {
|
|
73
|
-
args: {
|
|
74
|
-
records: [
|
|
75
|
-
{
|
|
76
|
-
amount: 1,
|
|
77
|
-
asset: 'BTC',
|
|
78
|
-
category: 'payments',
|
|
79
|
-
created_at: '2019-07-21T03:31:39.916Z',
|
|
80
|
-
external_id: 'external_id',
|
|
81
|
-
from_id: 'from_id',
|
|
82
|
-
id: 'id',
|
|
83
|
-
notes: 'notes',
|
|
84
|
-
to_id: 'to_id',
|
|
85
|
-
type: 'spend',
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
amount: 1,
|
|
89
|
-
asset: 'BTC',
|
|
90
|
-
category: 'payments',
|
|
91
|
-
created_at: '2019-07-20T03:31:39.916Z',
|
|
92
|
-
external_id: 'external_id',
|
|
93
|
-
from_id: 'from_id',
|
|
94
|
-
id: 'id',
|
|
95
|
-
notes: 'notes',
|
|
96
|
-
to_id: 'to_id',
|
|
97
|
-
type: 'spend',
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
description: 'Categorize records out of order',
|
|
102
|
-
expected: {
|
|
103
|
-
payments: [
|
|
104
|
-
{
|
|
105
|
-
amount: 1,
|
|
106
|
-
asset: 'BTC',
|
|
107
|
-
category: 'payments',
|
|
108
|
-
created_at: '2019-07-20T03:31:39.916Z',
|
|
109
|
-
external_id: 'external_id',
|
|
110
|
-
from_id: 'from_id',
|
|
111
|
-
id: 'id',
|
|
112
|
-
notes: 'notes',
|
|
113
|
-
to_id: 'to_id',
|
|
114
|
-
type: 'spend',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
amount: 1,
|
|
118
|
-
asset: 'BTC',
|
|
119
|
-
category: 'payments',
|
|
120
|
-
created_at: '2019-07-21T03:31:39.916Z',
|
|
121
|
-
external_id: 'external_id',
|
|
122
|
-
from_id: 'from_id',
|
|
123
|
-
id: 'id',
|
|
124
|
-
notes: 'notes',
|
|
125
|
-
to_id: 'to_id',
|
|
126
|
-
type: 'spend',
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
payments_csv: [
|
|
130
|
-
'"Amount","Asset","Date & Time","Fiat Amount","From ID","Network ID","Notes","To ID","Transaction ID","Type"',
|
|
131
|
-
'1,"BTC","2019-07-20T03:31:39.916Z",,"from_id","external_id","notes","to_id","id","spend"',
|
|
132
|
-
'1,"BTC","2019-07-21T03:31:39.916Z",,"from_id","external_id","notes","to_id","id","spend"',
|
|
133
|
-
].join('\n'),
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
args: {},
|
|
138
|
-
description: 'Records are required',
|
|
139
|
-
error: 'ExpectedRecordsArrayToCategorize',
|
|
140
|
-
},
|
|
141
|
-
];
|
|
142
|
-
|
|
143
|
-
tests.forEach(({args, description, error, expected}) => {
|
|
144
|
-
return test(description, (t, end) => {
|
|
145
|
-
if (!!error) {
|
|
146
|
-
throws(() => categorizeRecords(args), new Error(error), 'Got error');
|
|
147
|
-
} else {
|
|
148
|
-
const categorized = categorizeRecords(args);
|
|
149
|
-
|
|
150
|
-
deepEqual(categorized.payments, expected.payments, 'Categorized');
|
|
151
|
-
equal(categorized.payments_csv, expected.payments_csv, 'Categorize csv');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return end();
|
|
155
|
-
});
|
|
156
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const {deepEqual} = require('node:assert').strict;
|
|
2
|
-
const test = require('node:test');
|
|
3
|
-
|
|
4
|
-
const {chainFeesAsRecords} = require('./../../harmony');
|
|
5
|
-
|
|
6
|
-
const date = new Date().toISOString();
|
|
7
|
-
|
|
8
|
-
const tests = [
|
|
9
|
-
{
|
|
10
|
-
args: {
|
|
11
|
-
transactions: [{
|
|
12
|
-
created_at: date,
|
|
13
|
-
fee: 1,
|
|
14
|
-
id: 'id',
|
|
15
|
-
is_outgoing: true,
|
|
16
|
-
}]
|
|
17
|
-
},
|
|
18
|
-
description: 'Chain fees as records',
|
|
19
|
-
expected: {
|
|
20
|
-
records: [{
|
|
21
|
-
amount: -1,
|
|
22
|
-
category: 'chain_fees',
|
|
23
|
-
created_at: date,
|
|
24
|
-
id: 'id:fee',
|
|
25
|
-
notes: '[Chain Fee]',
|
|
26
|
-
type: 'fee:network',
|
|
27
|
-
}],
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
tests.forEach(({args, description, expected}) => {
|
|
33
|
-
return test(description, (t, end) => {
|
|
34
|
-
const {records} = chainFeesAsRecords(args);
|
|
35
|
-
|
|
36
|
-
deepEqual(records, expected.records, 'Fees formatted as records');
|
|
37
|
-
|
|
38
|
-
return end();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const {deepEqual} = require('node:assert').strict;
|
|
2
|
-
const test = require('node:test');
|
|
3
|
-
const {throws} = require('node:assert').strict;
|
|
4
|
-
|
|
5
|
-
const {chainReceivesAsRecords} = require('./../../harmony');
|
|
6
|
-
|
|
7
|
-
const date = new Date().toISOString();
|
|
8
|
-
|
|
9
|
-
const tests = [
|
|
10
|
-
{
|
|
11
|
-
args: {
|
|
12
|
-
channel_transaction_ids: ['funding_tx'],
|
|
13
|
-
transactions: [
|
|
14
|
-
{
|
|
15
|
-
created_at: new Date().toISOString(),
|
|
16
|
-
id: 'funding_tx',
|
|
17
|
-
is_confirmed: true,
|
|
18
|
-
is_outgoing: true,
|
|
19
|
-
output_addresses: ['out_address'],
|
|
20
|
-
tokens: 1,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
created_at: date,
|
|
24
|
-
id: 'id',
|
|
25
|
-
is_confirmed: true,
|
|
26
|
-
is_outgoing: false,
|
|
27
|
-
output_addresses: ['address'],
|
|
28
|
-
tokens: 1,
|
|
29
|
-
},
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
description: 'Chain receives as records',
|
|
33
|
-
expected: {
|
|
34
|
-
records: [{
|
|
35
|
-
amount: 1,
|
|
36
|
-
category: 'chain_receives',
|
|
37
|
-
created_at: date,
|
|
38
|
-
id: 'id',
|
|
39
|
-
notes: 'Outputs to address',
|
|
40
|
-
type: 'transfer:deposit',
|
|
41
|
-
}],
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
args: null,
|
|
46
|
-
description: 'Arguments expected',
|
|
47
|
-
error: 'ExpectedArgumentsToMapReceiveRecords',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
args: {},
|
|
51
|
-
description: 'Channel transaction ids array expected',
|
|
52
|
-
error: 'ExpectedChannelTransactionIdsArrayToMapReceiveRecords',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
args: {channel_transaction_ids: []},
|
|
56
|
-
description: 'Transaction info array expected',
|
|
57
|
-
error: 'ExpectedTransactionsArrayToMapToReceiveRecords',
|
|
58
|
-
},
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
tests.forEach(({args, description, error, expected}) => {
|
|
62
|
-
return test(description, (t, end) => {
|
|
63
|
-
if (!!error) {
|
|
64
|
-
throws(() => chainReceivesAsRecords(args), new Error(error), 'Got err');
|
|
65
|
-
} else {
|
|
66
|
-
const {records} = chainReceivesAsRecords(args);
|
|
67
|
-
|
|
68
|
-
deepEqual(records, expected.records, 'Fees formatted as records');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return end();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const {deepEqual} = require('node:assert').strict;
|
|
2
|
-
const test = require('node:test');
|
|
3
|
-
|
|
4
|
-
const {chainSendsAsRecords} = require('./../../harmony');
|
|
5
|
-
|
|
6
|
-
const date = new Date().toISOString();
|
|
7
|
-
|
|
8
|
-
const tests = [
|
|
9
|
-
{
|
|
10
|
-
args: {
|
|
11
|
-
channel_transaction_ids: ['funding_tx'],
|
|
12
|
-
transactions: [
|
|
13
|
-
{
|
|
14
|
-
created_at: new Date().toISOString(),
|
|
15
|
-
fee: 1,
|
|
16
|
-
id: 'funding_tx',
|
|
17
|
-
is_confirmed: true,
|
|
18
|
-
is_outgoing: true,
|
|
19
|
-
output_addresses: ['out_address'],
|
|
20
|
-
tokens: 2,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
created_at: date,
|
|
24
|
-
fee: 1,
|
|
25
|
-
id: 'id',
|
|
26
|
-
is_confirmed: true,
|
|
27
|
-
is_outgoing: true,
|
|
28
|
-
output_addresses: ['address'],
|
|
29
|
-
tokens: 2,
|
|
30
|
-
},
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
description: 'Chain sends as records',
|
|
34
|
-
expected: {
|
|
35
|
-
records: [{
|
|
36
|
-
amount: -1,
|
|
37
|
-
category: 'chain_sends',
|
|
38
|
-
created_at: date,
|
|
39
|
-
id: 'id',
|
|
40
|
-
notes: 'Outputs to address',
|
|
41
|
-
type: 'transfer:withdraw',
|
|
42
|
-
}],
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
tests.forEach(({args, description, expected}) => {
|
|
48
|
-
return test(description, (t, end) => {
|
|
49
|
-
const {records} = chainSendsAsRecords(args);
|
|
50
|
-
|
|
51
|
-
deepEqual(records, expected.records, 'Fees formatted as records');
|
|
52
|
-
|
|
53
|
-
return end();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const {equal} = require('node:assert').strict;
|
|
2
|
-
const test = require('node:test');
|
|
3
|
-
const {throws} = require('node:assert').strict;
|
|
4
|
-
|
|
5
|
-
const formattedNotes = require('./../../harmony/formatted_notes');
|
|
6
|
-
|
|
7
|
-
const tests = [
|
|
8
|
-
{
|
|
9
|
-
args: {notes: 'notes'},
|
|
10
|
-
description: 'Notes formatted',
|
|
11
|
-
expected: {notes: 'notes'},
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
args: {notes: ''},
|
|
15
|
-
description: 'Empty notes formatted',
|
|
16
|
-
expected: {notes: ''},
|
|
17
|
-
},
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
tests.forEach(({args, description, error, expected}) => {
|
|
21
|
-
return test(description, (t, end) => {
|
|
22
|
-
if (!!error) {
|
|
23
|
-
throws(() => formattedNotes(args), new Error(error), 'Got error');
|
|
24
|
-
} else {
|
|
25
|
-
const {notes} = formattedNotes(args);
|
|
26
|
-
|
|
27
|
-
equal(notes, expected.notes, 'Got formatted notes');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return end();
|
|
31
|
-
});
|
|
32
|
-
});
|