File tree Expand file tree Collapse file tree
packages/utils/test/multiaddr Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { multiaddr } from '@multiformats/multiaddr'
2+ import { expect } from 'aegir/chai'
3+ import { getNetConfig } from '../../src/index.ts'
4+
5+ describe ( 'multiaddr getNetConfig' , ( ) => {
6+ it ( 'throws on empty multiaddr' , ( ) => {
7+ expect ( ( ) => getNetConfig ( multiaddr ( ) ) ) . to . throw ( )
8+ } )
9+
10+ it ( 'identifies ip4 multiaddrs' , ( ) => {
11+ expect ( getNetConfig ( multiaddr ( '/ip4/169.254.35.4' ) ) ) . to . deep . equal ( {
12+ type : 'ip4' ,
13+ host : '169.254.35.4'
14+ } )
15+ expect ( getNetConfig ( multiaddr ( '/ip4/169.254.35.4/tcp/1000' ) ) ) . to . deep . equal ( {
16+ type : 'ip4' ,
17+ host : '169.254.35.4' ,
18+ protocol : 'tcp' ,
19+ port : 1000
20+ } )
21+ } )
22+
23+ it ( 'identifies ip6 multiaddrs' , ( ) => {
24+ expect ( getNetConfig ( multiaddr ( '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095' ) ) ) . to . deep . equal ( {
25+ type : 'ip6' ,
26+ host : '2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095'
27+ } )
28+ expect ( getNetConfig ( multiaddr ( '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/tcp/1000' ) ) ) . to . deep . equal ( {
29+ type : 'ip6' ,
30+ host : '2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095' ,
31+ protocol : 'tcp' ,
32+ port : 1000
33+ } )
34+ } )
35+ } )
You can’t perform that action at this time.
0 commit comments