Repository: ipfs/go-bitswap
Pull request #485 (2021-05-12 01:51:50)

sync: update CI config files
Syncing to commit https://github.com/protocol/.github/commit/c444802439eae549ab950774e3743c13a2e7a17d.

welcome[bot]: Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  * The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  * Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the [code contribution
    guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md#code-contribution-guidelines)
    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  * A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  * The PR gets reviews, discussed and approvals as needed.

  * The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within **two business days**. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

marten-seemann: Tests failing due to #481.

We'll also have to disable CircleCI for this repo.
Stebalien: I'm going to just disable that test.
Stebalien: Nevermind. I'm updating my expectation on fixing these tests to 1 (maybe 2) days of head scratching. Luckily, _most_ of this head scratching can be done by just about anyone.
BigLep: @coryschwartz : I'm working to get you access to this repo so I can assign this issue to you, but we want this to get merged during your rotation.  Any flaky tests that you need to disable, can you create tracking issues for and add to https://github.com/ipfs/go-bitswap/issues/493 if they aren't already there?
coryschwartz: I broke up the big TestWantlistRebroadcast test, which was flaky.
It passes now. There were multiple tests going on there and there might have been something goin on with the timing and rebroadcast intervals that was making it work inconstently. 

```
◉ go test -count 1000 -run  TestWantlistRebroadcastBroadcastsAllWanthaves -run TestWantlistRebroadcastBroadcastInterval -run TestWantlistRebroadcastCancels
PASS
ok      github.com/ipfs/go-bitswap/internal/messagequeue        10.934s
```


Patch:
diff --git a/.circleci/config.yml b/.circleci/config.yml
deleted file mode 100644
index 3b31955..0000000
--- a/.circleci/config.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-version: 2.1
-orbs:
-  ci-go: ipfs/ci-go@0.2.9
-
-workflows:
-  version: 2
-  test:
-    jobs:
-      - ci-go/build
-      - ci-go/lint
-      - ci-go/test
-      - ci-go/test:
-          race: true
-          name: "ci-go/test/race"
-      #- ci-go/benchmark:
-      #    tolerance: 50
-      #    requires:
-      #      - ci-go/test
diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml
new file mode 100644
index 0000000..32bcc2e
--- /dev/null
+++ b/.github/workflows/automerge.yml
@@ -0,0 +1,51 @@
+# File managed by web3-bot. DO NOT EDIT.
+# See https://github.com/protocol/.github/ for details.
+
+# Automatically merge pull requests opened by web3-bot, as soon as (and only if) all tests pass.
+# This reduces the friction associated with updating with our workflows.
+
+on: [ pull_request ]
+name: Automerge
+
+jobs:
+  automerge-check:
+    if: github.event.pull_request.user.login == 'web3-bot'
+    runs-on: ubuntu-latest
+    outputs:
+      status: ${{ steps.should-automerge.outputs.status }}
+    steps:
+    - uses: actions/checkout@v2
+      with:
+        fetch-depth: 0
+    - name: Check if we should automerge
+      id: should-automerge
+      run: |
+        for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do
+          committer=$(git show --format=$'%ce' -s $commit)
+          echo "Committer: $committer"
+          if [[ "$committer" != "web3-bot@users.noreply.github.com" ]]; then
+            echo "Commit $commit wasn't committed by web3-bot, but by $committer."
+            echo "::set-output name=status::false"
+            exit
+          fi
+        done
+        echo "::set-output name=status::true"
+  automerge:
+    needs: automerge-check
+    runs-on: ubuntu-latest
+    if: ${{ needs.automerge-check.outputs.status == 'true' }}
+    steps:
+    - name: Wait on tests
+      uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2
+      with:
+        ref: ${{ github.event.pull_request.head.sha }}
+        repo-token: ${{ secrets.GITHUB_TOKEN }}
+        wait-interval: 10
+        running-workflow-name: 'automerge' # the name of this job
+    - name: Merge PR
+      uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1
+      env:
+        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
+        MERGE_LABELS: ""
+        MERGE_METHOD: "squash"
+        MERGE_DELETE_BRANCH: true
diff --git a/.github/workflows/go-check.yml b/.github/workflows/go-check.yml
new file mode 100644
index 0000000..00ce947
--- /dev/null
+++ b/.github/workflows/go-check.yml
@@ -0,0 +1,50 @@
+# File managed by web3-bot. DO NOT EDIT.
+# See https://github.com/protocol/.github/ for details.
+
+on: [push, pull_request]
+name: Go Checks
+
+jobs:
+  unit:
+    runs-on: ubuntu-latest
+    name: All
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          submodules: recursive
+      - uses: actions/setup-go@v2
+        with:
+          go-version: "1.16.x"
+      - name: Install staticcheck
+        run: go install honnef.co/go/tools/cmd/staticcheck@434f5f3816b358fe468fa83dcba62d794e7fe04b # 2021.1 (v0.2.0)
+      - name: Check that go.mod is tidy
+        uses: protocol/multiple-go-modules@v1.0
+        with:
+          run: |
+            go mod tidy
+            if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
+              echo "go.sum was added by go mod tidy"
+              exit 1
+            fi
+            git diff --exit-code -- go.sum go.mod
+      - name: gofmt
+        if: ${{ success() || failure() }} # run this step even if the previous one failed
+        run: |
+          out=$(gofmt -s -l .)
+          if [[ -n "$out" ]]; then
+            echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
+            exit 1
+          fi
+      - name: go vet
+        if: ${{ success() || failure() }} # run this step even if the previous one failed
+        uses: protocol/multiple-go-modules@v1.0
+        with:
+          run: go vet ./...
+      - name: staticcheck
+        if: ${{ success() || failure() }} # run this step even if the previous one failed
+        uses: protocol/multiple-go-modules@v1.0
+        with:
+          run: |
+            set -o pipefail
+            staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
+
diff --git a/bitswap.go b/bitswap.go
index 0297c09..b7f763d 100644
--- a/bitswap.go
+++ b/bitswap.go
@@ -183,13 +183,13 @@ func New(parent context.Context, network bsnet.BitSwapNetwork,
 	sm = bssm.New(ctx, sessionFactory, sim, sessionPeerManagerFactory, bpm, pm, notif, network.Self())
 
 	bs := &Bitswap{
-		blockstore:       bstore,
-		network:          network,
-		process:          px,
-		newBlocks:        make(chan cid.Cid, HasBlockBufferSize),
-		provideKeys:      make(chan cid.Cid, provideKeysBufferSize),
-		pm:               pm,
-		pqm:              pqm,
+		blockstore:              bstore,
+		network:                 network,
+		process:                 px,
+		newBlocks:               make(chan cid.Cid, HasBlockBufferSize),
+		provideKeys:             make(chan cid.Cid, provideKeysBufferSize),
+		pm:                      pm,
+		pqm:                     pqm,
 		sm:                      sm,
 		sim:                     sim,
 		notif:                   notif,
diff --git a/go.mod b/go.mod
index 54eb143..faa0386 100644
--- a/go.mod
+++ b/go.mod
@@ -30,4 +30,4 @@ require (
 	go.uber.org/zap v1.16.0
 )
 
-go 1.12
+go 1.15
diff --git a/internal/decision/engine.go b/internal/decision/engine.go
index 6e69ca6..6950f59 100644
--- a/internal/decision/engine.go
+++ b/internal/decision/engine.go
@@ -163,7 +163,7 @@ type Engine struct {
 
 	sendDontHaves bool
 
-	self                  peer.ID
+	self peer.ID
 }
 
 // NewEngine creates a new block sending engine for the given block store


Test patch:
diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml
new file mode 100644
index 0000000..4c7138b
--- /dev/null
+++ b/.github/workflows/go-test.yml
@@ -0,0 +1,47 @@
+# File managed by web3-bot. DO NOT EDIT.
+# See https://github.com/protocol/.github/ for details.
+
+on: [push, pull_request]
+name: Go Test
+
+jobs:
+  unit:
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ "ubuntu", "windows", "macos" ]
+        go: [ "1.15.x", "1.16.x" ]
+    runs-on: ${{ matrix.os }}-latest
+    name: ${{ matrix.os}} (go ${{ matrix.go }})
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          submodules: recursive
+      - uses: actions/setup-go@v2
+        with:
+          go-version: ${{ matrix.go }}
+      - name: Go information
+        run: |
+          go version
+          go env
+      - name: Run tests
+        uses: protocol/multiple-go-modules@v1.0
+        with:
+          run: go test -v -coverprofile coverage.txt ./...
+      - name: Run tests (32 bit)
+        if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
+        uses: protocol/multiple-go-modules@v1.0
+        env:
+          GOARCH: 386
+        with:
+          run: go test -v ./...
+      - name: Run tests with race detector
+        if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
+        uses: protocol/multiple-go-modules@v1.0
+        with:
+          run: go test -v -race ./...
+      - name: Upload coverage to Codecov
+        uses: codecov/codecov-action@a1ed4b322b4b38cb846afb5a0ebfa17086917d27 # v1.5.0
+        with:
+          file: coverage.txt
+          env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}
diff --git a/benchmarks_test.go b/benchmarks_test.go
index d3aaf04..dd4cf5b 100644
--- a/benchmarks_test.go
+++ b/benchmarks_test.go
@@ -19,9 +19,9 @@ import (
 
 	bitswap "github.com/ipfs/go-bitswap"
 	bssession "github.com/ipfs/go-bitswap/internal/session"
+	bsnet "github.com/ipfs/go-bitswap/network"
 	testinstance "github.com/ipfs/go-bitswap/testinstance"
 	tn "github.com/ipfs/go-bitswap/testnet"
-	bsnet "github.com/ipfs/go-bitswap/network"
 	cid "github.com/ipfs/go-cid"
 	delay "github.com/ipfs/go-ipfs-delay"
 	mockrouting "github.com/ipfs/go-ipfs-routing/mock"
@@ -53,14 +53,14 @@ type bench struct {
 var benches = []bench{
 	// Fetch from two seed nodes that both have all 100 blocks
 	// - request one at a time, in series
-	bench{"3Nodes-AllToAll-OneAtATime", 3, 100, allToAll, oneAtATime},
+	{"3Nodes-AllToAll-OneAtATime", 3, 100, allToAll, oneAtATime},
 	// - request all 100 with a single GetBlocks() call
-	bench{"3Nodes-AllToAll-BigBatch", 3, 100, allToAll, batchFetchAll},
+	{"3Nodes-AllToAll-BigBatch", 3, 100, allToAll, batchFetchAll},
 
 	// Fetch from two seed nodes, one at a time, where:
 	// - node A has blocks 0 - 74
 	// - node B has blocks 25 - 99
-	bench{"3Nodes-Overlap1-OneAtATime", 3, 100, overlap1, oneAtATime},
+	{"3Nodes-Overlap1-OneAtATime", 3, 100, overlap1, oneAtATime},
 
 	// Fetch from two seed nodes, where:
 	// - node A has even blocks
@@ -68,40 +68,40 @@ var benches = []bench{
 	// - both nodes have every third block
 
 	// - request one at a time, in series
-	bench{"3Nodes-Overlap3-OneAtATime", 3, 100, overlap2, oneAtATime},
+	{"3Nodes-Overlap3-OneAtATime", 3, 100, overlap2, oneAtATime},
 	// - request 10 at a time, in series
-	bench{"3Nodes-Overlap3-BatchBy10", 3, 100, overlap2, batchFetchBy10},
+	{"3Nodes-Overlap3-BatchBy10", 3, 100, overlap2, batchFetchBy10},
 	// - request all 100 in parallel as individual GetBlock() calls
-	bench{"3Nodes-Overlap3-AllConcurrent", 3, 100, overlap2, fetchAllConcurrent},
+	{"3Nodes-Overlap3-AllConcurrent", 3, 100, overlap2, fetchAllConcurrent},
 	// - request all 100 with a single GetBlocks() call
-	bench{"3Nodes-Overlap3-BigBatch", 3, 100, overlap2, batchFetchAll},
+	{"3Nodes-Overlap3-BigBatch", 3, 100, overlap2, batchFetchAll},
 	// - request 1, then 10, then 89 blocks (similar to how IPFS would fetch a file)
-	bench{"3Nodes-Overlap3-UnixfsFetch", 3, 100, overlap2, unixfsFileFetch},
+	{"3Nodes-Overlap3-UnixfsFetch", 3, 100, overlap2, unixfsFileFetch},
 
 	// Fetch from nine seed nodes, all nodes have all blocks
 	// - request one at a time, in series
-	bench{"10Nodes-AllToAll-OneAtATime", 10, 100, allToAll, oneAtATime},
+	{"10Nodes-AllToAll-OneAtATime", 10, 100, allToAll, oneAtATime},
 	// - request 10 at a time, in series
-	bench{"10Nodes-AllToAll-BatchFetchBy10", 10, 100, allToAll, batchFetchBy10},
+	{"10Nodes-AllToAll-BatchFetchBy10", 10, 100, allToAll, batchFetchBy10},
 	// - request all 100 with a single GetBlocks() call
-	bench{"10Nodes-AllToAll-BigBatch", 10, 100, allToAll, batchFetchAll},
+	{"10Nodes-AllToAll-BigBatch", 10, 100, allToAll, batchFetchAll},
 	// - request all 100 in parallel as individual GetBlock() calls
-	bench{"10Nodes-AllToAll-AllConcurrent", 10, 100, allToAll, fetchAllConcurrent},
+	{"10Nodes-AllToAll-AllConcurrent", 10, 100, allToAll, fetchAllConcurrent},
 	// - request 1, then 10, then 89 blocks (similar to how IPFS would fetch a file)
-	bench{"10Nodes-AllToAll-UnixfsFetch", 10, 100, allToAll, unixfsFileFetch},
+	{"10Nodes-AllToAll-UnixfsFetch", 10, 100, allToAll, unixfsFileFetch},
 	// - follow a typical IPFS request pattern for 1000 blocks
-	bench{"10Nodes-AllToAll-UnixfsFetchLarge", 10, 1000, allToAll, unixfsFileFetchLarge},
+	{"10Nodes-AllToAll-UnixfsFetchLarge", 10, 1000, allToAll, unixfsFileFetchLarge},
 
 	// Fetch from nine seed nodes, blocks are distributed randomly across all nodes (no dups)
 	// - request one at a time, in series
-	bench{"10Nodes-OnePeerPerBlock-OneAtATime", 10, 100, onePeerPerBlock, oneAtATime},
+	{"10Nodes-OnePeerPerBlock-OneAtATime", 10, 100, onePeerPerBlock, oneAtATime},
 	// - request all 100 with a single GetBlocks() call
-	bench{"10Nodes-OnePeerPerBlock-BigBatch", 10, 100, onePeerPerBlock, batchFetchAll},
+	{"10Nodes-OnePeerPerBlock-BigBatch", 10, 100, onePeerPerBlock, batchFetchAll},
 	// - request 1, then 10, then 89 blocks (similar to how IPFS would fetch a file)
-	bench{"10Nodes-OnePeerPerBlock-UnixfsFetch", 10, 100, onePeerPerBlock, unixfsFileFetch},
+	{"10Nodes-OnePeerPerBlock-UnixfsFetch", 10, 100, onePeerPerBlock, unixfsFileFetch},
 
 	// Fetch from 199 seed nodes, all nodes have all blocks, fetch all 20 blocks with a single GetBlocks() call
-	bench{"200Nodes-AllToAll-BigBatch", 200, 20, allToAll, batchFetchAll},
+	{"200Nodes-AllToAll-BigBatch", 200, 20, allToAll, batchFetchAll},
 }
 
 func BenchmarkFixedDelay(b *testing.B) {
@@ -127,9 +127,9 @@ type mixedBench struct {
 }
 
 var mixedBenches = []mixedBench{
-	mixedBench{bench{"3Nodes-Overlap3-OneAtATime", 3, 10, overlap2, oneAtATime}, 1, 2},
-	mixedBench{bench{"3Nodes-AllToAll-OneAtATime", 3, 10, allToAll, oneAtATime}, 1, 2},
-	mixedBench{bench{"3Nodes-Overlap3-AllConcurrent", 3, 10, overlap2, fetchAllConcurrent}, 1, 2},
+	{bench{"3Nodes-Overlap3-OneAtATime", 3, 10, overlap2, oneAtATime}, 1, 2},
+	{bench{"3Nodes-AllToAll-OneAtATime", 3, 10, allToAll, oneAtATime}, 1, 2},
+	{bench{"3Nodes-Overlap3-AllConcurrent", 3, 10, overlap2, fetchAllConcurrent}, 1, 2},
 	// mixedBench{bench{"3Nodes-Overlap3-UnixfsFetch", 3, 100, overlap2, unixfsFileFetch}, 1, 2},
 }
 
diff --git a/internal/blockpresencemanager/blockpresencemanager_test.go b/internal/blockpresencemanager/blockpresencemanager_test.go
index 579dbfc..0d65c45 100644
--- a/internal/blockpresencemanager/blockpresencemanager_test.go
+++ b/internal/blockpresencemanager/blockpresencemanager_test.go
@@ -208,24 +208,24 @@ func TestAllPeersDoNotHaveBlock(t *testing.T) {
 	}
 
 	testcases := []testcase{
-		testcase{[]peer.ID{p0}, []cid.Cid{c0}, []cid.Cid{}},
-		testcase{[]peer.ID{p1}, []cid.Cid{c0}, []cid.Cid{c0}},
-		testcase{[]peer.ID{p2}, []cid.Cid{c0}, []cid.Cid{}},
+		{[]peer.ID{p0}, []cid.Cid{c0}, []cid.Cid{}},
+		{[]peer.ID{p1}, []cid.Cid{c0}, []cid.Cid{c0}},
+		{[]peer.ID{p2}, []cid.Cid{c0}, []cid.Cid{}},
 
-		testcase{[]peer.ID{p0}, []cid.Cid{c1}, []cid.Cid{c1}},
-		testcase{[]peer.ID{p1}, []cid.Cid{c1}, []cid.Cid{}},
-		testcase{[]peer.ID{p2}, []cid.Cid{c1}, []cid.Cid{}},
+		{[]peer.ID{p0}, []cid.Cid{c1}, []cid.Cid{c1}},
+		{[]peer.ID{p1}, []cid.Cid{c1}, []cid.Cid{}},
+		{[]peer.ID{p2}, []cid.Cid{c1}, []cid.Cid{}},
 
-		testcase{[]peer.ID{p0}, []cid.Cid{c2}, []cid.Cid{c2}},
-		testcase{[]peer.ID{p1}, []cid.Cid{c2}, []cid.Cid{}},
-		testcase{[]peer.ID{p2}, []cid.Cid{c2}, []cid.Cid{c2}},
+		{[]peer.ID{p0}, []cid.Cid{c2}, []cid.Cid{c2}},
+		{[]peer.ID{p1}, []cid.Cid{c2}, []cid.Cid{}},
+		{[]peer.ID{p2}, []cid.Cid{c2}, []cid.Cid{c2}},
 
 		// p0 recieved DONT_HAVE for c1 & c2 (but not for c0)
-		testcase{[]peer.ID{p0}, []cid.Cid{c0, c1, c2}, []cid.Cid{c1, c2}},
-		testcase{[]peer.ID{p0, p1}, []cid.Cid{c0, c1, c2}, []cid.Cid{}},
+		{[]peer.ID{p0}, []cid.Cid{c0, c1, c2}, []cid.Cid{c1, c2}},
+		{[]peer.ID{p0, p1}, []cid.Cid{c0, c1, c2}, []cid.Cid{}},
 		// Both p0 and p2 received DONT_HAVE for c2
-		testcase{[]peer.ID{p0, p2}, []cid.Cid{c0, c1, c2}, []cid.Cid{c2}},
-		testcase{[]peer.ID{p0, p1, p2}, []cid.Cid{c0, c1, c2}, []cid.Cid{}},
+		{[]peer.ID{p0, p2}, []cid.Cid{c0, c1, c2}, []cid.Cid{c2}},
+		{[]peer.ID{p0, p1, p2}, []cid.Cid{c0, c1, c2}, []cid.Cid{}},
 	}
 
 	for i, tc := range testcases {
diff --git a/internal/decision/engine_test.go b/internal/decision/engine_test.go
index 2cf9e77..ac370d0 100644
--- a/internal/decision/engine_test.go
+++ b/internal/decision/engine_test.go
@@ -236,31 +236,31 @@ func TestPartnerWantHaveWantBlockNonActive(t *testing.T) {
 
 	testCases := []testCase{
 		// Just send want-blocks
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     vowels,
 					sendDontHave: false,
 				},
 			},
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks: vowels,
 				},
 			},
 		},
 
 		// Send want-blocks and want-haves
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     vowels,
 					wantHaves:    "fgh",
 					sendDontHave: false,
 				},
 			},
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks:  vowels,
 					haves: "fgh",
 				},
@@ -269,16 +269,16 @@ func TestPartnerWantHaveWantBlockNonActive(t *testing.T) {
 
 		// Send want-blocks and want-haves, with some want-haves that are not
 		// present, but without requesting DONT_HAVES
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     vowels,
 					wantHaves:    "fgh123",
 					sendDontHave: false,
 				},
 			},
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks:  vowels,
 					haves: "fgh",
 				},
@@ -287,16 +287,16 @@ func TestPartnerWantHaveWantBlockNonActive(t *testing.T) {
 
 		// Send want-blocks and want-haves, with some want-haves that are not
 		// present, and request DONT_HAVES
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     vowels,
 					wantHaves:    "fgh123",
 					sendDontHave: true,
 				},
 			},
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks:      vowels,
 					haves:     "fgh",
 					dontHaves: "123",
@@ -306,16 +306,16 @@ func TestPartnerWantHaveWantBlockNonActive(t *testing.T) {
 
 		// Send want-blocks and want-haves, with some want-blocks and want-haves that are not
 		// present, but without requesting DONT_HAVES
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     "aeiou123",
 					wantHaves:    "fgh456",
 					sendDontHave: false,
 				},
 			},
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks:      "aeiou",
 					haves:     "fgh",
 					dontHaves: "",
@@ -325,16 +325,16 @@ func TestPartnerWantHaveWantBlockNonActive(t *testing.T) {
 
 		// Send want-blocks and want-haves, with some want-blocks and want-haves that are not
 		// present, and request DONT_HAVES
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     "aeiou123",
 					wantHaves:    "fgh456",
 					sendDontHave: true,
 				},
 			},
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks:      "aeiou",
 					haves:     "fgh",
 					dontHaves: "123456",
@@ -343,48 +343,48 @@ func TestPartnerWantHaveWantBlockNonActive(t *testing.T) {
 		},
 
 		// Send repeated want-blocks
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     "ae",
 					sendDontHave: false,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "io",
 					sendDontHave: false,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "u",
 					sendDontHave: false,
 				},
 			},
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks: "aeiou",
 				},
 			},
 		},
 
 		// Send repeated want-blocks and want-haves
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     "ae",
 					wantHaves:    "jk",
 					sendDontHave: false,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "io",
 					wantHaves:    "lm",
 					sendDontHave: false,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "u",
 					sendDontHave: false,
 				},
 			},
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks:  "aeiou",
 					haves: "jklm",
 				},
@@ -393,26 +393,26 @@ func TestPartnerWantHaveWantBlockNonActive(t *testing.T) {
 
 		// Send repeated want-blocks and want-haves, with some want-blocks and want-haves that are not
 		// present, and request DONT_HAVES
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     "ae12",
 					wantHaves:    "jk5",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "io34",
 					wantHaves:    "lm",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "u",
 					wantHaves:    "6",
 					sendDontHave: true,
 				},
 			},
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks:      "aeiou",
 					haves:     "jklm",
 					dontHaves: "123456",
@@ -421,13 +421,13 @@ func TestPartnerWantHaveWantBlockNonActive(t *testing.T) {
 		},
 
 		// Send want-block then want-have for same CID
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     "a",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantHaves:    "a",
 					sendDontHave: true,
 				},
@@ -435,67 +435,67 @@ func TestPartnerWantHaveWantBlockNonActive(t *testing.T) {
 			// want-have should be ignored because there was already a
 			// want-block for the same CID in the queue
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks: "a",
 				},
 			},
 		},
 
 		// Send want-have then want-block for same CID
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantHaves:    "b",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "b",
 					sendDontHave: true,
 				},
 			},
 			// want-block should overwrite existing want-have
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks: "b",
 				},
 			},
 		},
 
 		// Send want-block then want-block for same CID
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     "a",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "a",
 					sendDontHave: true,
 				},
 			},
 			// second want-block should be ignored
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks: "a",
 				},
 			},
 		},
 
 		// Send want-have then want-have for same CID
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantHaves:    "a",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantHaves:    "a",
 					sendDontHave: true,
 				},
 			},
 			// second want-have should be ignored
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					haves: "a",
 				},
 			},
@@ -573,13 +573,13 @@ func TestPartnerWantHaveWantBlockActive(t *testing.T) {
 
 	testCases := []testCase{
 		// Send want-block then want-have for same CID
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     "a",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantHaves:    "a",
 					sendDontHave: true,
 				},
@@ -587,20 +587,20 @@ func TestPartnerWantHaveWantBlockActive(t *testing.T) {
 			// want-have should be ignored because there was already a
 			// want-block for the same CID in the queue
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks: "a",
 				},
 			},
 		},
 
 		// Send want-have then want-block for same CID
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantHaves:    "b",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "b",
 					sendDontHave: true,
 				},
@@ -608,50 +608,50 @@ func TestPartnerWantHaveWantBlockActive(t *testing.T) {
 			// want-have is active when want-block is added, so want-have
 			// should get sent, then want-block
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					haves: "b",
 				},
-				testCaseExp{
+				{
 					blks: "b",
 				},
 			},
 		},
 
 		// Send want-block then want-block for same CID
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantBlks:     "a",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantBlks:     "a",
 					sendDontHave: true,
 				},
 			},
 			// second want-block should be ignored
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					blks: "a",
 				},
 			},
 		},
 
 		// Send want-have then want-have for same CID
-		testCase{
+		{
 			wls: []testCaseEntry{
-				testCaseEntry{
+				{
 					wantHaves:    "a",
 					sendDontHave: true,
 				},
-				testCaseEntry{
+				{
 					wantHaves:    "a",
 					sendDontHave: true,
 				},
 			},
 			// second want-have should be ignored
 			exp: []testCaseExp{
-				testCaseExp{
+				{
 					haves: "a",
 				},
 			},
diff --git a/network/ipfs_impl_test.go b/network/ipfs_impl_test.go
index 475fcfc..0d7968e 100644
--- a/network/ipfs_impl_test.go
+++ b/network/ipfs_impl_test.go
@@ -447,10 +447,10 @@ func TestSupportsHave(t *testing.T) {
 	}
 
 	testCases := []testCase{
-		testCase{bsnet.ProtocolBitswap, true},
-		testCase{bsnet.ProtocolBitswapOneOne, false},
-		testCase{bsnet.ProtocolBitswapOneZero, false},
-		testCase{bsnet.ProtocolBitswapNoVers, false},
+		{bsnet.ProtocolBitswap, true},
+		{bsnet.ProtocolBitswapOneOne, false},
+		{bsnet.ProtocolBitswapOneZero, false},
+		{bsnet.ProtocolBitswapNoVers, false},
 	}
 
 	for _, tc := range testCases {
diff --git a/testinstance/testinstance.go b/testinstance/testinstance.go
index 2ee6be8..05e3d51 100644
--- a/testinstance/testinstance.go
+++ b/testinstance/testinstance.go
@@ -5,8 +5,8 @@ import (
 	"time"
 
 	bitswap "github.com/ipfs/go-bitswap"
-	tn "github.com/ipfs/go-bitswap/testnet"
 	bsnet "github.com/ipfs/go-bitswap/network"
+	tn "github.com/ipfs/go-bitswap/testnet"
 	ds "github.com/ipfs/go-datastore"
 	delayed "github.com/ipfs/go-datastore/delayed"
 	ds_sync "github.com/ipfs/go-datastore/sync"
diff --git a/testnet/virtual.go b/testnet/virtual.go
index 48ef7b4..66f5e82 100644
--- a/testnet/virtual.go
+++ b/testnet/virtual.go
@@ -271,9 +271,9 @@ func (mp *messagePasser) Reset() error {
 }
 
 var oldProtos = map[protocol.ID]struct{}{
-	bsnet.ProtocolBitswapNoVers:  struct{}{},
-	bsnet.ProtocolBitswapOneZero: struct{}{},
-	bsnet.ProtocolBitswapOneOne:  struct{}{},
+	bsnet.ProtocolBitswapNoVers:  {},
+	bsnet.ProtocolBitswapOneZero: {},
+	bsnet.ProtocolBitswapOneOne:  {},
 }
 
 func (mp *messagePasser) SupportsHave() bool {