From 7005cd6c651649f29cb9fd69e705ea3db43ddb11 Mon Sep 17 00:00:00 2001 From: notanatol Date: Thu, 18 May 2023 15:54:13 +0300 Subject: [PATCH] fix: start host --- pkg/p2p/libp2p/main_test.go | 1 + pkg/p2p/libp2p/protocols_test.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/p2p/libp2p/main_test.go b/pkg/p2p/libp2p/main_test.go index caff0a5065c..25dc9afb605 100644 --- a/pkg/p2p/libp2p/main_test.go +++ b/pkg/p2p/libp2p/main_test.go @@ -17,6 +17,7 @@ func TestMain(m *testing.M) { goleak.IgnoreTopFunction("sync.runtime_Semacquire"), goleak.IgnoreTopFunction("net.ParseCIDR"), goleak.IgnoreTopFunction("github.com/ipfs/go-log/writer.(*MirrorWriter).logRoutine"), + goleak.IgnoreTopFunction("github.com/libp2p/go-flow-metrics.(*sweeper).runActive"), goleak.IgnoreTopFunction("github.com/huin/goupnp/httpu.(*MultiClient).Do.func2"), goleak.IgnoreTopFunction("github.com/libp2p/go-flow-metrics.(*sweeper).run"), goleak.IgnoreTopFunction("github.com/libp2p/go-cidranger.(*prefixTrie).insert"), diff --git a/pkg/p2p/libp2p/protocols_test.go b/pkg/p2p/libp2p/protocols_test.go index 82fd54ed859..b4f2fab91f8 100644 --- a/pkg/p2p/libp2p/protocols_test.go +++ b/pkg/p2p/libp2p/protocols_test.go @@ -408,7 +408,7 @@ func TestPing(t *testing.T) { s1, _ := newService(t, 1, libp2pServiceOpts{ libp2pOpts: libp2p.WithHostFactory( - func(_ ...libp2pm.Option) (host.Host, error) { + func(...libp2pm.Option) (host.Host, error) { return bhost.NewHost(swarmt.GenSwarm(t), &bhost.HostOpts{EnablePing: true}) }, ), @@ -416,8 +416,13 @@ func TestPing(t *testing.T) { s2, _ := newService(t, 1, libp2pServiceOpts{ libp2pOpts: libp2p.WithHostFactory( - func(_ ...libp2pm.Option) (host.Host, error) { - return bhost.NewHost(swarmt.GenSwarm(t), &bhost.HostOpts{EnablePing: true}) + func(...libp2pm.Option) (host.Host, error) { + host, err := bhost.NewHost(swarmt.GenSwarm(t), &bhost.HostOpts{EnablePing: true}) + if err != nil { + t.Fatalf("start host: %v", err) + } + host.Start() + return host, nil }, ), })