Skip to content

Commit

Permalink
test: test kubo boot with webtransport
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed May 5, 2023
1 parent 938ac17 commit fe5d390
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/cli/transports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,36 @@ func TestTransports(t *testing.T) {
})

}

func TestStartsWebTransport(t *testing.T) {
t.Run("announces without listening on web transport", func(t *testing.T) {
t.Parallel()
n := harness.NewT(t).NewNode().Init()
n.UpdateConfig(func(cfg *config.Config) {
cfg.Addresses.Swarm = []string{"/ip4/127.0.0.1/udp/0/quic-v1"}
cfg.Addresses.Announce = []string{"/ip4/127.0.0.1/udp/0/quic-v1/webtransport"}
})
n.StartDaemon()

// If we announce WebTransport, but do not listen on it, there will NOT
// be a certhash since the certificate manager is not initialized.
output := string(n.Daemon.Stdout.Bytes())
assert.Contains(t, output, "/webtransport")
assert.NotContains(t, output, "certhash")
})

t.Run("announces and listens on web transport", func(t *testing.T) {
t.Parallel()
n := harness.NewT(t).NewNode().Init()
n.UpdateConfig(func(cfg *config.Config) {
cfg.Addresses.Swarm = []string{"/ip4/127.0.0.1/udp/0/quic-v1", "/ip4/127.0.0.1/udp/0/quic-v1/webtransport"}
cfg.Addresses.Announce = []string{"/ip4/127.0.0.1/udp/0/quic-v1/webtransport"}
})
n.StartDaemon()

// If we announce and listen on WebTransport, there will be a WebTransport
// address WITH a certhash.
output := string(n.Daemon.Stdout.Bytes())
assert.Contains(t, output, "/webtransport/certhash/")
})
}

0 comments on commit fe5d390

Please sign in to comment.