Skip to content

Commit

Permalink
Merge pull request ipfs/go-bitswap#445 from ipfs/feat/rw-close
Browse files Browse the repository at this point in the history
feat: update for go-libp2p-core 0.7.0 interface changes

This commit was moved from ipfs/go-bitswap@b4720fa
  • Loading branch information
Stebalien authored Nov 12, 2020
2 parents 86fde29 + f15898f commit 84f3047
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
9 changes: 5 additions & 4 deletions bitswap/internal/sessionmanager/sessionmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sessionmanager

import (
"context"
"fmt"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -118,7 +119,7 @@ func TestReceiveFrom(t *testing.T) {
pm := &fakePeerManager{}
sm := New(ctx, sessionFactory, sim, peerManagerFactory, bpm, pm, notif, "")

p := peer.ID(123)
p := peer.ID(fmt.Sprint(123))
block := blocks.NewBlock([]byte("block"))

firstSession := sm.NewSession(ctx, time.Second, delay.Fixed(time.Minute)).(*fakeSession)
Expand Down Expand Up @@ -165,7 +166,7 @@ func TestReceiveBlocksWhenManagerShutdown(t *testing.T) {
pm := &fakePeerManager{}
sm := New(ctx, sessionFactory, sim, peerManagerFactory, bpm, pm, notif, "")

p := peer.ID(123)
p := peer.ID(fmt.Sprint(123))
block := blocks.NewBlock([]byte("block"))

firstSession := sm.NewSession(ctx, time.Second, delay.Fixed(time.Minute)).(*fakeSession)
Expand Down Expand Up @@ -199,7 +200,7 @@ func TestReceiveBlocksWhenSessionContextCancelled(t *testing.T) {
pm := &fakePeerManager{}
sm := New(ctx, sessionFactory, sim, peerManagerFactory, bpm, pm, notif, "")

p := peer.ID(123)
p := peer.ID(fmt.Sprint(123))
block := blocks.NewBlock([]byte("block"))

firstSession := sm.NewSession(ctx, time.Second, delay.Fixed(time.Minute)).(*fakeSession)
Expand Down Expand Up @@ -235,7 +236,7 @@ func TestShutdown(t *testing.T) {
pm := &fakePeerManager{}
sm := New(ctx, sessionFactory, sim, peerManagerFactory, bpm, pm, notif, "")

p := peer.ID(123)
p := peer.ID(fmt.Sprint(123))
block := blocks.NewBlock([]byte("block"))
cids := []cid.Cid{block.Cid()}
firstSession := sm.NewSession(ctx, time.Second, delay.Fixed(time.Minute)).(*fakeSession)
Expand Down
3 changes: 2 additions & 1 deletion bitswap/internal/testutil/testutil.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package testutil

import (
"fmt"
"math/rand"

bsmsg "github.com/ipfs/go-bitswap/message"
Expand Down Expand Up @@ -59,7 +60,7 @@ func GeneratePeers(n int) []peer.ID {
peerIds := make([]peer.ID, 0, n)
for i := 0; i < n; i++ {
peerSeq++
p := peer.ID(peerSeq)
p := peer.ID(fmt.Sprint(i))
peerIds = append(peerIds, p)
}
return peerIds
Expand Down
6 changes: 1 addition & 5 deletions bitswap/network/ipfs_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
cid "github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p-core/connmgr"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
Expand Down Expand Up @@ -132,7 +131,7 @@ func (s *streamMessageSender) Reset() error {

// Close the stream
func (s *streamMessageSender) Close() error {
return helpers.FullClose(s.stream)
return s.stream.Close()
}

// Indicates whether the peer supports HAVE / DONT_HAVE messages
Expand Down Expand Up @@ -323,9 +322,6 @@ func (bsnet *impl) SendMessage(
return err
}

// TODO(https://github.com/libp2p/go-libp2p-net/issues/28): Avoid this goroutine.
//nolint
go helpers.AwaitEOF(s)
return s.Close()
}

Expand Down

0 comments on commit 84f3047

Please sign in to comment.