Skip to content

Commit

Permalink
feat: plumb peerstore contexts changes through (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
guseggert committed Nov 10, 2021
1 parent 90403a4 commit 0af1a4b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
20 changes: 13 additions & 7 deletions p2p/discovery/backoff/backoffcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ func TestBackoffDiscoverySingleBackoff(t *testing.T) {

discServer := newDiscoveryServer()

h1 := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
h2 := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
h1 := bhost.NewBlankHost(swarmt.GenSwarm(t))
defer h1.Close()
h2 := bhost.NewBlankHost(swarmt.GenSwarm(t))
defer h2.Close()
d1 := &mockDiscoveryClient{h1, discServer}
d2 := &mockDiscoveryClient{h2, discServer}

Expand Down Expand Up @@ -100,8 +102,10 @@ func TestBackoffDiscoveryMultipleBackoff(t *testing.T) {

discServer := newDiscoveryServer()

h1 := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
h2 := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
h1 := bhost.NewBlankHost(swarmt.GenSwarm(t))
defer h1.Close()
h2 := bhost.NewBlankHost(swarmt.GenSwarm(t))
defer h2.Close()
d1 := &mockDiscoveryClient{h1, discServer}
d2 := &mockDiscoveryClient{h2, discServer}

Expand Down Expand Up @@ -152,7 +156,8 @@ func TestBackoffDiscoverySimultaneousQuery(t *testing.T) {
advertisers := make([]discovery.Discovery, n)

for i := 0; i < n; i++ {
h := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
h := bhost.NewBlankHost(swarmt.GenSwarm(t))
defer h.Close()
advertisers[i] = &mockDiscoveryClient{h, discServer}
}

Expand Down Expand Up @@ -210,11 +215,12 @@ func TestBackoffDiscoveryCacheCapacity(t *testing.T) {
advertisers := make([]discovery.Discovery, n)

for i := 0; i < n; i++ {
h := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
h := bhost.NewBlankHost(swarmt.GenSwarm(t))
defer h.Close()
advertisers[i] = &mockDiscoveryClient{h, discServer}
}

h1 := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
h1 := bhost.NewBlankHost(swarmt.GenSwarm(t))
d1 := &mockDiscoveryClient{h1, discServer}

const discoveryInterval = time.Millisecond * 100
Expand Down
3 changes: 2 additions & 1 deletion p2p/discovery/backoff/backoffconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ func getNetHosts(t *testing.T, ctx context.Context, n int) []host.Host {
var out []host.Host

for i := 0; i < n; i++ {
netw := swarmt.GenSwarm(t, ctx)
netw := swarmt.GenSwarm(t)
h := bhost.NewBlankHost(netw)
t.Cleanup(func() { h.Close() })
out = append(out, h)
}

Expand Down

0 comments on commit 0af1a4b

Please sign in to comment.