Skip to content

Commit

Permalink
webtransport: initialize a NullResourceManager if none is provided (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored Dec 29, 2022
1 parent 47f9ea1 commit e59aba2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions p2p/transport/webtransport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func New(key ic.PrivKey, psk pnet.PSK, connManager *quicreuse.ConnManager, gater
log.Error("WebTransport doesn't support private networks yet.")
return nil, errors.New("WebTransport doesn't support private networks yet")
}
if rcmgr == nil {
rcmgr = &network.NullResourceManager{}
}
id, err := peer.IDFromPrivateKey(key)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions p2p/transport/webtransport/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func newConnManager(t *testing.T, opts ...quicreuse.Option) *quicreuse.ConnManag

func TestTransport(t *testing.T) {
serverID, serverKey := newIdentity(t)
tr, err := libp2pwebtransport.New(serverKey, nil, newConnManager(t), nil, &network.NullResourceManager{})
tr, err := libp2pwebtransport.New(serverKey, nil, newConnManager(t), nil, nil)
require.NoError(t, err)
defer tr.(io.Closer).Close()
ln, err := tr.Listen(ma.StringCast("/ip4/127.0.0.1/udp/0/quic-v1/webtransport"))
Expand All @@ -117,7 +117,7 @@ func TestTransport(t *testing.T) {
addrChan := make(chan ma.Multiaddr)
go func() {
_, clientKey := newIdentity(t)
tr2, err := libp2pwebtransport.New(clientKey, nil, newConnManager(t), nil, &network.NullResourceManager{})
tr2, err := libp2pwebtransport.New(clientKey, nil, newConnManager(t), nil, nil)
require.NoError(t, err)
defer tr2.(io.Closer).Close()

Expand Down

0 comments on commit e59aba2

Please sign in to comment.