From 2f0ae0c5a78a4e7d28fe072fc36ec67842ad8b6f Mon Sep 17 00:00:00 2001 From: Cole Brown Date: Mon, 1 Oct 2018 17:37:16 -0400 Subject: [PATCH] Update tests to use new api --- test/integration_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/integration_test.go b/test/integration_test.go index 8f3687f..11f8d11 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -1,7 +1,6 @@ package test import ( - "bytes" "context" "io" "io/ioutil" @@ -11,7 +10,7 @@ import ( "github.com/libp2p/go-libp2p-daemon" "github.com/libp2p/go-libp2p-daemon/p2pclient" - pb "github.com/libp2p/go-libp2p-daemon/pb" + peer "github.com/libp2p/go-libp2p-peer" ma "github.com/multiformats/go-multiaddr" ) @@ -49,7 +48,7 @@ func TestIdentify(t *testing.T) { if err != nil { t.Fatal(err) } - if !bytes.Equal(cid, []byte(d.ID())) { + if cid != d.ID() { t.Fatal("peer id not equal to query result") } daddrs := d.Addrs() @@ -68,7 +67,7 @@ func TestIdentify(t *testing.T) { } func connect(c *p2pclient.Client, d *p2pd.Daemon) error { - return c.Connect([]byte(d.ID()), d.Addrs()) + return c.Connect(d.ID(), d.Addrs()) } func TestConnect(t *testing.T) { @@ -82,7 +81,7 @@ func TestConnect(t *testing.T) { if err := connect(c2, d1); err != nil { t.Fatal(err) } - if err := c1.Connect([]byte("foobar"), d2.Addrs()); err == nil { + if err := c1.Connect(peer.ID("foobar"), d2.Addrs()); err == nil { t.Fatal("expected connection to invalid peer id to fail") } } @@ -94,7 +93,7 @@ func TestConnectFailsOnBadAddress(t *testing.T) { defer closer2() addr, _ := ma.NewMultiaddr("/ip4/1.2.3.4/tcp/4000") addrs := []ma.Multiaddr{addr} - if err := c1.Connect([]byte(d2.ID()), addrs); err == nil { + if err := c1.Connect(d2.ID(), addrs); err == nil { t.Fatal("expected connection to invalid address to fail") } } @@ -110,7 +109,7 @@ func TestStreams(t *testing.T) { testprotos := []string{"/test"} done := make(chan struct{}) - c1.NewStreamHandler(testprotos, func(info *pb.StreamInfo, conn io.ReadWriteCloser) { + c1.NewStreamHandler(testprotos, func(info *p2pclient.StreamInfo, conn io.ReadWriteCloser) { defer conn.Close() var buf []byte n, err := conn.Read(buf) @@ -123,7 +122,7 @@ func TestStreams(t *testing.T) { done <- struct{}{} }) - _, conn, err := c2.NewStream([]byte(d1.ID()), testprotos) + _, conn, err := c2.NewStream(d1.ID(), testprotos) if err != nil { t.Fatal(err) }