Comparing version 1.8.3 to 1.8.4
# Versions | ||
## 1.8.3 | ||
## 1.8.4 | ||
@@ -5,0 +5,0 @@ - `decodeSocket`: Decode a connection socket from hex data |
@@ -13,5 +13,2 @@ { | ||
"description": "Utilities for working with bolt07 data formats", | ||
"devDependencies": { | ||
"@alexbosworth/tap": "15.0.12" | ||
}, | ||
"keywords": [ | ||
@@ -33,5 +30,5 @@ "bolt", | ||
"scripts": { | ||
"test": "tap --branches=1 --functions=1 --lines=1 --statements=1 test/addresses/*.js test/ids/*.js test/routing/*.js" | ||
"test": "npx nyc@15.1 node --experimental-test-coverage --test" | ||
}, | ||
"version": "1.8.3" | ||
"version": "1.8.4" | ||
} |
@@ -61,11 +61,9 @@ const asTokens = require('./as_tokens'); | ||
module.exports = args => { | ||
const {height, hops, mtokens} = args; | ||
const finalCltvDelta = args.cltv_delta || defaultCltvBuffer; | ||
if (height === undefined) { | ||
if (args.height === undefined) { | ||
throw new Error('ExpectedChainHeightForRoute'); | ||
} | ||
if (!isArray(hops) || !hops.length) { | ||
if (!isArray(args.hops) || !args.hops.length) { | ||
throw new Error('ExpectedHopsToConstructRouteFrom'); | ||
@@ -78,3 +76,3 @@ } | ||
if (!mtokens) { | ||
if (!args.mtokens) { | ||
throw new Error('ExpectedMillitokensToSendAcrossHops'); | ||
@@ -84,3 +82,3 @@ } | ||
// Check hops for validity | ||
hops.forEach((hop, i) => { | ||
args.hops.forEach((hop, i) => { | ||
if (hop.base_fee_mtokens === undefined) { | ||
@@ -109,8 +107,8 @@ throw new Error('ExpectedHopBaseFeeMillitokensForRouteConstruction'); | ||
let forwardMtokens = BigInt(mtokens); | ||
const [firstHop] = hops.slice(); | ||
let timeoutHeight = height + finalCltvDelta; | ||
let forwardMtokens = BigInt(args.mtokens); | ||
const [firstHop] = args.hops.slice(); | ||
let timeoutHeight = args.height + finalCltvDelta; | ||
// To construct the route, we need to go backwards from the end | ||
const backwardsPath = hops.slice().reverse().map((hop, i, hops) => { | ||
const backwardsPath = args.hops.slice().reverse().map((hop, i, hops) => { | ||
let feeMtokens = BigInt(minFee); | ||
@@ -145,5 +143,5 @@ | ||
const totalMtokens = totalFeeMtokens + BigInt(mtokens); | ||
const totalMtokens = totalFeeMtokens + BigInt(args.mtokens); | ||
if (hops.length === 1) { | ||
if (args.hops.length === 1) { | ||
timeoutHeight -= args.initial_cltv; | ||
@@ -150,0 +148,0 @@ } |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -56,3 +58,3 @@ const {decodeSocket} = require('./../../'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, strictSame, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -59,0 +61,0 @@ throws(() => decodeSocket(args), new Error(error), 'Got expected error'); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -28,3 +30,3 @@ const encodeBase32 = require('./../../addresses/encode_base32'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, strictSame, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -31,0 +33,0 @@ throws(() => encodeBase32(args), new Error(error), 'Got expected error'); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -43,3 +45,3 @@ const {encodeSocket} = require('./../../'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, strictSame, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -46,0 +48,0 @@ throws(() => encodeSocket(args), new Error(error), 'Got expected error'); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -39,3 +41,3 @@ const {chanFormat} = require('./../../'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, equal, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -49,3 +51,3 @@ throws(() => chanFormat(args), new Error(error), 'Got expected error'); | ||
equal(channel, expected.channel, 'Channel formatted returned'); | ||
strictSame(channel, expected.channel, 'Channel formatted returned'); | ||
@@ -52,0 +54,0 @@ return end(); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -39,3 +41,3 @@ const {chanNumber} = require('./../../'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, equal, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -49,3 +51,3 @@ throws(() => chanNumber(args), new Error(error), 'Got expected error'); | ||
equal(number, expected.number, 'Channel id number returned'); | ||
strictSame(number, expected.number, 'Channel id number returned'); | ||
@@ -52,0 +54,0 @@ return end(); |
@@ -1,2 +0,3 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -19,3 +20,3 @@ const componentsFromBuffer = require('./../../ids/components_from_buffer'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, equal, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -22,0 +23,0 @@ throws(() => componentsFromBuffer(args), new Error(error), 'Got error'); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -54,3 +56,3 @@ const {decodeChanId} = require('./../../'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({equal, end, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -64,5 +66,5 @@ throws(() => decodeChanId(args), new Error(error), 'Got expected err'); | ||
equal(decoded.block_height, expected.block_height, 'Block height derived'); | ||
equal(decoded.block_index, expected.block_index, 'Block index derived'); | ||
equal(decoded.output_index, expected.output_index, 'Output index derived'); | ||
strictSame(decoded.block_height, expected.block_height, 'Block height'); | ||
strictSame(decoded.block_index, expected.block_index, 'Block index'); | ||
strictSame(decoded.output_index, expected.output_index, 'Output index'); | ||
@@ -69,0 +71,0 @@ return end(); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -51,3 +53,3 @@ const {encodeChanId} = require('./../../'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({equal, end, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -61,5 +63,5 @@ throws(() => encodeChanId(args), new Error(error), 'Got expected err'); | ||
equal(encoded.channel, expected.channel, 'Channel components returned'); | ||
equal(encoded.id, expected.id, 'Channel id returned'); | ||
equal(encoded.number, expected.number, 'Channel number returned'); | ||
strictSame(encoded.channel, expected.channel, 'Channel components'); | ||
strictSame(encoded.id, expected.id, 'Channel id returned'); | ||
strictSame(encoded.number, expected.number, 'Channel number returned'); | ||
@@ -66,0 +68,0 @@ return end(); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -39,3 +41,3 @@ const {rawChanId} = require('./../../'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, equal, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -49,3 +51,3 @@ throws(() => rawChanId(args), new Error(error), 'Got expected error'); | ||
equal(id, expected.id, 'Raw channel id returned'); | ||
strictSame(id, expected.id, 'Raw channel id returned'); | ||
@@ -52,0 +54,0 @@ return end(); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -277,3 +279,3 @@ const betaChannels = require('./../fixtures/graph_beta').channels; | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, strictSame, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -280,0 +282,0 @@ throws(() => hopsFromChannels(args), new Error(error), 'Got error'); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -34,7 +36,7 @@ const policyFee = require('./../../routing/policy_fee'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, equal, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
throws(() => policyFee(args), new Error(error), 'Got expected error'); | ||
} else { | ||
equal(policyFee(args).fee_mtokens, expected.fee_mtokens, 'Got fee'); | ||
strictSame(policyFee(args).fee_mtokens, expected.fee_mtokens, 'Fee'); | ||
} | ||
@@ -41,0 +43,0 @@ |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -941,3 +943,3 @@ const {routeFromChannels} = require('./../../'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, strictSame, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -944,0 +946,0 @@ throws(() => routeFromChannels(args), new Error(error), 'Got error'); |
@@ -1,2 +0,4 @@ | ||
const {test} = require('@alexbosworth/tap'); | ||
const strictSame = require('node:assert').strict.deepStrictEqual; | ||
const test = require('node:test'); | ||
const {throws} = require('node:assert').strict; | ||
@@ -343,3 +345,3 @@ const {routeFromHops} = require('./../../'); | ||
tests.forEach(({args, description, error, expected}) => { | ||
return test(description, ({end, strictSame, throws}) => { | ||
return test(description, (t, end) => { | ||
if (!!error) { | ||
@@ -346,0 +348,0 @@ throws(() => routeFromHops(args), new Error(error), 'Got expected err'); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98303
0
3034