Commit 30c7cfd7 authored by Jeromy's avatar Jeromy

implement GetStreams

parent 8838b1c2
...@@ -69,9 +69,9 @@ ...@@ -69,9 +69,9 @@
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmNbLFRGG1uHVfQM2fRFrhc7dgjThXkYUAp5qChFqxYNSH", "hash": "QmUQhsqvLehBDWjFq3C3nT6ZkGEsdPWSzxV6sNAzjRMfQQ",
"name": "go-peerstream", "name": "go-peerstream",
"version": "1.3.0" "version": "1.4.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
......
...@@ -92,7 +92,13 @@ func (c *Conn) Close() error { ...@@ -92,7 +92,13 @@ func (c *Conn) Close() error {
} }
func (c *Conn) GetStreams() ([]inet.Stream, error) { func (c *Conn) GetStreams() ([]inet.Stream, error) {
return nil, fmt.Errorf("GetStreams() not yet implemented") ss := c.StreamConn().Streams()
out := make([]inet.Stream, len(ss))
for i, s := range ss {
out[i] = (*Stream)(s)
}
return out, nil
} }
func wrapConn(psc *ps.Conn) (*Conn, error) { func wrapConn(psc *ps.Conn) (*Conn, error) {
......
...@@ -165,6 +165,15 @@ func TestNetworkOpenStream(t *testing.T) { ...@@ -165,6 +165,15 @@ func TestNetworkOpenStream(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
streams, err := nets[0].ConnsToPeer(nets[1].LocalPeer())[0].GetStreams()
if err != nil {
t.Fatal(err)
}
if len(streams) != 1 {
t.Fatal("should only have one stream there")
}
_, err = s.Write([]byte("hello ipfs")) _, err = s.Write([]byte("hello ipfs"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment