ln-sync
Version:
LN metadata persistence methods
69 lines (63 loc) • 1.49 kB
JavaScript
const {deepEqual} = require('node:assert').strict;
const test = require('node:test');
const {throws} = require('node:assert').strict;
const peerLiquidity = require('./../../peers/peer_liquidity');
const tests = [
{
args: {
channels: [{
local_balance: 1,
pending_payments: [
{
id: 'id',
is_outgoing: true,
tokens: 1,
},
{
id: 'id',
is_outgoing: false,
tokens: 1,
},
{
id: 'id3',
is_outgoing: true,
tokens: 1,
},
{
id: 'id2',
is_outgoing: false,
tokens: 2,
},
],
remote_balance: 1,
}],
opening: [{
local_balance: 1,
remote_balance: 1,
}],
settled: 'id',
},
description: 'Channels are mapped to liquidity balances',
expected: {
liquidity: {
inbound: 2,
inbound_opening: 1,
inbound_pending: 1,
outbound: 2,
outbound_opening: 1,
outbound_pending: 2,
},
},
},
];
tests.forEach(({args, description, error, expected}) => {
return test(description, (t, end) => {
if (!!error) {
throws(() => peerLiquidity(args), new Error(error));
} else {
const liquidity = peerLiquidity(args);
deepEqual(liquidity, expected.liquidity, 'Got expected liquidity');
}
return end();
});
});