bolt07 1.8.2 → 1.8.3

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
- ## 1.8.2
3
+ ## 1.8.3
4
4
 
5
5
  - `decodeSocket`: Decode a connection socket from hex data
6
6
  - `encodeSocket`: Encode a connection socket to hex data
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "description": "Utilities for working with bolt07 data formats",
13
13
  "devDependencies": {
14
- "@alexbosworth/tap": "15.0.11"
14
+ "@alexbosworth/tap": "15.0.12"
15
15
  },
16
16
  "keywords": [
17
17
  "bolt",
@@ -31,5 +31,5 @@
31
31
  "scripts": {
32
32
  "test": "tap --branches=1 --functions=1 --lines=1 --statements=1 test/addresses/*.js test/ids/*.js test/routing/*.js"
33
33
  },
34
- "version": "1.8.2"
34
+ "version": "1.8.3"
35
35
  }
@@ -0,0 +1,39 @@
1
+ const {test} = require('@alexbosworth/tap');
2
+
3
+ const encodeBase32 = require('./../../addresses/encode_base32');
4
+
5
+ const tests = [
6
+ {
7
+ args: {data: ''},
8
+ description: 'Encode nil data as base32',
9
+ expected: {base32: ''},
10
+ },
11
+ {
12
+ args: {data: '73'},
13
+ description: 'Encode short data as base32',
14
+ expected: {base32: 'om'},
15
+ },
16
+ {
17
+ args: {
18
+ data: 'f2fc2319bd29457ccd01e8e194ee9bd7e97298b6610df4ab0f3d5baa0b2d7ccf69829edb74edef',
19
+ },
20
+ description: 'Encode long data as base32',
21
+ expected: {
22
+ base32: '6l6cggn5ffcxztib5dqzj3u327uxfgfwmeg7jkyphvn2ucznpthwtau63n2o33y',
23
+ },
24
+ },
25
+ ];
26
+
27
+ tests.forEach(({args, description, error, expected}) => {
28
+ return test(description, ({end, strictSame, throws}) => {
29
+ if (!!error) {
30
+ throws(() => encodeBase32(args), new Error(error), 'Got expected error');
31
+ } else {
32
+ const res = encodeBase32(args);
33
+
34
+ strictSame(res, expected, 'Got expected result');
35
+ }
36
+
37
+ return end();
38
+ });
39
+ });
@@ -23,6 +23,11 @@ const tests = [
23
23
  description: 'Standard bitcoin channel',
24
24
  expected: {channel: '537136x2080x1'},
25
25
  },
26
+ {
27
+ args: {number: '17592186044416000010'},
28
+ description: 'SCID alias type id',
29
+ expected: {channel: '16000000x0x10'},
30
+ },
26
31
  {
27
32
  args: {},
28
33
  description: 'An id or number is required',
@@ -23,6 +23,11 @@ const tests = [
23
23
  description: 'Standard bitcoin channel',
24
24
  expected: {number: '590587277833404417'},
25
25
  },
26
+ {
27
+ args: {channel: '16000000x0x10'},
28
+ description: 'SCID alias channel id',
29
+ expected: {number: '17592186044416000010'},
30
+ },
26
31
  {
27
32
  args: {},
28
33
  description: 'Channel or id is required',
@@ -33,6 +33,11 @@ const tests = [
33
33
  description: 'Standard bitcoin channel id',
34
34
  expected: {block_height: 537136, block_index: 2080, output_index: 1},
35
35
  },
36
+ {
37
+ args: {number: '17592186044416000010'},
38
+ description: 'SCID alias channel id',
39
+ expected: {block_height: 16000000, block_index: 0, output_index: 10},
40
+ },
36
41
  {
37
42
  args: {},
38
43
  description: 'Id or channel or number is required',
@@ -21,6 +21,15 @@ const tests = [
21
21
  number: '590587277833404417',
22
22
  },
23
23
  },
24
+ {
25
+ args: {block_height: 16000000, block_index: 0, output_index: 10},
26
+ description: 'SCID alias channel id',
27
+ expected: {
28
+ channel: '16000000x0x10',
29
+ id: 'f42400000000000a',
30
+ number: '17592186044416000010',
31
+ },
32
+ },
24
33
  {
25
34
  args: {},
26
35
  description: 'Expected block height',
@@ -23,6 +23,11 @@ const tests = [
23
23
  description: 'Standard bitcoin channel id',
24
24
  expected: {id: '0832300008200001'},
25
25
  },
26
+ {
27
+ args: {number: '17592186044416000010'},
28
+ description: 'SCID alias channel id',
29
+ expected: {id: 'f42400000000000a'},
30
+ },
26
31
  {
27
32
  args: {},
28
33
  description: 'Number is required',