@cryptotaxi247 / kubo / commits / bec54c254

Rename PTP to P2P

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Jun 19, 2017 at 20:46 UTC bec54c25400a8a551bba4a58681cd1ad15ddde66
6 files changed +127 -127
core/commands/p2p.go renamed
+50 -50
@@ -14,14 +14,14 @@ import (
14 ma "gx/ipfs/QmcyqRMCAXVtYPS4DiBrA7sezL9rRGfW8Ctx7cywL4TXJj/go-multiaddr"
15 )
16
17 -// PTPListenerInfoOutput is output type of ls command
18 -type PTPListenerInfoOutput struct {
17 +// P2PListenerInfoOutput is output type of ls command
18 +type P2PListenerInfoOutput struct {
19 Protocol string
20 Address string
21 }
22
23 -// PTPStreamInfoOutput is output type of streams command
24 -type PTPStreamInfoOutput struct {
23 +// P2PStreamInfoOutput is output type of streams command
24 +type P2PStreamInfoOutput struct {
25 HandlerID string
26 Protocol string
27 LocalPeer string
@@ -30,18 +30,18 @@ type PTPStreamInfoOutput struct {
30 RemoteAddress string
31 }
32
33 -// PTPLsOutput is output type of ls command
34 -type PTPLsOutput struct {
35 - Listeners []PTPListenerInfoOutput
33 +// P2PLsOutput is output type of ls command
34 +type P2PLsOutput struct {
35 + Listeners []P2PListenerInfoOutput
36 }
37
38 -// PTPStreamsOutput is output type of streams command
39 -type PTPStreamsOutput struct {
40 - Streams []PTPStreamInfoOutput
38 +// P2PStreamsOutput is output type of streams command
39 +type P2PStreamsOutput struct {
40 + Streams []P2PStreamInfoOutput
41 }
42
43 -// PTPCmd is the 'ipfs ptp' command
44 -var PTPCmd = &cmds.Command{
43 +// P2PCmd is the 'ipfs ppp' command
44 +var P2PCmd = &cmds.Command{
45 Helptext: cmds.HelpText{
46 Tagline: "Libp2p stream mounting.",
47 ShortDescription: `
@@ -51,40 +51,40 @@ Note: this command is experimental and subject to change as usecases and APIs ar
51 },
52
53 Subcommands: map[string]*cmds.Command{
54 - "listener": ptpListenerCmd,
55 - "stream": ptpStreamCmd,
54 + "listener": p2pListenerCmd,
55 + "stream": p2pStreamCmd,
56 },
57 }
58
59 -// ptpListenerCmd is the 'ipfs ptp listener' command
60 -var ptpListenerCmd = &cmds.Command{
59 +// p2pListenerCmd is the 'ipfs p2p listener' command
60 +var p2pListenerCmd = &cmds.Command{
61 Helptext: cmds.HelpText{
62 Tagline: "P2P listener management.",
63 ShortDescription: "Create and manage listener p2p endpoints",
64 },
65
66 Subcommands: map[string]*cmds.Command{
67 - "ls": ptpListenerLsCmd,
68 - "open": ptpListenerListenCmd,
69 - "close": ptpListenerCloseCmd,
67 + "ls": p2pListenerLsCmd,
68 + "open": p2pListenerListenCmd,
69 + "close": p2pListenerCloseCmd,
70 },
71 }
72
73 -// ptpStreamCmd is the 'ipfs ptp stream' command
74 -var ptpStreamCmd = &cmds.Command{
73 +// p2pStreamCmd is the 'ipfs p2p stream' command
74 +var p2pStreamCmd = &cmds.Command{
75 Helptext: cmds.HelpText{
76 Tagline: "P2P stream management.",
77 ShortDescription: "Create and manage p2p streams",
78 },
79
80 Subcommands: map[string]*cmds.Command{
81 - "ls": ptpStreamLsCmd,
82 - "dial": ptpStreamDialCmd,
83 - "close": ptpStreamCloseCmd,
81 + "ls": p2pStreamLsCmd,
82 + "dial": p2pStreamDialCmd,
83 + "close": p2pStreamCloseCmd,
84 },
85 }
86
87 -var ptpListenerLsCmd = &cmds.Command{
87 +var p2pListenerLsCmd = &cmds.Command{
88 Helptext: cmds.HelpText{
89 Tagline: "List active p2p listeners.",
90 },
@@ -99,10 +99,10 @@ var ptpListenerLsCmd = &cmds.Command{
99 return
100 }
101
102 - output := &PTPLsOutput{}
102 + output := &P2PLsOutput{}
103
104 - for _, listener := range n.PTP.Listeners.Listeners {
105 - output.Listeners = append(output.Listeners, PTPListenerInfoOutput{
104 + for _, listener := range n.P2P.Listeners.Listeners {
105 + output.Listeners = append(output.Listeners, P2PListenerInfoOutput{
106 Protocol: listener.Protocol,
107 Address: listener.Address.String(),
108 })
@@ -110,11 +110,11 @@ var ptpListenerLsCmd = &cmds.Command{
110
111 res.SetOutput(output)
112 },
113 - Type: PTPLsOutput{},
113 + Type: P2PLsOutput{},
114 Marshalers: cmds.MarshalerMap{
115 cmds.Text: func(res cmds.Response) (io.Reader, error) {
116 headers, _, _ := res.Request().Option("headers").Bool()
117 - list, _ := res.Output().(*PTPLsOutput)
117 + list, _ := res.Output().(*P2PLsOutput)
118 buf := new(bytes.Buffer)
119 w := tabwriter.NewWriter(buf, 1, 2, 1, ' ', 0)
120 for _, listener := range list.Listeners {
@@ -131,7 +131,7 @@ var ptpListenerLsCmd = &cmds.Command{
131 },
132 }
133
134 -var ptpStreamLsCmd = &cmds.Command{
134 +var p2pStreamLsCmd = &cmds.Command{
135 Helptext: cmds.HelpText{
136 Tagline: "List active p2p streams.",
137 },
@@ -145,10 +145,10 @@ var ptpStreamLsCmd = &cmds.Command{
145 return
146 }
147
148 - output := &PTPStreamsOutput{}
148 + output := &P2PStreamsOutput{}
149
150 - for _, s := range n.PTP.Streams.Streams {
151 - output.Streams = append(output.Streams, PTPStreamInfoOutput{
150 + for _, s := range n.P2P.Streams.Streams {
151 + output.Streams = append(output.Streams, P2PStreamInfoOutput{
152 HandlerID: strconv.FormatUint(s.HandlerID, 10),
153
154 Protocol: s.Protocol,
@@ -163,11 +163,11 @@ var ptpStreamLsCmd = &cmds.Command{
163
164 res.SetOutput(output)
165 },
166 - Type: PTPStreamsOutput{},
166 + Type: P2PStreamsOutput{},
167 Marshalers: cmds.MarshalerMap{
168 cmds.Text: func(res cmds.Response) (io.Reader, error) {
169 headers, _, _ := res.Request().Option("headers").Bool()
170 - list, _ := res.Output().(*PTPStreamsOutput)
170 + list, _ := res.Output().(*P2PStreamsOutput)
171 buf := new(bytes.Buffer)
172 w := tabwriter.NewWriter(buf, 1, 2, 1, ' ', 0)
173 for _, stream := range list.Streams {
@@ -184,7 +184,7 @@ var ptpStreamLsCmd = &cmds.Command{
184 },
185 }
186
187 -var ptpListenerListenCmd = &cmds.Command{
187 +var p2pListenerListenCmd = &cmds.Command{
188 Helptext: cmds.HelpText{
189 Tagline: "Forward p2p connections to a network multiaddr.",
190 ShortDescription: `
@@ -204,8 +204,8 @@ Note that the connections originate from the ipfs daemon process.
204 return
205 }
206
207 - proto := "/ptp/" + req.Arguments()[0]
208 - if n.PTP.CheckProtoExists(proto) {
207 + proto := "/p2p/" + req.Arguments()[0]
208 + if n.P2P.CheckProtoExists(proto) {
209 res.SetError(errors.New("protocol handler already registered"), cmds.ErrNormal)
210 return
211 }
@@ -216,21 +216,21 @@ Note that the connections originate from the ipfs daemon process.
216 return
217 }
218
219 - _, err = n.PTP.NewListener(n.Context(), proto, addr)
219 + _, err = n.P2P.NewListener(n.Context(), proto, addr)
220 if err != nil {
221 res.SetError(err, cmds.ErrNormal)
222 return
223 }
224
225 // Successful response.
226 - res.SetOutput(&PTPListenerInfoOutput{
226 + res.SetOutput(&P2PListenerInfoOutput{
227 Protocol: proto,
228 Address: addr.String(),
229 })
230 },
231 }
232
233 -var ptpStreamDialCmd = &cmds.Command{
233 +var p2pStreamDialCmd = &cmds.Command{
234 Helptext: cmds.HelpText{
235 Tagline: "Dial to a p2p listener.",
236
@@ -260,7 +260,7 @@ transparently connect to a p2p service.
260 return
261 }
262
263 - proto := "/ptp/" + req.Arguments()[1]
263 + proto := "/p2p/" + req.Arguments()[1]
264
265 bindAddr, _ := ma.NewMultiaddr("/ip4/127.0.0.1/tcp/0")
266 if len(req.Arguments()) == 3 {
@@ -271,13 +271,13 @@ transparently connect to a p2p service.
271 }
272 }
273
274 - listenerInfo, err := n.PTP.Dial(n.Context(), addr, peer, proto, bindAddr)
274 + listenerInfo, err := n.P2P.Dial(n.Context(), addr, peer, proto, bindAddr)
275 if err != nil {
276 res.SetError(err, cmds.ErrNormal)
277 return
278 }
279
280 - output := PTPListenerInfoOutput{
280 + output := P2PListenerInfoOutput{
281 Protocol: listenerInfo.Protocol,
282 Address: listenerInfo.Address.String(),
283 }
@@ -286,7 +286,7 @@ transparently connect to a p2p service.
286 },
287 }
288
289 -var ptpListenerCloseCmd = &cmds.Command{
289 +var p2pListenerCloseCmd = &cmds.Command{
290 Helptext: cmds.HelpText{
291 Tagline: "Close active p2p listener.",
292 },
@@ -312,10 +312,10 @@ var ptpListenerCloseCmd = &cmds.Command{
312 return
313 }
314
315 - proto = "/ptp/" + req.Arguments()[0]
315 + proto = "/p2p/" + req.Arguments()[0]
316 }
317
318 - for _, listener := range n.PTP.Listeners.Listeners {
318 + for _, listener := range n.P2P.Listeners.Listeners {
319 if !closeAll && listener.Protocol != proto {
320 continue
321 }
@@ -327,7 +327,7 @@ var ptpListenerCloseCmd = &cmds.Command{
327 },
328 }
329
330 -var ptpStreamCloseCmd = &cmds.Command{
330 +var p2pStreamCloseCmd = &cmds.Command{
331 Helptext: cmds.HelpText{
332 Tagline: "Close active p2p stream.",
333 },
@@ -360,7 +360,7 @@ var ptpStreamCloseCmd = &cmds.Command{
360 }
361 }
362
363 - for _, stream := range n.PTP.Streams.Streams {
363 + for _, stream := range n.P2P.Streams.Streams {
364 if !closeAll && handlerID != stream.HandlerID {
365 continue
366 }
core/commands/root.go
+2 -2
@@ -47,7 +47,7 @@ ADVANCED COMMANDS
47 pin Pin objects to local storage
48 repo Manipulate the IPFS repository
49 stats Various operational stats
50 - ptp Libp2p stream mounting
50 + p2p Libp2p stream mounting
51 filestore Manage the filestore (experimental)
52
53 NETWORK COMMANDS
@@ -114,7 +114,7 @@ var rootSubcommands = map[string]*cmds.Command{
114 "object": ocmd.ObjectCmd,
115 "pin": PinCmd,
116 "ping": PingCmd,
117 - "ptp": PTPCmd,
117 + "p2p": P2PCmd,
118 "pubsub": PubsubCmd,
119 "refs": RefsCmd,
120 "repo": RepoCmd,
core/core.go
+3 -3
@@ -33,9 +33,9 @@ import (
33 mfs "github.com/ipfs/go-ipfs/mfs"
34 namesys "github.com/ipfs/go-ipfs/namesys"
35 ipnsrp "github.com/ipfs/go-ipfs/namesys/republisher"
36 + p2p "github.com/ipfs/go-ipfs/p2p"
37 path "github.com/ipfs/go-ipfs/path"
38 pin "github.com/ipfs/go-ipfs/pin"
38 - ptp "github.com/ipfs/go-ipfs/ptp"
39 repo "github.com/ipfs/go-ipfs/repo"
40 config "github.com/ipfs/go-ipfs/repo/config"
41 nilrouting "github.com/ipfs/go-ipfs/routing/none"
@@ -131,7 +131,7 @@ type IpfsNode struct {
131 IpnsRepub *ipnsrp.Republisher
132
133 Floodsub *floodsub.PubSub
134 - PTP *ptp.PTP
134 + P2P *p2p.P2P
135
136 proc goprocess.Process
137 ctx context.Context
@@ -247,7 +247,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
247 n.Floodsub = floodsub.NewFloodSub(ctx, peerhost)
248 }
249
250 - n.PTP = ptp.NewPTP(n.Identity, n.PeerHost, n.Peerstore)
250 + n.P2P = p2p.NewP2P(n.Identity, n.PeerHost, n.Peerstore)
251
252 // setup local discovery
253 if do != nil {
p2p/p2p.go renamed
+32 -32
@@ -1,4 +1,4 @@
1 -package ptp
1 +package p2p
2
3 import (
4 "context"
@@ -14,8 +14,8 @@ import (
14 manet "gx/ipfs/Qmf1Gq7N45Rpuw7ev47uWgH6dLPtdnvcMRNPkVBwqjLJg2/go-multiaddr-net"
15 )
16
17 -// PTP structure holds information on currently running streams/listeners
18 -type PTP struct {
17 +// P2P structure holds information on currently running streams/listeners
18 +type P2P struct {
19 Listeners ListenerRegistry
20 Streams StreamRegistry
21
@@ -24,38 +24,38 @@ type PTP struct {
24 peerstore pstore.Peerstore
25 }
26
27 -// NewPTP creates new PTP struct
28 -func NewPTP(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *PTP {
29 - return &PTP{
27 +// NewP2P creates new P2P struct
28 +func NewP2P(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *P2P {
29 + return &P2P{
30 identity: identity,
31 peerHost: peerHost,
32 peerstore: peerstore,
33 }
34 }
35
36 -func (ptp *PTP) newStreamTo(ctx2 context.Context, p peer.ID, protocol string) (net.Stream, error) {
36 +func (p2p *P2P) newStreamTo(ctx2 context.Context, p peer.ID, protocol string) (net.Stream, error) {
37 ctx, cancel := context.WithTimeout(ctx2, time.Second*30) //TODO: configurable?
38 defer cancel()
39 - err := ptp.peerHost.Connect(ctx, pstore.PeerInfo{ID: p})
39 + err := p2p.peerHost.Connect(ctx, pstore.PeerInfo{ID: p})
40 if err != nil {
41 return nil, err
42 }
43 - return ptp.peerHost.NewStream(ctx2, p, pro.ID(protocol))
43 + return p2p.peerHost.NewStream(ctx2, p, pro.ID(protocol))
44 }
45
46 // Dial creates new P2P stream to a remote listener
47 -func (ptp *PTP) Dial(ctx context.Context, addr ma.Multiaddr, peer peer.ID, proto string, bindAddr ma.Multiaddr) (*ListenerInfo, error) {
47 +func (p2p *P2P) Dial(ctx context.Context, addr ma.Multiaddr, peer peer.ID, proto string, bindAddr ma.Multiaddr) (*ListenerInfo, error) {
48 lnet, _, err := manet.DialArgs(bindAddr)
49 if err != nil {
50 return nil, err
51 }
52
53 listenerInfo := ListenerInfo{
54 - Identity: ptp.identity,
54 + Identity: p2p.identity,
55 Protocol: proto,
56 }
57
58 - remote, err := ptp.newStreamTo(ctx, peer, proto)
58 + remote, err := p2p.newStreamTo(ctx, peer, proto)
59 if err != nil {
60 return nil, err
61 }
@@ -74,7 +74,7 @@ func (ptp *PTP) Dial(ctx context.Context, addr ma.Multiaddr, peer peer.ID, proto
74 listenerInfo.Closer = listener
75 listenerInfo.Running = true
76
77 - go ptp.doAccept(&listenerInfo, remote, listener)
77 + go p2p.doAccept(&listenerInfo, remote, listener)
78
79 default:
80 return nil, errors.New("unsupported protocol: " + lnet)
@@ -83,7 +83,7 @@ func (ptp *PTP) Dial(ctx context.Context, addr ma.Multiaddr, peer peer.ID, proto
83 return &listenerInfo, nil
84 }
85
86 -func (ptp *PTP) doAccept(listenerInfo *ListenerInfo, remote net.Stream, listener manet.Listener) {
86 +func (p2p *P2P) doAccept(listenerInfo *ListenerInfo, remote net.Stream, listener manet.Listener) {
87 defer listener.Close()
88
89 local, err := listener.Accept()
@@ -103,10 +103,10 @@ func (ptp *PTP) doAccept(listenerInfo *ListenerInfo, remote net.Stream, listener
103 Local: local,
104 Remote: remote,
105
106 - Registry: &ptp.Streams,
106 + Registry: &p2p.Streams,
107 }
108
109 - ptp.Streams.Register(&stream)
109 + p2p.Streams.Register(&stream)
110 stream.startStreaming()
111 }
112
@@ -143,18 +143,18 @@ func (il *P2PListener) Close() error {
143 }
144
145 // Listen creates new P2PListener
146 -func (ptp *PTP) registerStreamHandler(ctx2 context.Context, protocol string) (*P2PListener, error) {
146 +func (p2p *P2P) registerStreamHandler(ctx2 context.Context, protocol string) (*P2PListener, error) {
147 ctx, cancel := context.WithCancel(ctx2)
148
149 list := &P2PListener{
150 - peerHost: ptp.peerHost,
150 + peerHost: p2p.peerHost,
151 proto: pro.ID(protocol),
152 conCh: make(chan net.Stream),
153 ctx: ctx,
154 cancel: cancel,
155 }
156
157 - ptp.peerHost.SetStreamHandler(list.proto, func(s net.Stream) {
157 + p2p.peerHost.SetStreamHandler(list.proto, func(s net.Stream) {
158 select {
159 case list.conCh <- s:
160 case <-ctx.Done():
@@ -165,30 +165,30 @@ func (ptp *PTP) registerStreamHandler(ctx2 context.Context, protocol string) (*P
165 return list, nil
166 }
167
168 -// NewListener creates new ptp listener
169 -func (ptp *PTP) NewListener(ctx context.Context, proto string, addr ma.Multiaddr) (*ListenerInfo, error) {
170 - listener, err := ptp.registerStreamHandler(ctx, proto)
168 +// NewListener creates new p2p listener
169 +func (p2p *P2P) NewListener(ctx context.Context, proto string, addr ma.Multiaddr) (*ListenerInfo, error) {
170 + listener, err := p2p.registerStreamHandler(ctx, proto)
171 if err != nil {
172 return nil, err
173 }
174
175 listenerInfo := ListenerInfo{
176 - Identity: ptp.identity,
176 + Identity: p2p.identity,
177 Protocol: proto,
178 Address: addr,
179 Closer: listener,
180 Running: true,
181 - Registry: &ptp.Listeners,
181 + Registry: &p2p.Listeners,
182 }
183
184 - go ptp.acceptStreams(&listenerInfo, listener)
184 + go p2p.acceptStreams(&listenerInfo, listener)
185
186 - ptp.Listeners.Register(&listenerInfo)
186 + p2p.Listeners.Register(&listenerInfo)
187
188 return &listenerInfo, nil
189 }
190
191 -func (ptp *PTP) acceptStreams(listenerInfo *ListenerInfo, listener Listener) {
191 +func (p2p *P2P) acceptStreams(listenerInfo *ListenerInfo, listener Listener) {
192 for listenerInfo.Running {
193 remote, err := listener.Accept()
194 if err != nil {
@@ -214,19 +214,19 @@ func (ptp *PTP) acceptStreams(listenerInfo *ListenerInfo, listener Listener) {
214 Local: local,
215 Remote: remote,
216
217 - Registry: &ptp.Streams,
217 + Registry: &p2p.Streams,
218 }
219
220 - ptp.Streams.Register(&stream)
220 + p2p.Streams.Register(&stream)
221 stream.startStreaming()
222 }
223 - ptp.Listeners.Deregister(listenerInfo.Protocol)
223 + p2p.Listeners.Deregister(listenerInfo.Protocol)
224 }
225
226 // CheckProtoExists checks whether a protocol handler is registered to
227 // mux handler
228 -func (ptp *PTP) CheckProtoExists(proto string) bool {
229 - protos := ptp.peerHost.Mux().Protocols()
228 +func (p2p *P2P) CheckProtoExists(proto string) bool {
229 + protos := p2p.peerHost.Mux().Protocols()
230
231 for _, p := range protos {
232 if p != proto {
p2p/registry.go renamed
+1 -1
@@ -1,4 +1,4 @@
1 -package ptp
1 +package p2p
2
3 import (
4 "fmt"
test/sharness/t0180-p2p.sh renamed
+39 -39
@@ -1,6 +1,6 @@
1 #!/bin/sh
2
3 -test_description="Test experimental ptp commands"
3 +test_description="Test experimental p2p commands"
4
5 . lib/test-lib.sh
6
@@ -27,7 +27,7 @@ test_expect_success "test ports are closed" '
27 '
28
29 test_must_fail 'fail without config option being enabled' '
30 - ipfsi 0 ptp stream ls
30 + ipfsi 0 p2p stream ls
31 '
32
33 test_expect_success "enable filestore config setting" '
@@ -35,15 +35,15 @@ test_expect_success "enable filestore config setting" '
35 ipfsi 1 config --json Experimental.Libp2pStreamMounting true
36 '
37
38 -test_expect_success 'start ptp listener' '
39 - ipfsi 0 ptp listener open ptp-test /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log
38 +test_expect_success 'start p2p listener' '
39 + ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log
40 '
41
42 test_expect_success 'Test server to client communications' '
43 ma-pipe-unidir --listen send /ip4/127.0.0.1/tcp/10101 < test0.bin &
44 SERVER_PID=$!
45
46 - ipfsi 1 ptp stream dial $PEERID_0 ptp-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
46 + ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
47 ma-pipe-unidir recv /ip4/127.0.0.1/tcp/10102 > client.out &&
48 wait $SERVER_PID
49 '
@@ -52,7 +52,7 @@ test_expect_success 'Test client to server communications' '
52 ma-pipe-unidir --listen recv /ip4/127.0.0.1/tcp/10101 > server.out &
53 SERVER_PID=$!
54
55 - ipfsi 1 ptp stream dial $PEERID_0 ptp-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
55 + ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
56 ma-pipe-unidir send /ip4/127.0.0.1/tcp/10102 < test1.bin
57 wait $SERVER_PID
58 '
@@ -65,90 +65,90 @@ test_expect_success 'client to server output looks good' '
65 test_cmp server.out test1.bin
66 '
67
68 -test_expect_success "'ipfs listener ptp ls' succeeds" '
69 - echo "/ip4/127.0.0.1/tcp/10101 /ptp/ptp-test" > expected &&
70 - ipfsi 0 ptp listener ls > actual
68 +test_expect_success "'ipfs listener p2p ls' succeeds" '
69 + echo "/ip4/127.0.0.1/tcp/10101 /p2p/p2p-test" > expected &&
70 + ipfsi 0 p2p listener ls > actual
71 '
72
73 -test_expect_success "'ipfs ptp listener ls' output looks good" '
73 +test_expect_success "'ipfs p2p listener ls' output looks good" '
74 test_cmp expected actual
75 '
76
77 test_expect_success "Cannot re-register app handler" '
78 - (! ipfsi 0 ptp listener open ptp-test /ip4/127.0.0.1/tcp/10101)
78 + (! ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101)
79 '
80
81 -test_expect_success "'ipfs ptp stream ls' output is empty" '
82 - ipfsi 0 ptp stream ls > actual &&
81 +test_expect_success "'ipfs p2p stream ls' output is empty" '
82 + ipfsi 0 p2p stream ls > actual &&
83 test_must_be_empty actual
84 '
85
86 test_expect_success "Setup: Idle stream" '
87 ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 &
88
89 - ipfsi 1 ptp stream dial $PEERID_0 ptp-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
89 + ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
90 ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 &
91
92 go-sleep 500ms &&
93 kill -0 $(cat listener.pid) && kill -0 $(cat client.pid)
94 '
95
96 -test_expect_success "'ipfs ptp stream ls' succeeds" '
97 - echo "2 /ptp/ptp-test /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
98 - ipfsi 0 ptp stream ls > actual
96 +test_expect_success "'ipfs p2p stream ls' succeeds" '
97 + echo "2 /p2p/p2p-test /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
98 + ipfsi 0 p2p stream ls > actual
99 '
100
101 -test_expect_success "'ipfs ptp stream ls' output looks good" '
101 +test_expect_success "'ipfs p2p stream ls' output looks good" '
102 test_cmp expected actual
103 '
104
105 -test_expect_success "'ipfs ptp stream close' closes stream" '
106 - ipfsi 0 ptp stream close 2 &&
107 - ipfsi 0 ptp stream ls > actual &&
105 +test_expect_success "'ipfs p2p stream close' closes stream" '
106 + ipfsi 0 p2p stream close 2 &&
107 + ipfsi 0 p2p stream ls > actual &&
108 [ ! -f listener.pid ] && [ ! -f client.pid ] &&
109 test_must_be_empty actual
110 '
111
112 -test_expect_success "'ipfs ptp listener close' closes app handler" '
113 - ipfsi 0 ptp listener close ptp-test &&
114 - ipfsi 0 ptp listener ls > actual &&
112 +test_expect_success "'ipfs p2p listener close' closes app handler" '
113 + ipfsi 0 p2p listener close p2p-test &&
114 + ipfsi 0 p2p listener ls > actual &&
115 test_must_be_empty actual
116 '
117
118 test_expect_success "Setup: Idle stream(2)" '
119 ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 &
120
121 - ipfsi 0 ptp listener open ptp-test2 /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log &&
122 - ipfsi 1 ptp stream dial $PEERID_0 ptp-test2 /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
121 + ipfsi 0 p2p listener open p2p-test2 /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log &&
122 + ipfsi 1 p2p stream dial $PEERID_0 p2p-test2 /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
123 ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 &
124
125 go-sleep 500ms &&
126 kill -0 $(cat listener.pid) && kill -0 $(cat client.pid)
127 '
128
129 -test_expect_success "'ipfs ptp stream ls' succeeds(2)" '
130 - echo "3 /ptp/ptp-test2 /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
131 - ipfsi 0 ptp stream ls > actual
129 +test_expect_success "'ipfs p2p stream ls' succeeds(2)" '
130 + echo "3 /p2p/p2p-test2 /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
131 + ipfsi 0 p2p stream ls > actual
132 test_cmp expected actual
133 '
134
135 -test_expect_success "'ipfs ptp listener close -a' closes app handlers" '
136 - ipfsi 0 ptp listener close -a &&
137 - ipfsi 0 ptp listener ls > actual &&
135 +test_expect_success "'ipfs p2p listener close -a' closes app handlers" '
136 + ipfsi 0 p2p listener close -a &&
137 + ipfsi 0 p2p listener ls > actual &&
138 test_must_be_empty actual
139 '
140
141 -test_expect_success "'ipfs ptp stream close -a' closes streams" '
142 - ipfsi 0 ptp stream close -a &&
143 - ipfsi 0 ptp stream ls > actual &&
141 +test_expect_success "'ipfs p2p stream close -a' closes streams" '
142 + ipfsi 0 p2p stream close -a &&
143 + ipfsi 0 p2p stream ls > actual &&
144 [ ! -f listener.pid ] && [ ! -f client.pid ] &&
145 test_must_be_empty actual
146 '
147
148 -test_expect_success "'ipfs ptp listener close' closes app numeric handlers" '
149 - ipfsi 0 ptp listener open 1234 /ip4/127.0.0.1/tcp/10101 &&
150 - ipfsi 0 ptp listener close 1234 &&
151 - ipfsi 0 ptp listener ls > actual &&
148 +test_expect_success "'ipfs p2p listener close' closes app numeric handlers" '
149 + ipfsi 0 p2p listener open 1234 /ip4/127.0.0.1/tcp/10101 &&
150 + ipfsi 0 p2p listener close 1234 &&
151 + ipfsi 0 p2p listener ls > actual &&
152 test_must_be_empty actual
153 '
154