Skip to content

Commit

Permalink
test: fix failing test (#3141)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo authored Jan 16, 2025
1 parent 4651a0d commit 9fe14c2
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 9fe14c2

Please sign in to comment.