Rename PTP to P2P

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
Łukasz Magiera 2017-06-19 20:46:55 +02:00
parent 2f999d4b49
commit bec54c2540
6 changed files with 127 additions and 127 deletions

View File

@ -14,14 +14,14 @@ import (
ma "gx/ipfs/QmcyqRMCAXVtYPS4DiBrA7sezL9rRGfW8Ctx7cywL4TXJj/go-multiaddr"
)
// PTPListenerInfoOutput is output type of ls command
type PTPListenerInfoOutput struct {
// P2PListenerInfoOutput is output type of ls command
type P2PListenerInfoOutput struct {
Protocol string
Address string
}
// PTPStreamInfoOutput is output type of streams command
type PTPStreamInfoOutput struct {
// P2PStreamInfoOutput is output type of streams command
type P2PStreamInfoOutput struct {
HandlerID string
Protocol string
LocalPeer string
@ -30,18 +30,18 @@ type PTPStreamInfoOutput struct {
RemoteAddress string
}
// PTPLsOutput is output type of ls command
type PTPLsOutput struct {
Listeners []PTPListenerInfoOutput
// P2PLsOutput is output type of ls command
type P2PLsOutput struct {
Listeners []P2PListenerInfoOutput
}
// PTPStreamsOutput is output type of streams command
type PTPStreamsOutput struct {
Streams []PTPStreamInfoOutput
// P2PStreamsOutput is output type of streams command
type P2PStreamsOutput struct {
Streams []P2PStreamInfoOutput
}
// PTPCmd is the 'ipfs ptp' command
var PTPCmd = &cmds.Command{
// P2PCmd is the 'ipfs ppp' command
var P2PCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Libp2p stream mounting.",
ShortDescription: `
@ -51,40 +51,40 @@ Note: this command is experimental and subject to change as usecases and APIs ar
},
Subcommands: map[string]*cmds.Command{
"listener": ptpListenerCmd,
"stream": ptpStreamCmd,
"listener": p2pListenerCmd,
"stream": p2pStreamCmd,
},
}
// ptpListenerCmd is the 'ipfs ptp listener' command
var ptpListenerCmd = &cmds.Command{
// p2pListenerCmd is the 'ipfs p2p listener' command
var p2pListenerCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "P2P listener management.",
ShortDescription: "Create and manage listener p2p endpoints",
},
Subcommands: map[string]*cmds.Command{
"ls": ptpListenerLsCmd,
"open": ptpListenerListenCmd,
"close": ptpListenerCloseCmd,
"ls": p2pListenerLsCmd,
"open": p2pListenerListenCmd,
"close": p2pListenerCloseCmd,
},
}
// ptpStreamCmd is the 'ipfs ptp stream' command
var ptpStreamCmd = &cmds.Command{
// p2pStreamCmd is the 'ipfs p2p stream' command
var p2pStreamCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "P2P stream management.",
ShortDescription: "Create and manage p2p streams",
},
Subcommands: map[string]*cmds.Command{
"ls": ptpStreamLsCmd,
"dial": ptpStreamDialCmd,
"close": ptpStreamCloseCmd,
"ls": p2pStreamLsCmd,
"dial": p2pStreamDialCmd,
"close": p2pStreamCloseCmd,
},
}
var ptpListenerLsCmd = &cmds.Command{
var p2pListenerLsCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "List active p2p listeners.",
},
@ -99,10 +99,10 @@ var ptpListenerLsCmd = &cmds.Command{
return
}
output := &PTPLsOutput{}
output := &P2PLsOutput{}
for _, listener := range n.PTP.Listeners.Listeners {
output.Listeners = append(output.Listeners, PTPListenerInfoOutput{
for _, listener := range n.P2P.Listeners.Listeners {
output.Listeners = append(output.Listeners, P2PListenerInfoOutput{
Protocol: listener.Protocol,
Address: listener.Address.String(),
})
@ -110,11 +110,11 @@ var ptpListenerLsCmd = &cmds.Command{
res.SetOutput(output)
},
Type: PTPLsOutput{},
Type: P2PLsOutput{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
headers, _, _ := res.Request().Option("headers").Bool()
list, _ := res.Output().(*PTPLsOutput)
list, _ := res.Output().(*P2PLsOutput)
buf := new(bytes.Buffer)
w := tabwriter.NewWriter(buf, 1, 2, 1, ' ', 0)
for _, listener := range list.Listeners {
@ -131,7 +131,7 @@ var ptpListenerLsCmd = &cmds.Command{
},
}
var ptpStreamLsCmd = &cmds.Command{
var p2pStreamLsCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "List active p2p streams.",
},
@ -145,10 +145,10 @@ var ptpStreamLsCmd = &cmds.Command{
return
}
output := &PTPStreamsOutput{}
output := &P2PStreamsOutput{}
for _, s := range n.PTP.Streams.Streams {
output.Streams = append(output.Streams, PTPStreamInfoOutput{
for _, s := range n.P2P.Streams.Streams {
output.Streams = append(output.Streams, P2PStreamInfoOutput{
HandlerID: strconv.FormatUint(s.HandlerID, 10),
Protocol: s.Protocol,
@ -163,11 +163,11 @@ var ptpStreamLsCmd = &cmds.Command{
res.SetOutput(output)
},
Type: PTPStreamsOutput{},
Type: P2PStreamsOutput{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
headers, _, _ := res.Request().Option("headers").Bool()
list, _ := res.Output().(*PTPStreamsOutput)
list, _ := res.Output().(*P2PStreamsOutput)
buf := new(bytes.Buffer)
w := tabwriter.NewWriter(buf, 1, 2, 1, ' ', 0)
for _, stream := range list.Streams {
@ -184,7 +184,7 @@ var ptpStreamLsCmd = &cmds.Command{
},
}
var ptpListenerListenCmd = &cmds.Command{
var p2pListenerListenCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Forward p2p connections to a network multiaddr.",
ShortDescription: `
@ -204,8 +204,8 @@ Note that the connections originate from the ipfs daemon process.
return
}
proto := "/ptp/" + req.Arguments()[0]
if n.PTP.CheckProtoExists(proto) {
proto := "/p2p/" + req.Arguments()[0]
if n.P2P.CheckProtoExists(proto) {
res.SetError(errors.New("protocol handler already registered"), cmds.ErrNormal)
return
}
@ -216,21 +216,21 @@ Note that the connections originate from the ipfs daemon process.
return
}
_, err = n.PTP.NewListener(n.Context(), proto, addr)
_, err = n.P2P.NewListener(n.Context(), proto, addr)
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
// Successful response.
res.SetOutput(&PTPListenerInfoOutput{
res.SetOutput(&P2PListenerInfoOutput{
Protocol: proto,
Address: addr.String(),
})
},
}
var ptpStreamDialCmd = &cmds.Command{
var p2pStreamDialCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Dial to a p2p listener.",
@ -260,7 +260,7 @@ transparently connect to a p2p service.
return
}
proto := "/ptp/" + req.Arguments()[1]
proto := "/p2p/" + req.Arguments()[1]
bindAddr, _ := ma.NewMultiaddr("/ip4/127.0.0.1/tcp/0")
if len(req.Arguments()) == 3 {
@ -271,13 +271,13 @@ transparently connect to a p2p service.
}
}
listenerInfo, err := n.PTP.Dial(n.Context(), addr, peer, proto, bindAddr)
listenerInfo, err := n.P2P.Dial(n.Context(), addr, peer, proto, bindAddr)
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
output := PTPListenerInfoOutput{
output := P2PListenerInfoOutput{
Protocol: listenerInfo.Protocol,
Address: listenerInfo.Address.String(),
}
@ -286,7 +286,7 @@ transparently connect to a p2p service.
},
}
var ptpListenerCloseCmd = &cmds.Command{
var p2pListenerCloseCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Close active p2p listener.",
},
@ -312,10 +312,10 @@ var ptpListenerCloseCmd = &cmds.Command{
return
}
proto = "/ptp/" + req.Arguments()[0]
proto = "/p2p/" + req.Arguments()[0]
}
for _, listener := range n.PTP.Listeners.Listeners {
for _, listener := range n.P2P.Listeners.Listeners {
if !closeAll && listener.Protocol != proto {
continue
}
@ -327,7 +327,7 @@ var ptpListenerCloseCmd = &cmds.Command{
},
}
var ptpStreamCloseCmd = &cmds.Command{
var p2pStreamCloseCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Close active p2p stream.",
},
@ -360,7 +360,7 @@ var ptpStreamCloseCmd = &cmds.Command{
}
}
for _, stream := range n.PTP.Streams.Streams {
for _, stream := range n.P2P.Streams.Streams {
if !closeAll && handlerID != stream.HandlerID {
continue
}

View File

@ -47,7 +47,7 @@ ADVANCED COMMANDS
pin Pin objects to local storage
repo Manipulate the IPFS repository
stats Various operational stats
ptp Libp2p stream mounting
p2p Libp2p stream mounting
filestore Manage the filestore (experimental)
NETWORK COMMANDS
@ -114,7 +114,7 @@ var rootSubcommands = map[string]*cmds.Command{
"object": ocmd.ObjectCmd,
"pin": PinCmd,
"ping": PingCmd,
"ptp": PTPCmd,
"p2p": P2PCmd,
"pubsub": PubsubCmd,
"refs": RefsCmd,
"repo": RepoCmd,

View File

@ -33,9 +33,9 @@ import (
mfs "github.com/ipfs/go-ipfs/mfs"
namesys "github.com/ipfs/go-ipfs/namesys"
ipnsrp "github.com/ipfs/go-ipfs/namesys/republisher"
p2p "github.com/ipfs/go-ipfs/p2p"
path "github.com/ipfs/go-ipfs/path"
pin "github.com/ipfs/go-ipfs/pin"
ptp "github.com/ipfs/go-ipfs/ptp"
repo "github.com/ipfs/go-ipfs/repo"
config "github.com/ipfs/go-ipfs/repo/config"
nilrouting "github.com/ipfs/go-ipfs/routing/none"
@ -131,7 +131,7 @@ type IpfsNode struct {
IpnsRepub *ipnsrp.Republisher
Floodsub *floodsub.PubSub
PTP *ptp.PTP
P2P *p2p.P2P
proc goprocess.Process
ctx context.Context
@ -247,7 +247,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
n.Floodsub = floodsub.NewFloodSub(ctx, peerhost)
}
n.PTP = ptp.NewPTP(n.Identity, n.PeerHost, n.Peerstore)
n.P2P = p2p.NewP2P(n.Identity, n.PeerHost, n.Peerstore)
// setup local discovery
if do != nil {

View File

@ -1,4 +1,4 @@
package ptp
package p2p
import (
"context"
@ -14,8 +14,8 @@ import (
manet "gx/ipfs/Qmf1Gq7N45Rpuw7ev47uWgH6dLPtdnvcMRNPkVBwqjLJg2/go-multiaddr-net"
)
// PTP structure holds information on currently running streams/listeners
type PTP struct {
// P2P structure holds information on currently running streams/listeners
type P2P struct {
Listeners ListenerRegistry
Streams StreamRegistry
@ -24,38 +24,38 @@ type PTP struct {
peerstore pstore.Peerstore
}
// NewPTP creates new PTP struct
func NewPTP(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *PTP {
return &PTP{
// NewP2P creates new P2P struct
func NewP2P(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *P2P {
return &P2P{
identity: identity,
peerHost: peerHost,
peerstore: peerstore,
}
}
func (ptp *PTP) newStreamTo(ctx2 context.Context, p peer.ID, protocol string) (net.Stream, error) {
func (p2p *P2P) newStreamTo(ctx2 context.Context, p peer.ID, protocol string) (net.Stream, error) {
ctx, cancel := context.WithTimeout(ctx2, time.Second*30) //TODO: configurable?
defer cancel()
err := ptp.peerHost.Connect(ctx, pstore.PeerInfo{ID: p})
err := p2p.peerHost.Connect(ctx, pstore.PeerInfo{ID: p})
if err != nil {
return nil, err
}
return ptp.peerHost.NewStream(ctx2, p, pro.ID(protocol))
return p2p.peerHost.NewStream(ctx2, p, pro.ID(protocol))
}
// Dial creates new P2P stream to a remote listener
func (ptp *PTP) Dial(ctx context.Context, addr ma.Multiaddr, peer peer.ID, proto string, bindAddr ma.Multiaddr) (*ListenerInfo, error) {
func (p2p *P2P) Dial(ctx context.Context, addr ma.Multiaddr, peer peer.ID, proto string, bindAddr ma.Multiaddr) (*ListenerInfo, error) {
lnet, _, err := manet.DialArgs(bindAddr)
if err != nil {
return nil, err
}
listenerInfo := ListenerInfo{
Identity: ptp.identity,
Identity: p2p.identity,
Protocol: proto,
}
remote, err := ptp.newStreamTo(ctx, peer, proto)
remote, err := p2p.newStreamTo(ctx, peer, proto)
if err != nil {
return nil, err
}
@ -74,7 +74,7 @@ func (ptp *PTP) Dial(ctx context.Context, addr ma.Multiaddr, peer peer.ID, proto
listenerInfo.Closer = listener
listenerInfo.Running = true
go ptp.doAccept(&listenerInfo, remote, listener)
go p2p.doAccept(&listenerInfo, remote, listener)
default:
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
return &listenerInfo, nil
}
func (ptp *PTP) doAccept(listenerInfo *ListenerInfo, remote net.Stream, listener manet.Listener) {
func (p2p *P2P) doAccept(listenerInfo *ListenerInfo, remote net.Stream, listener manet.Listener) {
defer listener.Close()
local, err := listener.Accept()
@ -103,10 +103,10 @@ func (ptp *PTP) doAccept(listenerInfo *ListenerInfo, remote net.Stream, listener
Local: local,
Remote: remote,
Registry: &ptp.Streams,
Registry: &p2p.Streams,
}
ptp.Streams.Register(&stream)
p2p.Streams.Register(&stream)
stream.startStreaming()
}
@ -143,18 +143,18 @@ func (il *P2PListener) Close() error {
}
// Listen creates new P2PListener
func (ptp *PTP) registerStreamHandler(ctx2 context.Context, protocol string) (*P2PListener, error) {
func (p2p *P2P) registerStreamHandler(ctx2 context.Context, protocol string) (*P2PListener, error) {
ctx, cancel := context.WithCancel(ctx2)
list := &P2PListener{
peerHost: ptp.peerHost,
peerHost: p2p.peerHost,
proto: pro.ID(protocol),
conCh: make(chan net.Stream),
ctx: ctx,
cancel: cancel,
}
ptp.peerHost.SetStreamHandler(list.proto, func(s net.Stream) {
p2p.peerHost.SetStreamHandler(list.proto, func(s net.Stream) {
select {
case list.conCh <- s:
case <-ctx.Done():
@ -165,30 +165,30 @@ func (ptp *PTP) registerStreamHandler(ctx2 context.Context, protocol string) (*P
return list, nil
}
// NewListener creates new ptp listener
func (ptp *PTP) NewListener(ctx context.Context, proto string, addr ma.Multiaddr) (*ListenerInfo, error) {
listener, err := ptp.registerStreamHandler(ctx, proto)
// NewListener creates new p2p listener
func (p2p *P2P) NewListener(ctx context.Context, proto string, addr ma.Multiaddr) (*ListenerInfo, error) {
listener, err := p2p.registerStreamHandler(ctx, proto)
if err != nil {
return nil, err
}
listenerInfo := ListenerInfo{
Identity: ptp.identity,
Identity: p2p.identity,
Protocol: proto,
Address: addr,
Closer: listener,
Running: true,
Registry: &ptp.Listeners,
Registry: &p2p.Listeners,
}
go ptp.acceptStreams(&listenerInfo, listener)
go p2p.acceptStreams(&listenerInfo, listener)
ptp.Listeners.Register(&listenerInfo)
p2p.Listeners.Register(&listenerInfo)
return &listenerInfo, nil
}
func (ptp *PTP) acceptStreams(listenerInfo *ListenerInfo, listener Listener) {
func (p2p *P2P) acceptStreams(listenerInfo *ListenerInfo, listener Listener) {
for listenerInfo.Running {
remote, err := listener.Accept()
if err != nil {
@ -214,19 +214,19 @@ func (ptp *PTP) acceptStreams(listenerInfo *ListenerInfo, listener Listener) {
Local: local,
Remote: remote,
Registry: &ptp.Streams,
Registry: &p2p.Streams,
}
ptp.Streams.Register(&stream)
p2p.Streams.Register(&stream)
stream.startStreaming()
}
ptp.Listeners.Deregister(listenerInfo.Protocol)
p2p.Listeners.Deregister(listenerInfo.Protocol)
}
// CheckProtoExists checks whether a protocol handler is registered to
// mux handler
func (ptp *PTP) CheckProtoExists(proto string) bool {
protos := ptp.peerHost.Mux().Protocols()
func (p2p *P2P) CheckProtoExists(proto string) bool {
protos := p2p.peerHost.Mux().Protocols()
for _, p := range protos {
if p != proto {

View File

@ -1,4 +1,4 @@
package ptp
package p2p
import (
"fmt"

View File

@ -1,6 +1,6 @@
#!/bin/sh
test_description="Test experimental ptp commands"
test_description="Test experimental p2p commands"
. lib/test-lib.sh
@ -27,7 +27,7 @@ test_expect_success "test ports are closed" '
'
test_must_fail 'fail without config option being enabled' '
ipfsi 0 ptp stream ls
ipfsi 0 p2p stream ls
'
test_expect_success "enable filestore config setting" '
@ -35,15 +35,15 @@ test_expect_success "enable filestore config setting" '
ipfsi 1 config --json Experimental.Libp2pStreamMounting true
'
test_expect_success 'start ptp listener' '
ipfsi 0 ptp listener open ptp-test /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log
test_expect_success 'start p2p listener' '
ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log
'
test_expect_success 'Test server to client communications' '
ma-pipe-unidir --listen send /ip4/127.0.0.1/tcp/10101 < test0.bin &
SERVER_PID=$!
ipfsi 1 ptp stream dial $PEERID_0 ptp-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
ma-pipe-unidir recv /ip4/127.0.0.1/tcp/10102 > client.out &&
wait $SERVER_PID
'
@ -52,7 +52,7 @@ test_expect_success 'Test client to server communications' '
ma-pipe-unidir --listen recv /ip4/127.0.0.1/tcp/10101 > server.out &
SERVER_PID=$!
ipfsi 1 ptp stream dial $PEERID_0 ptp-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
ma-pipe-unidir send /ip4/127.0.0.1/tcp/10102 < test1.bin
wait $SERVER_PID
'
@ -65,90 +65,90 @@ test_expect_success 'client to server output looks good' '
test_cmp server.out test1.bin
'
test_expect_success "'ipfs listener ptp ls' succeeds" '
echo "/ip4/127.0.0.1/tcp/10101 /ptp/ptp-test" > expected &&
ipfsi 0 ptp listener ls > actual
test_expect_success "'ipfs listener p2p ls' succeeds" '
echo "/ip4/127.0.0.1/tcp/10101 /p2p/p2p-test" > expected &&
ipfsi 0 p2p listener ls > actual
'
test_expect_success "'ipfs ptp listener ls' output looks good" '
test_expect_success "'ipfs p2p listener ls' output looks good" '
test_cmp expected actual
'
test_expect_success "Cannot re-register app handler" '
(! ipfsi 0 ptp listener open ptp-test /ip4/127.0.0.1/tcp/10101)
(! ipfsi 0 p2p listener open p2p-test /ip4/127.0.0.1/tcp/10101)
'
test_expect_success "'ipfs ptp stream ls' output is empty" '
ipfsi 0 ptp stream ls > actual &&
test_expect_success "'ipfs p2p stream ls' output is empty" '
ipfsi 0 p2p stream ls > actual &&
test_must_be_empty actual
'
test_expect_success "Setup: Idle stream" '
ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 &
ipfsi 1 ptp stream dial $PEERID_0 ptp-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
ipfsi 1 p2p stream dial $PEERID_0 p2p-test /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 &
go-sleep 500ms &&
kill -0 $(cat listener.pid) && kill -0 $(cat client.pid)
'
test_expect_success "'ipfs ptp stream ls' succeeds" '
echo "2 /ptp/ptp-test /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
ipfsi 0 ptp stream ls > actual
test_expect_success "'ipfs p2p stream ls' succeeds" '
echo "2 /p2p/p2p-test /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
ipfsi 0 p2p stream ls > actual
'
test_expect_success "'ipfs ptp stream ls' output looks good" '
test_expect_success "'ipfs p2p stream ls' output looks good" '
test_cmp expected actual
'
test_expect_success "'ipfs ptp stream close' closes stream" '
ipfsi 0 ptp stream close 2 &&
ipfsi 0 ptp stream ls > actual &&
test_expect_success "'ipfs p2p stream close' closes stream" '
ipfsi 0 p2p stream close 2 &&
ipfsi 0 p2p stream ls > actual &&
[ ! -f listener.pid ] && [ ! -f client.pid ] &&
test_must_be_empty actual
'
test_expect_success "'ipfs ptp listener close' closes app handler" '
ipfsi 0 ptp listener close ptp-test &&
ipfsi 0 ptp listener ls > actual &&
test_expect_success "'ipfs p2p listener close' closes app handler" '
ipfsi 0 p2p listener close p2p-test &&
ipfsi 0 p2p listener ls > actual &&
test_must_be_empty actual
'
test_expect_success "Setup: Idle stream(2)" '
ma-pipe-unidir --listen --pidFile=listener.pid recv /ip4/127.0.0.1/tcp/10101 &
ipfsi 0 ptp listener open ptp-test2 /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log &&
ipfsi 1 ptp stream dial $PEERID_0 ptp-test2 /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
ipfsi 0 p2p listener open p2p-test2 /ip4/127.0.0.1/tcp/10101 2>&1 > listener-stdouterr.log &&
ipfsi 1 p2p stream dial $PEERID_0 p2p-test2 /ip4/127.0.0.1/tcp/10102 2>&1 > dialer-stdouterr.log &&
ma-pipe-unidir --pidFile=client.pid recv /ip4/127.0.0.1/tcp/10102 &
go-sleep 500ms &&
kill -0 $(cat listener.pid) && kill -0 $(cat client.pid)
'
test_expect_success "'ipfs ptp stream ls' succeeds(2)" '
echo "3 /ptp/ptp-test2 /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
ipfsi 0 ptp stream ls > actual
test_expect_success "'ipfs p2p stream ls' succeeds(2)" '
echo "3 /p2p/p2p-test2 /ip4/127.0.0.1/tcp/10101 $PEERID_1" > expected
ipfsi 0 p2p stream ls > actual
test_cmp expected actual
'
test_expect_success "'ipfs ptp listener close -a' closes app handlers" '
ipfsi 0 ptp listener close -a &&
ipfsi 0 ptp listener ls > actual &&
test_expect_success "'ipfs p2p listener close -a' closes app handlers" '
ipfsi 0 p2p listener close -a &&
ipfsi 0 p2p listener ls > actual &&
test_must_be_empty actual
'
test_expect_success "'ipfs ptp stream close -a' closes streams" '
ipfsi 0 ptp stream close -a &&
ipfsi 0 ptp stream ls > actual &&
test_expect_success "'ipfs p2p stream close -a' closes streams" '
ipfsi 0 p2p stream close -a &&
ipfsi 0 p2p stream ls > actual &&
[ ! -f listener.pid ] && [ ! -f client.pid ] &&
test_must_be_empty actual
'
test_expect_success "'ipfs ptp listener close' closes app numeric handlers" '
ipfsi 0 ptp listener open 1234 /ip4/127.0.0.1/tcp/10101 &&
ipfsi 0 ptp listener close 1234 &&
ipfsi 0 ptp listener ls > actual &&
test_expect_success "'ipfs p2p listener close' closes app numeric handlers" '
ipfsi 0 p2p listener open 1234 /ip4/127.0.0.1/tcp/10101 &&
ipfsi 0 p2p listener close 1234 &&
ipfsi 0 p2p listener ls > actual &&
test_must_be_empty actual
'