mirror of
https://github.com/libp2p/go-libp2p.git
synced 2026-04-23 00:27:05 +08:00
9d149fa3cb
* config: refactor AutoNAT construction into separate method * config: use a lifecycle hook to start listening on swarm addresses * use Fx to construct the host * add a test for constructing a routed host * use Fx hooks to start the host * config: use Fx lifecycle hooks to start AutoRelay and for PeerRouting * basichost: don't close the swarm The swarm is not constructed by the basic host, thus is shouldn't be closed by it. * config: use Fx hook to close the quicreuse connection manager * test for goroutine leaks when starting/stopping fx To do this, I've had to move a few leaky tests into a separate package. I've filed a bug for the AutoNAT issue (#2743) but the "error on startup" issue is going to require some pretty invasive changes (we need to construct _then_ start). * go fmt * Ignore one more top function * Typo * Ignore any not top --------- Co-authored-by: Sukun <sukunrt@gmail.com> Co-authored-by: Steven Allen <steven@stebalien.com> Co-authored-by: Marco Munizaga <git@marcopolo.io>
27 lines
524 B
Go
27 lines
524 B
Go
package leaky_test
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/libp2p/go-libp2p"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestBadTransportConstructor(t *testing.T) {
|
|
h, err := libp2p.New(libp2p.Transport(func() {}))
|
|
if err == nil {
|
|
h.Close()
|
|
t.Fatal("expected an error")
|
|
}
|
|
if !strings.Contains(err.Error(), "_test.go") {
|
|
t.Error("expected error to contain debugging info")
|
|
}
|
|
}
|
|
|
|
func TestAutoNATService(t *testing.T) {
|
|
h, err := libp2p.New(libp2p.EnableNATService())
|
|
require.NoError(t, err)
|
|
h.Close()
|
|
}
|