Skip to content

Commit

Permalink
test: fix failing test
Browse files Browse the repository at this point in the history
We shouldn't be actually resolving DNS names for this test. The failure
was due to example.com updating their A and AAAA records.
  • Loading branch information
MarcoPolo committed Jan 16, 2025
1 parent 4651a0d commit 85bb703
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion p2p/net/swarm/swarm_dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,23 @@ func TestBlackHoledAddrBlocked(t *testing.T) {
require.ErrorIs(t, err, ErrDialRefusedBlackHole)
}

type mockDNSResolver struct {
ipsToReturn []net.IPAddr
txtsToReturn []string
}

var _ madns.BasicResolver = (*mockDNSResolver)(nil)

func (m *mockDNSResolver) LookupIPAddr(_ context.Context, _ string) ([]net.IPAddr, error) {
return m.ipsToReturn, nil
}

func (m *mockDNSResolver) LookupTXT(_ context.Context, _ string) ([]string, error) {
return m.txtsToReturn, nil
}

func TestSkipDialingManyDNS(t *testing.T) {
resolver, err := madns.NewResolver()
resolver, err := madns.NewResolver(madns.WithDefaultResolver(&mockDNSResolver{ipsToReturn: []net.IPAddr{{IP: net.ParseIP("1.2.3.4")}, {IP: net.ParseIP("1.2.3.5")}}}))
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 85bb703

Please sign in to comment.