Unverified Commit 963dc8fd authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #474 from coryschwartz/feat/fix-staticcheck

fix staticcheck
parents 0fa39758 f4fae3a4
...@@ -12,7 +12,6 @@ import ( ...@@ -12,7 +12,6 @@ import (
deciface "github.com/ipfs/go-bitswap/decision" deciface "github.com/ipfs/go-bitswap/decision"
decision "github.com/ipfs/go-bitswap/internal/decision" decision "github.com/ipfs/go-bitswap/internal/decision"
bssession "github.com/ipfs/go-bitswap/internal/session" bssession "github.com/ipfs/go-bitswap/internal/session"
"github.com/ipfs/go-bitswap/message"
bsmsg "github.com/ipfs/go-bitswap/message" bsmsg "github.com/ipfs/go-bitswap/message"
pb "github.com/ipfs/go-bitswap/message/pb" pb "github.com/ipfs/go-bitswap/message/pb"
testinstance "github.com/ipfs/go-bitswap/testinstance" testinstance "github.com/ipfs/go-bitswap/testinstance"
...@@ -149,7 +148,7 @@ func TestUnwantedBlockNotAdded(t *testing.T) { ...@@ -149,7 +148,7 @@ func TestUnwantedBlockNotAdded(t *testing.T) {
net := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(kNetworkDelay)) net := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(kNetworkDelay))
block := blocks.NewBlock([]byte("block")) block := blocks.NewBlock([]byte("block"))
bsMessage := message.New(true) bsMessage := bsmsg.New(true)
bsMessage.AddBlock(block) bsMessage.AddBlock(block)
ig := testinstance.NewTestInstanceGenerator(net, nil, nil) ig := testinstance.NewTestInstanceGenerator(net, nil, nil)
...@@ -215,7 +214,7 @@ func TestPendingBlockAdded(t *testing.T) { ...@@ -215,7 +214,7 @@ func TestPendingBlockAdded(t *testing.T) {
// Simulate receiving a message which contains the block in the "tofetch" queue // Simulate receiving a message which contains the block in the "tofetch" queue
lastBlock := blks[len(blks)-1] lastBlock := blks[len(blks)-1]
bsMessage := message.New(true) bsMessage := bsmsg.New(true)
bsMessage.AddBlock(lastBlock) bsMessage.AddBlock(lastBlock)
unknownPeer := peer.ID("QmUHfvCQrzyR6vFXmeyCptfCWedfcmfa12V6UuziDtrw23") unknownPeer := peer.ID("QmUHfvCQrzyR6vFXmeyCptfCWedfcmfa12V6UuziDtrw23")
instance.Exchange.ReceiveMessage(oneSecCtx, unknownPeer, bsMessage) instance.Exchange.ReceiveMessage(oneSecCtx, unknownPeer, bsMessage)
......
...@@ -183,10 +183,9 @@ func peerIsPartner(p peer.ID, e *Engine) bool { ...@@ -183,10 +183,9 @@ func peerIsPartner(p peer.ID, e *Engine) bool {
} }
func TestOutboxClosedWhenEngineClosed(t *testing.T) { func TestOutboxClosedWhenEngineClosed(t *testing.T) {
ctx := context.Background()
t.SkipNow() // TODO implement *Engine.Close t.SkipNow() // TODO implement *Engine.Close
e := newEngine(blockstore.NewBlockstore(dssync.MutexWrap(ds.NewMapDatastore())), 4, &fakePeerTagger{}, "localhost", 0, NewTestScoreLedger(shortTerm, nil)) e := newEngine(blockstore.NewBlockstore(dssync.MutexWrap(ds.NewMapDatastore())), 4, &fakePeerTagger{}, "localhost", 0, NewTestScoreLedger(shortTerm, nil))
e.StartWorkers(ctx, process.WithTeardown(func() error { return nil })) e.StartWorkers(context.Background(), process.WithTeardown(func() error { return nil }))
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
go func() { go func() {
......
...@@ -9,7 +9,6 @@ import ( ...@@ -9,7 +9,6 @@ import (
bsmsg "github.com/ipfs/go-bitswap/message" bsmsg "github.com/ipfs/go-bitswap/message"
pb "github.com/ipfs/go-bitswap/message/pb" pb "github.com/ipfs/go-bitswap/message/pb"
bsnet "github.com/ipfs/go-bitswap/network" bsnet "github.com/ipfs/go-bitswap/network"
"github.com/ipfs/go-bitswap/wantlist"
bswl "github.com/ipfs/go-bitswap/wantlist" bswl "github.com/ipfs/go-bitswap/wantlist"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
...@@ -142,7 +141,7 @@ func (r *recallWantlist) RemoveType(c cid.Cid, wtype pb.Message_Wantlist_WantTyp ...@@ -142,7 +141,7 @@ func (r *recallWantlist) RemoveType(c cid.Cid, wtype pb.Message_Wantlist_WantTyp
// //
// Returns true if the want was marked as sent. Returns false if the want wasn't // Returns true if the want was marked as sent. Returns false if the want wasn't
// pending. // pending.
func (r *recallWantlist) MarkSent(e wantlist.Entry) bool { func (r *recallWantlist) MarkSent(e bswl.Entry) bool {
if !r.pending.RemoveType(e.Cid, e.WantType) { if !r.pending.RemoveType(e.Cid, e.WantType) {
return false return false
} }
......
...@@ -10,7 +10,6 @@ import ( ...@@ -10,7 +10,6 @@ import (
"time" "time"
"github.com/ipfs/go-bitswap/internal/testutil" "github.com/ipfs/go-bitswap/internal/testutil"
"github.com/ipfs/go-bitswap/message"
pb "github.com/ipfs/go-bitswap/message/pb" pb "github.com/ipfs/go-bitswap/message/pb"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
...@@ -251,7 +250,7 @@ func TestSendingMessagesPriority(t *testing.T) { ...@@ -251,7 +250,7 @@ func TestSendingMessagesPriority(t *testing.T) {
if totalEntriesLength(messages) != len(wantHaves)+len(wantBlocks) { if totalEntriesLength(messages) != len(wantHaves)+len(wantBlocks) {
t.Fatal("wrong number of wants") t.Fatal("wrong number of wants")
} }
byCid := make(map[cid.Cid]message.Entry) byCid := make(map[cid.Cid]bsmsg.Entry)
for _, entry := range messages[0] { for _, entry := range messages[0] {
byCid[entry.Cid] = entry byCid[entry.Cid] = entry
} }
......
...@@ -67,7 +67,7 @@ func (r *receiver) PeerDisconnected(p peer.ID) { ...@@ -67,7 +67,7 @@ func (r *receiver) PeerDisconnected(p peer.ID) {
r.connectionEvent <- false r.connectionEvent <- false
} }
var mockNetErr = fmt.Errorf("network err") var errMockNetErr = fmt.Errorf("network err")
type ErrStream struct { type ErrStream struct {
network.Stream network.Stream
...@@ -115,7 +115,7 @@ func (eh *ErrHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID ...@@ -115,7 +115,7 @@ func (eh *ErrHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID
defer eh.lk.Unlock() defer eh.lk.Unlock()
if eh.err != nil { if eh.err != nil {
return nil, mockNetErr return nil, errMockNetErr
} }
if eh.timingOut { if eh.timingOut {
return nil, context.DeadlineExceeded return nil, context.DeadlineExceeded
...@@ -337,7 +337,7 @@ func TestMessageResendAfterError(t *testing.T) { ...@@ -337,7 +337,7 @@ func TestMessageResendAfterError(t *testing.T) {
// Return an error from the networking layer the next time we try to send // Return an error from the networking layer the next time we try to send
// a message // a message
eh.setError(mockNetErr) eh.setError(errMockNetErr)
go func() { go func() {
time.Sleep(testSendErrorBackoff / 2) time.Sleep(testSendErrorBackoff / 2)
......
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