From 747c1140be7d5d1732cc0d59d306dea38fb9a131 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 23 Apr 2022 02:26:22 +0200 Subject: [PATCH] fix(tests): panic during sharness --- core/node/libp2p/routing.go | 5 +++++ test/sharness/.gitignore | 1 + test/sharness/t0160-resolve.sh | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/node/libp2p/routing.go b/core/node/libp2p/routing.go index 254ab8cfe61..5ba32279249 100644 --- a/core/node/libp2p/routing.go +++ b/core/node/libp2p/routing.go @@ -197,6 +197,11 @@ func AutoRelayFeeder(lc fx.Lifecycle, h host.Host, peerChan chan peer.AddrInfo, case <-ctx.Done(): return } + // TODO: refactor AutoRelayFeeder, for now we skip it if dht missing to fix sharness panics + if dht == nil { + fmt.Println("AutoRelayFeeder: noop due to missing dht.WAN") + continue + } closestPeers, err := dht.WAN.GetClosestPeers(ctx, h.ID().String()) if err != nil { fmt.Println(err) diff --git a/test/sharness/.gitignore b/test/sharness/.gitignore index 06ceccc7567..c7ab08146c5 100644 --- a/test/sharness/.gitignore +++ b/test/sharness/.gitignore @@ -2,3 +2,4 @@ lib/sharness/ test-results/ trash directory.*.sh/ plugins +*.DS_Store diff --git a/test/sharness/t0160-resolve.sh b/test/sharness/t0160-resolve.sh index 600e4c07bba..4b967704946 100755 --- a/test/sharness/t0160-resolve.sh +++ b/test/sharness/t0160-resolve.sh @@ -125,7 +125,7 @@ test_resolve_cmd_b32() { local self_hash_b32libp2pkey=$(echo $self_hash | ipfs cid format -v 1 -b b --codec libp2p-key) test_expect_success "resolve of /ipns/{cidv1} with multicodec other than libp2p-key returns a meaningful error" ' test_expect_code 1 ipfs resolve /ipns/$self_hash_b32protobuf 2>cidcodec_error && - grep "Error: peer ID represented as CIDv1 require libp2p-key multicodec: retry with /ipns/$self_hash_b32libp2pkey" cidcodec_error + test_should_contain "Error: peer ID represented as CIDv1 require libp2p-key multicodec: retry with /ipns/$self_hash_b32libp2pkey" cidcodec_error ' }